Dear Popov,
I am sorry to bother you. I am a programmer as well, but I am having weird output when I tried to modify the trade logic inside the hedged EAs exported from portfolio.
For example, I tried to add these logic inside the "OpenPosition" function, I wrap the "if(IsTradeContextFree())" with:
1. if(takeProfit < 0)
2. if(takeProfit == 0)
3. if(takeProfit > 0)
All three of them doesn't affect anything when I update the EA and re-run the backtest. I also tried to modify the validation to be inline validation using &&, eg. "if(IsTradeContextFree() && takeProfit > 0)" as well as == 0 and < 0. But modifying it this way made the EA don't trade at all.
So I am a bit confused about the logic, and if it is possible for you, could I request you to give me a snippet code that I can append to my hedged mq4? Or maybe modify the mq4 that I attach here, and I can follow it for other mq4 I exported.
I am trying to add a validation before the EAs can open trade. And I think there is also logic to modify trades, although I don't know when the modification logic will be called.
But in the end, what I need is all the trades that the EA make, need to satisfy these rules:
1. The price between open price and take profit price must be above or equal X value (or -X if sell order).
2. The spread value when trying to open the trade must be between X to Y value.
UPDATE
Nvm Popov, I have got it done. Thanks
Post's attachmentsm15 12.mq4 89.67 kb, 1 downloads since 2021-10-08
You don't have the permssions to download the attachments of this post.