Hi, I found that with mt4 if you have a bot and its attached say to AUDUSD on M15 is there any way in code to see if the same bot/version is attached on the same pair but different period?
For example: If I have 5 open charts m5, m15, m30, m60, m240, I can run my bot over all of them but because there could be different buy/sell signals for the different periods the bot opens a buy at m5 but m60 it sees a sell and the orders get cancelled out.
I don't want to have 5 magic numbers, is there a way in mql to have OrderPeriod() saved away with the current order? Then it would simply be a check:
if(Period()==OrderPeriod()) then yes this order is from bot instance that got executed originally on this chart, and can distinguish from other period orders, we need this feature.
im not sure if that would work, i need something more like a runtime command to say IsEAattached() then I loop over the periods and if more than one i just uninitialize and it will keep only one running EA.
I'm building a Period hedge EA to have my bot run over the same pair but different periods and I want each EA instance to manage the pair & period orders not just the pair.
there is no problem apart from the wrong name of the var :(
I thought we would have to setup 5 different numbers, but what you proposed is short and sweet and works, i used + instead of *
But an OrderPeriod() would be good, that way we can check back in the history whether our bot had more profits on 15m vs 240m etc...
that field is small in size and plus using it for specific messages.
What we need in the product is OrderOpenPeriod() and OrderClosePeriod() as inbuilt functions.
As for the task itself, it's much more proper to handle open positions and new signals without any dependency from originating timeframe. If multiple instances of EA is running on different timeframes they can analyse direction of the current position (if any) and handle new signals from any timeframe appropriately (close position, add lots, etc).
BTW, the comment field is large enough to handle an additional symbol. Even if the comment is already used for other purposes it's not a problem to combine more info there and parse it if needed.