Make a global or static boolean variable like flag. When the condition has occurred and flag=true open the order and make flag=false. Now if the order closes, a new order will not open. When the condition has gone, set flag=True again.
Roger: Make a global or static boolean variable of type flag. When the condition is reached and flag=true, open an order and make flag=false. Now, if the order is closed, a new order will not be opened. When the condition has gone, set flag=True again.
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has closed.
That is, I need to know that the order has been executed, but it has closed n candles ago because the N condition has triggered. And if the condition N has disappeared, and no more than n candles have passed since the close of the order, we should open the order again.
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has been concluded.
That is to say I need to know that the order has been concluded but it has closed n candles ago because of the N condition. And if the condition N has disappeared and no more than n candles have passed since the close of the order, we should open the order again.
Imagine the situation: a stop is triggered, because of the triggering of the N-th condition. But after a couple of candlesticks, the N-th condition has fallen away. With the help of which function you can open the deal again after the N-th condition falls out. That is, you need to determine that triggered a stop some number of bars ago, and because the N-th condition fell off, re-open the trade!
if programmatically - when opening an order - there is a magik and a comment - you can encrypt the information about which condition the order is opened, in the magik or comment
in general, the stop is not triggered by a condition, but when the price reaches a price level - this order can be closed by a condition
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order is closed.
That is, I need to know that the order has been placed, but has closed n candles ago due to triggering of condition N. And if condition N has disappeared and no more than n candles have passed since the order was closed, I need to open the order again.
You do not want to complicate things too much? After all, the order could have been closed if condition X had been present, although condition N may also have been present.
The solution depends a lot on your position management logic, for example to find orders which have been closed no later than n candlesticks and to check the event N at the moment the order is closed and at the current moment.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Make a global or static boolean variable of type flag. When the condition is reached and flag=true, open an order and make flag=false. Now, if the order is closed, a new order will not be opened. When the condition has gone, set flag=True again.
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has closed.
That is, I need to know that the order has been executed, but it has closed n candles ago because the N condition has triggered. And if the condition N has disappeared, and no more than n candles have passed since the close of the order, we should open the order again.
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order has been concluded.
That is to say I need to know that the order has been concluded but it has closed n candles ago because of the N condition. And if the condition N has disappeared and no more than n candles have passed since the close of the order, we should open the order again.
Be more active using Alert(), Print() with Logic!
Please advise us, gentlemen!
Imagine the situation: a stop is triggered, because of the triggering of the N-th condition. But after a couple of candlesticks, the N-th condition has fallen away. With the help of which function you can open the deal again after the N-th condition falls out. That is, you need to determine that triggered a stop some number of bars ago, and because the N-th condition fell off, re-open the trade!
if programmatically - when opening an order - there is a magik and a comment - you can encrypt the information about which condition the order is opened, in the magik or comment
in general, the stop is not triggered by a condition, but when the price reaches a price level - this order can be closed by a condition
How do I know if an order was opened but closed because of condition N? Because there are many conditions, and the presence of condition N does not guarantee that the order is closed.
That is, I need to know that the order has been placed, but has closed n candles ago due to triggering of condition N. And if condition N has disappeared and no more than n candles have passed since the order was closed, I need to open the order again.
You do not want to complicate things too much? After all, the order could have been closed if condition X had been present, although condition N may also have been present.
The solution depends a lot on your position management logic, for example to find orders which have been closed no later than n candlesticks and to check the event N at the moment the order is closed and at the current moment.
How do I make this cycle "easier"? It takes a very long time to count.
the same conditionmaybe something I don't understand, but here:
the same condition - at all times CountH equals CountLmaybe I didn't get it right, but here:
No, If the price is higher than Bid, then CountH? If lower, then CountL
it is possible to speed up the calculation:
reduce i<=6000
It is possible to speed up the calculation:
a) Reduce i<=6000
b) Calculate only at the beginning of the bar
a) Reduce the number of i can be done, but is not desirable. This is how it takes bars for the year.
b) At the beginning of a bar... This is probably an option. Works on M15.
However, in any case, it counts almost 2 seconds.