wait for the candle to close
-
i am using 3 flags (true-false)
if indicator appears on current candle then flag one should be turned true and the ea wait till this candle closes and move on to next candle (Now this candle becomes current candle) if the indicator appears on this candle as well it turns the second flag true and wait for this candle to close and move forward, is it possible? -
-
Is working on the current candle (candle ID 0) completely necessary. My experience says that it is not a good idea, initially. Please notic that you never know what the current candle is going to do. Can't you work on candle ID 1?
-
@l-andorrà well I am in a strange situation because of this current candle issue,
Here is what I am trying to do :
I have an indicator that displays arrows on current candle, but most of the times the arrow disappear as soon as the current candle closes, and what I am trying to do is whenever the arrows appears on current candle the ea should wait to see if the same thing happens to 2 out of three consecutive candles,
let's consider this scenario, we have three previous candles candle 1, candle 2, and candle 3, now indicator did appeared on the candle 3 when it was forming (before candle 3 closed) but it disappeared as soon as that candle closes, and then candle 2 also has same thing happened, and then for candle 1 either the same thing happened or indicator did not disappeared after it closed.
Now we are left with three candles (previous candles that have been closed) now on the current candle we open the trade even if indicator does not appear for current candle -
Could you please share your project? A screenshot showing what you exactly want would also be useful.
-
@l-andorrà https://fxdreema.com/shared/5Oq0mJc

As you can see there are three arrows when i run the back test but there will only be one arrow in realtime because the indicator removes the arrows sometimes
arrow appears on current candle so it removes the arrows sometime but in back test the arrows are left on the chart
So what I am trying to do is, once every candle if an arrow appears on the current candle, the ea turn a flag true and wait for that candle to close and then on new candle ea wait and see if arrow appears on this candle as well, of the arrow appears then turn the second flag true and wait for the candle to close, now the new candle appears, and if the arrow appear on this candle as well, the ea turn the 3rd flag true -
@l-andorrà does this make any sense to you?
-
I think the best option is requiring a condition for closed candles 1 and to to show the arrow. Then adding another condition block for current candle (ID 0).
The problem is that maybe candle 0 loses its arrow due to price move after trade was opened. Would you accept that?
-
@l-andorrà
Of course, it doesnt matter if the current candle looses the arrow, as long as the the flag for that candle gets turned "true" -
@l-andorrà I am trying to turn a flag true for every current candle that have or had an arrow appeared on it, let say there are 10 candles on question, and all ten candles had the arrows appeared on them but let say 5 of them lost the arrows along the way,
But still all 10 flags needs to be turned true -
Then what's the problem exactly?
-
@l-andorrà
The Main problem is arrow is appearing on the current candle so it gets removed if price is not favoring the arrow direction
And second problem is, I don't know how to tell the ea to wait for the current candle to close once the flag is turned true,
And third problem is I don't know how the ea will know if these flags that were turned true are for three consecutive candles or not -
IMHO you should forget that flag on current candle. The EA knowing if candles 1,2 and 3 have a flag is easy. The question is, would your strategy work that way?
-
Here is what I made: https://fxdreema.com/shared/ZfD9Tt4Nc
I have 2 variables:

To simulate the indicator I have blocks 5--6-7 where I create a new arrow only in some candles. In your project these blocks should be like: Condition -> Once per bar.
At block 8 imagine that you just detected the appearance of a new candle. So, I increment ArrowsCounter with 1 and I set ArrowDetected to "true" to indicate that within this candle I detected a signal.
In block 10 I check how many candles I detected. And if I detected enough (in my case 4), I can continue doing whatever needs to be done. But first I reset ArrowsCounter to 0, so the counting starts again. "Draw Line" is to see when I detected 4 arrows in a row.
If no arrow is detected inside the candle, we need to start counting again. So, in blocks 1-2-3-4 what I do is once per bar to check if ArrowDetected equals to false and reset ArrowsCounter to 0 if this is the case. Also, block 1 passes in the beginning of each new candle, so here is where I reset ArrowDetected to false, so then in the middle of the candle it can be set to true.
-
@l-andorrà yup that's the only way it will work, cuz I tried it on demo and, I tried it on past data and its the only way the strategy works
-
@fxdreema perfect, that's precisely what I am looking for thanks a lot