Hi there
I'm trying to build a simple EA. Here's the code I am using now - this opens one trade per bar for the current timeframe (H4).
The problem is that it sometimes opens the second trade on the next H4 bar and this is to soon. Basically, if the trend reverses I will lose 2 trades, both opened based on the same signal. I need a delay of X bars to make sure that the current trade signal expired. I don't want to use the sleep function, I've heard it uses to much of the CPU.
Any idea how to?
Btw, please understand that I'm still experimenting with coding, so if you can help post the entire code. In other words, don't bother with instructions because there's a 99% chance I won't understand them
I'm trying to build a simple EA. Here's the code I am using now - this opens one trade per bar for the current timeframe (H4).
Inserted Code
......... datetime prevTime; int start() { if (prevTime==Time[0]) return(0); prevTime=Time[0]; ..........
The problem is that it sometimes opens the second trade on the next H4 bar and this is to soon. Basically, if the trend reverses I will lose 2 trades, both opened based on the same signal. I need a delay of X bars to make sure that the current trade signal expired. I don't want to use the sleep function, I've heard it uses to much of the CPU.
Any idea how to?
Btw, please understand that I'm still experimenting with coding, so if you can help post the entire code. In other words, don't bother with instructions because there's a 99% chance I won't understand them
Using the RobotFX EAs for a while https://www.robotfx.org/