Hello,
Try with
TicketNumber=OrderSend( Symbol(), OP_BUY, LotSize, Ask, 3, NormalizeDouble(Ask-(StopLoss*pips),Digits), NormalizeDouble(Ask+(TakeProfit*pips),Digits), CommentName, MAGIC,0,Green);
thank you very much for the help, but does not work.
the strange thing is that just opens the position...
thanks
thank you very much for the help, but does not work.
the strange thing is that just opens the position...
thanks
Hello,
Try with
if the value "StopLoss" or "TakeProfit" is changed by a function before being called by OrderSend, it may send an error "Invalid S/L or T/P" if there is a lot of decimal
thanks for the help, the code is very simple, I'm just starting in the programming of mql.
double StopLoss=500; double TakeProfit=1000; double pips = 0.00001; void openPosition(){ int TicketNumber; if(IsNewCandle()){ if( AccountFreeMargin() > 0 ){ TicketNumber=OrderSend( Symbol(), OP_BUY, LotSize, Ask, 3, NormalizeDouble(Ask-(StopLoss*pips),Digits), NormalizeDouble(Ask+(TakeProfit*pips),Digits), CommentName, MAGIC,0,Green); if(TicketNumber==-1){logError("openPosition()", "Error opening BUY order SMA4 >= SMA9");} } } }
as data I'm working with micro lots and broker allows 50 points to put the stoploss
thanks for the help, the code is very simple, I'm just starting in the programming of mql.
as data I'm working with micro lots and broker allows 50 points to put the stoploss
Where do you get error 4059 from ? your code doesn't Print() it or output it to a log . . . why aren't you outputting the error number ?
if(TicketNumber==-1){logError("openPosition() Error opening BUY order SMA4 >= SMA9. Error # ", GetLastError() );}
thanks for the help, the code is very simple, I'm just starting in the programming of mql. [...]
sorry but my english is not good when i change this parameter works well
TicketNumber=OrderSend( Symbol(), OP_BUY, LotSize, Ask, slippage, 0, 0, CommentName, MAGIC,0,Green);
but if i change it, didnt work
double StopLoss=500; double TakeProfit=1000; double pips = 0.00001; double LotSize=0.01; void openPosition(){ int TicketNumber; if(IsNewCandle()){ if( AccountFreeMargin() > 0 ){ TicketNumber=OrderSend( Symbol(), OP_BUY, LotSize, Ask, 3, NormalizeDouble(Ask-(StopLoss*pips),Digits), NormalizeDouble(Ask+(TakeProfit*pips),Digits), CommentName, MAGIC,0,Green); if(TicketNumber==-1){logError("openPosition()", "Error opening BUY order SMA4 >= SMA9");} } } } void logError(string functionName, string msg, int errorCode = -1) { Print("ERROR: in " + functionName + "()"); Print("ERROR: " + msg ); int err = GetLastError(); if(errorCode != -1) err = errorCode; if(err != ERR_NO_ERROR) { Print("ERROR: code=" + err + " - " + ErrorDescription( err )); } }
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi, I have the problem...when i excute the EA. appear the error " ERROR: code=4059 - function is not allowed in testing mode"
i copy the code where I think the error must be here because if I put to 0, in the stoploss and takeprofit it works....any idea..??
thanks a lot