| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Quote:
Should have added that you need to use 'MODE_HISTORY' with OrderSelect()... Last edited by omelette; 01-18-2008 at 06:21 PM. |
|
|||
|
Quote:
Do you know that BT have a problem looking in the history: it looks on the real history, not the one of the BT. I asked Metaquote few months ago about this bug but they didn't have any answer.... Maybe now it's fixed... |
|
|||
|
Help on function call
Hi,
I would like to replace the code of this indicator : int start() { int bar, limit, i; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //Hull average computation for(i=0; i<limit; i++) TempBuf1[i]=2*iMA(NULL,0,HalfHullPeriod,0,MODE_LWMA,PRICE_CLO SE,i)-iMA(NULL,0,HullPeriod,0,MODE_LWMA,PRICE_CLOSE,i); for(i=0; i<limit; i++) HullBuf[i]=iMAOnArray(TempBuf1,0,SqrtHullPeriod,0,MODE_LWMA, i); //---- return(0); } by a call at a function like that : double ComputeHull(double MyArray[], int MyPeriod) { double MyTemp[]; double result = -1; int i; int HalfPeriod = MathRound(MyPeriod/2); int SqrtPeriod = MathRound(MathSqrt(MyPeriod)); //Copy Close Values to CloseTemp ArrayResize(MyTemp, SqrtPeriod); ArraySetAsSeries(MyTemp, true); //HMA value computation for(i=0; i<SqrtPeriod; i++) { MyTemp[i] = 2*iMAOnArray(MyArray, 0, HalfPeriod, 0, MODE_LWMA, i) - iMAOnArray(MyArray, 0, MyPeriod, 0, MODE_LWMA, i); } result = iMAOnArray(MyTemp, 0, SqrtPeriod, 0, MODE_LWMA, 0); //---- done return(result); } int start() { double CloseTemp[]; int bar, limit, i; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; ArrayResize(CloseTemp, HullPeriod+SqrtHullPeriod); ArraySetAsSeries(CloseTemp, true); for(i=0; i<limit; i++) { ArrayCopy(CloseTemp, Close, 0, i, HullPeriod+SqrtHullPeriod); HullAntBuf[i]=ComputeHull(CloseTemp, HullPeriod); } //---- return(0); } I don't understand why the result is not the same. It is not a spécific problem about the HMA just i'd like to ompute my indicator in a spécific function where the array is passed in argument. I've attached source code of an indicator which display the two curves, it's seems that it is the second call to iMAOnArray which done different results. Please help me i don't understand the problem |
|
||||
|
Check out Formal parameters - MQL4 Documentation
|
|
|||
|
Best way to add MaxBarsToCount (History) to the limit
whan we limit MaxBarsToCount (History) sometimes it require to add Correction, etc
is the best (safest, easiest, universal) way exists? ---------------------- like here we have light fisher 4 stoch smothing: ---------- int start() { int counted_bars=IndicatorCounted(); //---- check for possible errors if(counted_bars<0) return(-1); int limit=Bars-counted_bars; if(limit>maxbars)limit=maxbars; if (limit>Bars-lenth-1)limit=Bars-lenth-1; //---- for (int shift = limit; shift>=0;shift--) { AuxBuffer[shift]=(iStochastic(NULL,0,lenth,2,1,MODE_SMA,0,MODE_MAI N,shift)/100-0.5) +0.5*AuxBuffer[shift+1]; FishBuffer[shift]= 0.25* MathLog((1+AuxBuffer[shift])/(1-AuxBuffer[shift]))+ 0.5*FishBuffer[shift+1]; SignalBuffer[shift]=FishBuffer[shift+1]; } //---- return(0); } ------------------------ for fisher limit f-la: int limit; int counted_bars=IndicatorCounted(); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; for(int i=limit; i>=0; i--) { .... for Stoch: int start() { int i,k; int counted_bars=IndicatorCounted(); double price; //---- if(Bars<=draw_begin2) return(0); //---- initial zero if(counted_bars<1) { for(i=1;i<=draw_begin1;i++) MainBuffer[Bars-i]=0; for(i=1;i<=draw_begin2;i++) SignalBuffer[Bars-i]=0; } //---- minimums counting i=Bars-KPeriod; if(counted_bars>KPeriod) i=Bars-counted_bars-1; while(i>=0) { double min=1000000; k=i+KPeriod-1; while(k>=i) { price=Low[k]; if(min>price) min=price; k--; } LowesBuffer[i]=min; i--; } .... p.s. in attached indicator, based on clean fisher transform and Stoch; MaxBars needs to be straighten-up a bit... (when MaxBars out - no problem) Last edited by fxbs; 01-19-2008 at 01:16 PM. |
|
|||
|
Hi,
Thanks a lot to all of you. It is working fine now and only one order per bar is opened. What is nice with an EA like this is that we can use the "Open price only" option for backtesting, which is faster than the "per tick" one. |
|
|||
|
Quote:
To check this (with MT 208), I used OrdersHistoryTotal() info. to decide trade direction on a martingaler, and used 'conventional means' on another version - the equity curve for both 'should' be identical. This is what I found......... ![]() I have also just checked with the latest Metatrader and the bug is still there - unbelieveable..... |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 04:22 PM |