Hi,
I was wondering if anyone can help me with a problem I’m having with my EA.
When it sending an order, it’s generating “Ordersend error: 130”, everytime.
It seems it’s either related to incorrect stop levels, or something to do with normalizing double variables.
My stop levels tp & sl are correct as far as I can tell when printing out their values, and I tried using the NormalizeDouble function, but it’s still not working. Here’s a snippet of code:
if (AccountBalance() < 1000) {Lots = 1; } // calculate Lot Size based on balance
else if(AccountBalance()<2000) {Lots = 2;}
else {Lots=NormalizeDouble(MathRound(AccountBalance()+1000)/1000,Digits);}
TakeProfit1= NormalizeDouble( MathRound ( (AccountBalance()*0.04) /Lots),Digits); // calculate stop levels based on % of balance
StopLoss = NormalizeDouble(MathRound( (AccountBalance()*0.02) /Lots),Digits);
if(StopLoss <= 10){StopLoss = 11;}
if (buysignal)
{
ticket=OrderSend(Symbol(),OP_BUY,(Lots/10),Ask,3,Ask-StopLoss*Point,Ask + TakeProfit1 * Point,“Sweet Stoch EA”,0,0,Green);
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());
}
else Print("Error opening BUY order : ",GetLastError());
return(0); // end long order entry
}
These are the variable values:
EURJPY,M15: Lots = 0.2 Stop Loss = 11 Point = 0.01 Ask = 158.18 Take Profit = 20 Stop Loss Value = 158.07
I’ve tried searching the net but to no avail for a solution yet.
Thanks