Topic: Help needed with some code closing trades for the day
So basically I just need a little help with some code.
What I have done is created functions to close all Longs/Shorts when a % of profit/loss is made. For example if all longs open profit = 2% of account balance close all longs and visa versa.
However what I am struggling with is getting the Portfolio EA to not open any more longs for the trading session (session defined by EA Studio force session close function).
The idea is to close all orders in a particular direction to either take a % loss or gain but leave the orders in the other direction open.
What keeps happening with my code is I can get the EA to close all the trades when the % profit or loss is reached but then for the rest of the session it will open another trade in the direction then close it instantly. So instead of not allowing any trades in that particular direction to open until the new session starts they will open and instantly close and I’m just paying the spread/commission.
Could some please help with this?
Sorry I do not have the code on me at the moment.