i rearranged the layout to maybe make it a bit more clearer.
the first line is the current open trade checker and it included previously closed trade. each direction is like an independent ea. so im just talking about sell now.
it checks if the signal for sell is valid and all valid is sell just like in the initial sell. the trade management is the tricky part. theres a recovery portion and hedge portion.
if it drop more then a certain pips and a buy occur it will just make another buy in the same direction and now it will start to look for break even.
the normal close flags are added just as a precaution and reset everything back to false.
when it has a sell and one of the signal changes direction to a buy, it will immediately open a hedge trade, until the all signals align for a sell again then it will close the hedge trade. and set the flag for hedge to true. when the hedge closes, it sets another hedgecloseflag to true so that it would start looking for a breakeven trade.
the recovery checks whether hedge is currently running through the flags. so it would not make a sell trade during hedge.
when hedge close, a variable will store the closed hedge amount. the purpose of doing this is because there are possibly 2 direction running so i cant check for number of closed trade before and it can close an uncertain amount of hedge before it will close at a breakeven in total. so the hedge will carry on as long as its has not breakeven.
speaking of this, oninit the global variable was checked to be empty or something and it output to EMPTY_VALUE to my variable and i cant find a way to solve this. for now a condition checks whether its more than a certain value but during live it keeps getting 21437... oninit. for now its working fine on strategy tester though. i think when it checks and there is no global variable it automatically assigned a EMPTY VALUE to that global variable.EMPTY_VALUE becomes a real value 214......... in this way.
so the same is done for the buy direction and they operate mostly independent of each other.
i uploaded another file id mt4-1788. it was using global variable to store the memory but if mt4 crashes the global variable are not saved. so another method i think of to saving is still to write to file lol. then oninit read the values from file.
thanks for the info.