Hi
I m trying to create a very simple EA (thats my first one) that will use a simple indicator to enter and exit a trade.
This indicator has two lines (Buffers) a green and a red. So I want to enter the trade when green & red cross and exit when they cross again AND RE-ENTER the trade.
I ve created the code bellow based on an MT4 EA code:
Is this ok ? I m asking cause when i m also placing the indicator with the EA as well it doesn't show correct but the code looks ok to me.
Or should i say something like :
Also during a backtest, is there a way to output anything to a file/log/Console/Print whatever?
Thanks
The Indicator you are using, it only has one extern variable ?
You can Print() from your EA while it is in the Strategy Tester, the output will appear in the Strategy Tester journal tab and also in the log in tester/logs
The Indicator you are using, it only has one extern variable ?
You can Print() from your EA while it is in the Strategy Tester, the output will appear in the Strategy Tester journal tab and also in the log in tester/logs
Thanks for your answer Raptor.
Yes it has only one extern variable. I do not need any more cause i do not want any money management at this stage. I just want to test it with a standard lot size.
Any ideas if the code is ok so to enter the trade when green & red cross and exit when they cross again AND RE-ENTER the trade?
Thanks for your answer Raptor.
Yes it has only one extern variable. I do not need any more cause i do not want any money management at this stage. I just want to test it with a standard lot size.
Any ideas if the code is ok so to enter the trade when green & red cross and exit when they cross again AND RE-ENTER the trade?
There are some things you need to consider, does your Indicator handle bar 0 ? meaning does it repaint ? if your EA uses bar 0 data from your Indicator it can be crossing multiple times during bar 0, how do you propose to handle that ?
Well my indicator is using bar 0 but i m not sure how an indicator can repaint. As far as i have checked, my indicator crosses do not change position as time passes.
i m only interested in enter/exit a trade as soon as a candle is closed and there is a cross.
Well my indicator is using bar 0 but i m not sure how an indicator can repaint. As far as i have checked, my indicator crosses do not change position as time passes.
i m only interested in enter/exit a trade as soon as a candle is closed and there is a cross.
You should not be using bar 0 then . . . use bars 1 and 2 (and maybe bar 3) and check for the cross as soon as a new bar 1 is created . . .
If you want to see an Indicator repaint put a SMA on a M1 chart applied to the close price, call up the Data Windows (Ctrl + D) an watch the Indicator value for bar 0 and you will see it changes, repaints.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
I m trying to create a very simple EA (thats my first one) that will use a simple indicator to enter and exit a trade.
This indicator has two lines (Buffers) a green and a red. So I want to enter the trade when green & red cross and exit when they cross again AND RE-ENTER the trade.
I ve created the code bellow based on an MT4 EA code:
Is this ok ? I m asking cause when i m also placing the indicator with the EA as well it doesn't show correct but the code looks ok to me.
Or should i say something like :
Also during a backtest, is there a way to output anything to a file/log/Console/Print whatever?
Thanks