Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 810
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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() {