David Gauch:
Hey guys,
Im new here in coding, I tried to code together an EAm which simply uses the last 6 Candles, if thosse 6 are down-candles it opens up a long-position. That seems to work, but I cant get my EA to close that position on the next candle.
I would be glad, if theres anyone who can help me on that. I will provide the Code down below:
use the trade class to open positions.
It's simple, and less messy
#include <Trade/Trade.mqh> CTrade trade; Void OnTick() { //open BUY trade trade.Buy(0.01,NULL); //close trade trade.PositionClose(...); }
just a snippet. this code will not compile
David Gauch: That seems to work, but I cant get my EA to close that position on the next candle.
Where do you check for a new candle?
Where do you check for an open order? Where do you try to close it?
to close "on the next candle" means you need to do something with position time or bar open time. As that guy mentioned, create a reference to the CTrade object to have full control over how you manage trades

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hey guys,
Im new here in coding, I tried to code together an EAm which simply uses the last 6 Candles, if thosse 6 are down-candles it opens up a long-position. That seems to work, but I cant get my EA to close that position on the next candle.
I would be glad, if theres anyone who can help me on that. I will provide the Code down below: