remjte: Gentlemen! Can you tell me the code that will stop testing an EA when there is not enough margin to open a position? Thank you!
If AccountFreeMarginCheck() is less than a certain value (e.g. less than 50% of AccountFreeMargin) - exit trading function, test ends quickly because empty loops are almost unloadable.
evillive: If AccountFreeMarginCheck() is less than a certain value (for example, less than 50% of AccountFreeMargin) - exit from trade function, test quickly ends, because empty loops are almost not loading.
Honestly, still very green, found this piece of code can you tell me how to correct
Honestly, still very green, found this piece of code can you tell me how to correct
if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= 0.0) return (-1); if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2); return (l_lots_4);
You needn't edit it, it will do just fine. Unless you just replace the variables with your own names.
But if we need less risk, then if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= AccountFreeMargin()*0.5) return (-1); - in this case, if 50% or less free money remains after the position is opened with the specified lot, then return (-1)
Can you give me a hint, please? I need to write a part of code where the second order in the list will be selected and then deleted (pending). Returns 4051 when OrderSelect(1, SELECT_BY_POS, MODE_TRADES)
remjte: Gentlemen! Can you tell me the code that will stop testing an EA when there is not enough margin to open a position? Thank you!
// проверяем доступность свободных средствif(AccountFreeMarginCheck(Symbol(),OP_BUY,OpenLot)<=0 || GetLastError()==134)
{
Print("It is impossible to open the order Buy, not enough money.");
return(0);
}
// проверяем доступность свободных средствif(AccountFreeMarginCheck(Symbol(),OP_SELL,OpenLot)<=0 || GetLastError()==134)
{
Print("It is impossible to open the order Sell, not enough money.");
return(0);
}
Pomid: Can you give me a hint, please? I need to write a part of code where the second order in the list will be selected and then deleted (pending). Returns 4051 when OrderSelect(1, SELECT_BY_POS, MODE_TRADES)
The order count starts from 0. Try, OrderSelect(0, SELECT_BY_POS, MODE_TRADES)
Here we need to place pending orders and calculate their prices relative to the previous bar close price. BUYSTOP is placed, while SELLSTOP returns error 130. Is there an error in this code? Or in another function.
or how to get rid of this error
Gentlemen! Can you tell me the code that will stop testing an EA when there is not enough margin to open a position?
Thank you!
If AccountFreeMarginCheck() is less than a certain value (for example, less than 50% of AccountFreeMargin) - exit from trade function, test quickly ends, because empty loops are almost not loading.
Honestly, still very green, found this piece of code can you tell me how to correct
if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= 0.0) return (-1);
if(GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
return (l_lots_4);
Let me write in a simpler way: how to write this condition - Do not modify an open order until a new candlestick appears
Honestly, still very green, found this piece of code can you tell me how to correct
if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= 0.0) return (-1);
if (GetLastError() == 134/* NOT_ENOUGH_MONEY */) return (-2);
return (l_lots_4);
You needn't edit it, it will do just fine. Unless you just replace the variables with your own names.
But if we need less risk, then if (AccountFreeMarginCheck(Symbol(), a_cmd_0, l_lots_4) <= AccountFreeMargin()*0.5) return (-1); - in this case, if 50% or less free money remains after the position is opened with the specified lot, then return (-1)
Gentlemen! Can you tell me the code that will stop testing an EA when there is not enough margin to open a position?
Thank you!
Can you give me a hint, please? I need to write a part of code where the second order in the list will be selected and then deleted (pending). Returns 4051 when OrderSelect(1, SELECT_BY_POS, MODE_TRADES)
Here we need to place pending orders and calculate their prices relative to the previous bar close price. BUYSTOP is placed, while SELLSTOP returns error 130. Is there an error in this code? Or in another function.
void SetOrders() {