Hello .
You have to anticipate such events .
Keep a log of what is occuring and the EA state (strategy state) and maintain it across Inits.
What needs to be done with the positions the EA was monitoring will be decided every time its loaded .
so, basically i would need to:
- load some sort of ini, if exists, on OnInit()
- create a log in OnTrade() when a trade is created
- update or remove in OnTick()
would that be possible to integrate with the EA base that MQL5 supplies, or do i need to rethink/adapt the existing structure to do it?
edit:
another way would be to read the existing active trades and add them to the list of trades of the EA after initialization of indicators/trail/money
i am digging, but don't seem to find where/how the EA stores that info
so, basically i would need to:
- load some sort of ini, if exists, on OnInit()
- create a log in OnTrade() when a trade is created
- update or remove in OnTick()
would that be possible to integrate with the EA base that MQL5 supplies, or do i need to rethink/adapt the existing structure to do it?
It depends .
What are we discussing actually ?
It kinda looks you are looking for a trade manager and there is no EA yet
You will have a structure/class with the state of the system (if your ea exists and its a strategy) ,because its key it picks up from where it left off.
And then another trade class ,for which you will have an array .
From there you load and save in your own custom binary file.
for now i am just fiddling with the possibilities
the objective is to - eventually - develop a trading robot
i know that i can manage the trades with my trail-stop routine even between sessions
but for the system to be functional it should be able to send a close signal to existing orders, not just keep the trail-stop, as it does if there is no EA interruption
my main problem is how to integrate those trades back into the EA, in case of power failure or other interruption that might happen
for now at least, i am using the expert advisor routines to manage the indicator signals, and realize the trades
i know that eventually i will have to create a new way of doing things, but for my knowledge atm it is a good base to start
- www.mql5.com
for now i am just fiddling with the possibilities
the objective is to - eventually - develop a trading robot
i know that i can manage the trades with my trail-stop routine even between sessions
but for the system to be functional it should be able to send a close signal to existing orders, not just keep the trail-stop, as it does if there is no EA interruption
my main problem is how to integrate those trades back into the EA, in case of power failure or other interruption that might happen
for now at least, i am using the expert advisor routines to manage the indicator signals, and realize the trades
i know that eventually i will have to create a new way of doing things, but for my knowledge atm it is a good base to start
Correct . You keep a log of tickets and everything else you need for each trade .
Upon loading of that list ,lets say after a power failure ,you loop through your orders-positions and check what still open .
Theres a hint you are using netting mode on mt5 and not hedging mode .I cannot advise on the netting aspect as each symbol has one position but in hedging , what i do, is check to see
if the order is still open first .If not open i remove it ,if open it goes through the usual system checks based on what i had stored up to the power failure.
seems that i was creating a storm in a glass of water
for what i understood so far from analyzing the header files, the expert cycles all trades, using those that have the same magic number as the expert
for a local use that is great, and saves me a lot of headaches
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi there
i have been wondering for a while, and didn't got any luck in answering by myself
situation:
does the EA automatically recover the deal/position and keeps track of it, or it needs to be inserted somehow in the EA deals/positions list?
when working on deals, one could always close them, with positions would not be that easy