Hello, I am trying to code EA and I dont know how to set SL that i would be below MA.
I tried to do this
StopLoss = MA22 - 100*Point;
but it gives me order send error 130, the same eror iw it is 1000Point or 10000Point
How to set SL in this way ?
extern double TakeProfit = 100;
extern double Lots = 0.01;
double StopLoss;
double MA1, MA2, MA3, MA4, STOCH1, STOCH2, Low1, Low2, Low3, High1, High2, High3;
int start()
{
double MA1 = iMA(NULL,0,50,0,MODE_EMA,PRICE_HIGH,0);
double MA2 = iMA(NULL,0,50,0,MODE_EMA,PRICE_LOW,0);
double MA22 = iMA(NULL,0,50,0,MODE_EMA,PRICE_LOW,1);
double MA3 = iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,0);
double MA4 = iMA(NULL,0,100,0,MODE_EMA,PRICE_CLOSE,0);
double STOCH1 = iStochastic(NULL,0,14,3,3,MODE_EMA,1,MODE_MAIN,0);
double STOCH2 = iStochastic(NULL,0,14,3,3,MODE_EMA,1,MODE_MAIN,1);
double Low1 = iLow(NULL, 0, 1);
double Low2 = iLow(NULL, 0, 2);
double Low3 = iLow(NULL, 0, 3);
double High1 = iHigh(NULL, 0, 1);
double High2 = iHigh(NULL, 0, 2);
double High3 = iHigh(NULL, 0, 3);
int ticket;
//----buy
if ((OrdersTotal()<1) && (MA1&&MA2&&MA3>MA4) && (Low1<MA2 || Low2<MA2 || Low3<MA3) && (STOCH1<30 && STOCH2>30) )
{
StopLoss = MA2 - 100Point;
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLossPoint,Ask+TakeProfitPoint,“MA sample”,16384,0,Green);
}
//----sell
/ if ((HA1>HA2) && (OrdersTotal()<1) && (MA<HA1) && (MACD<0))
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLossPoint,Bid-TakeProfitPoint,“MA sample”,16384,0,Red);
}
//–*/
return(0);
}