Hello Everyone,
I try to create the strategy for EA. It is based on simple average from indicator. Strategy which I have already created is below:
The strategy is simple: When two lines cross we have signal. Signal buy is when next bar closes higher then high of bar on which the signal appeared. Signal sell is when next bar closes lower then low of bar on which the signal appeared.
The first issue is that I would like to define the High and low of bar where the signal appears.
The secondly I would like to under <missing code> define criteria opening or closing ticket which I described above.
I will be appreciated for any help.
kanar
Thank you for creating this new thread :-)
Are you sure that your iCustom call is correct ? you are retrieving the value for Bar number 6 from buffer number 4 . . . is that what you meant to do ?
Thank you for creating this new thread :-)
Are you sure that your iCustom call is correct ? you are retrieving the value for Bar number 6 from buffer number 4 . . . is that what you meant to do ?
It works as I expect. It should be from buffer 4 and it is shifted 6 bars ahead. The same effect I have on indicator. I wonder how to point bar under EA where the buy and sell appear. The bar which its close is higher then the high of bar where the signal appears and the same for sell. Below visualization. :)
It works as I expect. It should be from buffer 4 and it is shifted 6 bars ahead. The same effect I have on indicator. I wonder how to point bar under EA where the buy and sell appear. The bar which its close is higher then the high of bar where the signal appears and the same for sell. Below visualization. :)
A shift of 6 does not mean "shifted" it means bar 6 where the current bar is bar 0, the next bar to the left is bar 1, then 2 etc. So you are looking at the value for bar 6, or the 7th bar on the chart going from right to left. if you want to look a the next bar then that is bar 5.
Can you post your Indicator ?
double high=iHigh(Symbol(),PERIOD_H4,0); double low=iLow(Symbol(),PERIOD_H4,0);This will not work for any chart except H4 in the tester. You can not get bar zero data in the tester for other timeframes. Testing Features and Limits in MetaTrader 4 - MQL4 Articles
Hello again,
Thanks Raptor for explanation. Your clue gave me another point of view for EA. I decided to modify my indicator. In Indicator I point bar where the signal buy or sell occurs. When signal buy occurs then variable SIGNAL have value 1.0 (double). When signal sell occurs then variable SIGNAL will get -1.0 (double as well). Having this EA doesn't look so complicated:
SIGNAL = iCustom(NULL,0,"INDICATOR_FOR_TRADING",Avg,Shift,6,0);
INDICATOR_FOR_TRADING - indicator where sell and buy signal is generated in sixth buffer
Avg,Shift - extern int value which are used to calculate the indicator "INDICATOR_FOR_TRADING"
if (SIGNAL == 1.0) { Print ("Opn_B=" , SIGNAL ); Opn_B=true; } if (SIGNAL == -1.0) { Print ("Opn_B=" , SIGNAL ); Opn_S=true; }
Please tell me if it is correct or not because it doesn't give me any result :) when EA is executed. EA loads all needed things but sell and buy is not generated. I think that something is wrong with above code. Indicator works great. Thanks in advance.
Please tell me if it is correct or not because it doesn't give me any result :) when EA is executed. EA loads all needed things but sell and buy is not generated. I think that something is wrong with above code. Indicator works great. Thanks in advance.
if (MA[i]>MA2[i] && iWaitFor == PLOTDOWN) { iWaitFor = PLOTUP; CROSS[i-Shift] = 0.0; f=1; while (High[i-Shift]>Close[i-f-Shift] && Close[i-f-Shift]>Low[i-Shift]) { f++; } if (Close[i-f-Shift]>High[i-Shift]) { SIGNAL[i-f-Shift-1]= 1.0; } if (Close[i-f-Shift]<Low[i-Shift]) { SIGNAL[i-f-Shift-1]= -1.0; } }Above there is an indicator which calculates value and returns to buffer.
This will not work for any chart except H4 in the tester. You can not get bar zero data in the tester for other timeframes. Testing Features and Limits in MetaTrader 4 - MQL4 Articles
Is that article still accurate? I noticed another article which seems to contradict it was posted a few years later: https://www.mql5.com/en/articles/1490
The tester in MetaTrader 4 allows seeing not only the tested timeframe, but also other - higher and lower - timeframes. Thus, if we test an Expert Advisor on the timeframe EURUSD M15, we can see the values of the indicators for EURUSD H1 or EURUSD M5. We can also see the maximal and minimal prices of the current zero bar on any available timeframe EURUSD.
Thus, the task of the tester is to model correctly not only the current timeframe, but also all other necessary timeframes. This task is solved in the tester the following way: not only the bar progress on the current zero bar is modelled, but also all other timeframes are modelled the same way. The receipt of each new tick changes the information about the zero bar condition on each timeframe, everything is done synchronously.
All requested timeframes (and not only prices, but also volumes) are correctly modelled. The tester sees the synchronous price progress on each timeframe, like in real life:
Is that article still accurate? I noticed another article which seems to contradict it was posted a few years later: https://www.mql5.com/en/articles/1490
Can you copy and paste the contradiction ? I don't seem to see it . . .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone,
I try to create the strategy for EA. It is based on simple average from indicator. Strategy which I have already created is below:
The strategy is simple: When two lines cross we have signal. Signal buy is when next bar closes higher then high of bar on which the signal appeared. Signal sell is when next bar closes lower then low of bar on which the signal appeared.
The first issue is that I would like to define the High and low of bar where the signal appears.
The secondly I would like to under <missing code> define criteria opening or closing ticket which I described above.
I will be appreciated for any help.
kanar