It is giving this Error 3 Invalid Trade Parameters but only if I use it on lower timeframes ( lower then M4). On M4 or Daily time is working fine. My SL and TP are calculated as per ATR value...also lotsize...maybe on lower timeframes lotsize cannot be calculated as per broker requirements ?!... I mean on my broker can only set lotsize multiple of 0.01...i
Please find my code below:
//Stoploss Calculationint stoploss;
if(StopLoss==0)
{
stoploss=(int)(ATR*ATRMultiplier/_Point);
}
else(stoploss=0);
int SL= StopLoss+stoploss;
//TakeProfit Calculationint takeprofit;
if(TakeProfit==0)
{
takeprofit=(int)(ATR/_Point);
}
else(takeprofit=0);
int TP=TakeProfit+takeprofit;
// Money managementdouble lotSize = FixedLotSize;
if(UseMoneyManagement == true)
{
lotSize = MoneyManagement(_Symbol,FixedLotSize,RiskPercent,SL);
}
//////// if condition are true => buy order
{
double PP=0;
if(ClosePips > 0)
{
PP = Ask + NormalizeDouble(at(1)*ClosePips,_Digits);
}
int ticket = OrderSend(_Symbol,OP_BUY,lotSize,Ask,Slippage,0,0,"Buy Order",MagicNumber,0,clrGreen);
GVSet("tp",PP);
ModifyStopsByPoints(ticket,SL,TP);
DrawVLine(PP);
}
// if sell conditions true => sell order
{
double PP=0;
if(ClosePips > 0)
{
PP = Bid - NormalizeDouble(at(1)*ClosePips,_Digits);
}
int ticket = OrderSend(_Symbol,OP_SELL,lotSize,Bid,Slippage,0,0,"Sell Order",MagicNumber,0,clrRed);
GVSet("tp",PP);
ModifyStopsByPoints(ticket,SL,TP);
DrawVLine(PP);
}
// // // // // //
// at(1) => atr value
//PP => first TAKE PROFit
//ClosePips => procent of first TP
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hello guys! I have an issue with my EA.
It is giving this Error 3 Invalid Trade Parameters but only if I use it on lower timeframes ( lower then M4). On M4 or Daily time is working fine. My SL and TP are calculated as per ATR value...also lotsize...maybe on lower timeframes lotsize cannot be calculated as per broker requirements ?!... I mean on my broker can only set lotsize multiple of 0.01...i
Please find my code below: