Greetings,
Can the lot size of an EA be changed for the next trade while the EA is attached to a pair???
Have been testing an EA recently and all has been well. It's designed to stay in the market at all times, closing the current position and opening one in the opposite direction at the same time. This has been working fine, until ...
While the EA was attached to a pair, with a proper trade running, I have opened the EA properties to change the Lots for the next trade. This works fine for opening the new trade with the revised lots BUT the previous trade does NOT close ... This has happened a few times now.
Note that the changes were for Lot Size only ... nothing else. Magic number remains unchanged.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Here is the active part of the code for closing a long position.
//+-------------+
//| Close - Long
//+-------------+
bool TradeCloseLong=false;
if (SARD1>Bid && OrderFind(magicnolong)) TradeCloseLong=true;
if (TradeCloseLong && OrderFind(magicnolong)) OrderClose(glbOrderTicket,OrderLots(),Bid,3,CLR_NONE);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Any thoughts as to why changing the lot size and re-attaching an EA negates the close feature are appreciated.
Can the lot size of an EA be changed for the next trade while the EA is attached to a pair???
Have been testing an EA recently and all has been well. It's designed to stay in the market at all times, closing the current position and opening one in the opposite direction at the same time. This has been working fine, until ...
While the EA was attached to a pair, with a proper trade running, I have opened the EA properties to change the Lots for the next trade. This works fine for opening the new trade with the revised lots BUT the previous trade does NOT close ... This has happened a few times now.
Note that the changes were for Lot Size only ... nothing else. Magic number remains unchanged.
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Here is the active part of the code for closing a long position.
//+-------------+
//| Close - Long
//+-------------+
bool TradeCloseLong=false;
if (SARD1>Bid && OrderFind(magicnolong)) TradeCloseLong=true;
if (TradeCloseLong && OrderFind(magicnolong)) OrderClose(glbOrderTicket,OrderLots(),Bid,3,CLR_NONE);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Any thoughts as to why changing the lot size and re-attaching an EA negates the close feature are appreciated.