If the time the order was opened -- that's OrderOpenTime() -- is greater than or equal to Time[0] don't do another trade.
supertrade:
...
...
Is there a way to save a variable ~outside~ of the program where it doesnt get updated every run? Although thats seems too ad-hoc.
HOW DO I TELL AN EA (OR CUSTOM INDICATOR) NOT TO PERFORM A GIVEN ACTION FOR THE REMAINDER OF A CANDLE IF IT HAS ALREADY BEEN PERFORMED DURING ANY GIVEN TICK OF THAT CANDLE?????
Thank you to anyone who helps me with this!
Have a read up on static variables...https://book.mql4.com/variables/types and for new bar actions... try this function.
hth
V
// Identify new bars bool Fun_New_Bar() { static datetime New_Time = 0; bool New_Bar = false; if (New_Time!= Time[0]) { New_Time = Time[0]; New_Bar = true; } return(New_Bar); }
static datetime Time0; bool New_Bar = Time0 < Time[0]; Time0 = Time[0]; if (New_Bar){...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hi,
Im trying to put together my first expert advisor but ran into an issue that I cant seem to get around. Like most EA's I have my entries and exits based on some criteria, the problem Im having is that criteria may become TRUE several ticks into a candle and remain true for the duration of that candle..since the EA essentially refreshes at every tick, the criteria is deemed TRUE per tick, and it ends up placing an order for every tick as well!
I can alleviate the issue by setting a condition that 'no orders may be opened if there are already orders open' but thats ultimately not what I want to do. I want to have the option of opening additional orders to those already open or pending.
I tried using the Volume[] array to "save" the tick index at the opening of the very first order following the entry criteria being been met, then set a condition that would prevent the opening of new orders if the Volume[] for the same candle exceed the original saved tick volume. But as I've discovered this pointless because the original Volume[] gets refreshed along with the entire program at each tick so they are by design always the same!
Is there a way to save a variable ~outside~ of the program where it doesnt get updated every run? Although thats seems too ad-hoc.
HOW DO I TELL AN EA (OR CUSTOM INDICATOR) NOT TO PERFORM A GIVEN ACTION FOR THE REMAINDER OF A CANDLE IF IT HAS ALREADY BEEN PERFORMED DURING ANY GIVEN TICK OF THAT CANDLE?????
Thank you to anyone who helps me with this!