Non-traded my EA :(

 
Sample imageHi friends
I gathered the following EA from other codes. But he is not trading. What could be the reason. Can you help me.

Thank you

extern int stoploss     = 150;
extern int takeprofit   = 500;
extern int slippage     = 10;

extern int Magic = 4166;

extern double Lot = 0.01;

void OnTick()
{
   for (int i=0; i<OrdersTotal(); i++)
      if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         if (OrderSymbol()==Symbol() && Magic==OrderMagicNumber()) return;
   double mts  = iCustom(NULL,0,"Market/MA TREND SG",False,True,False,5,30,500,0); //MA Trend SG
   double ma30 = iMA(NULL,0,30,0,MODE_SMMA,PRICE_CLOSE,1); //SMA:Basit, EMA:Exponential, SMMA:Smoothed, LWMA:Linear Weighted
   double ma50 = iMA(NULL,0,50,0,MODE_SMMA,PRICE_CLOSE,1); //SMA:Basit, EMA:Exponential, SMMA:Smoothed, LWMA:Linear Weighted
   double SL=0,TP=0;
  
   if (mts > ma30 && mts < ma50)
   {
      if (takeprofit!=0) TP  = NormalizeDouble(Ask + takeprofit*Point,Digits);
      if (stoploss!=0)   SL  = NormalizeDouble(Ask - stoploss*  Point,Digits);     
      
      if (OrderSend(Symbol(),OP_BUY, Lot,NormalizeDouble(Ask,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError());
   }
  
   if (mts < ma30 && mts > ma50)
   {
      if (takeprofit!=0) TP = NormalizeDouble(Bid - takeprofit*Point,Digits);
      if (stoploss!=0)   SL = NormalizeDouble(Bid + stoploss*  Point,Digits);            
      
      if (OrderSend(Symbol(),OP_SELL,Lot,NormalizeDouble(Bid,Digits),slippage,SL,TP,NULL,Magic)==-1) Print(GetLastError());
   }
}


 
if (mts < ma30 && mts > ma30)

because mts cannot be smaller than ma30 and bigger than ma30 at the same time.

 
Don't paste code
Play video
Please edit your post.
For large amounts of code, attach it.
 
Meng Yin Teoh:

because mts cannot be smaller than ma30 and bigger than ma30 at the same time.


Super attention :)
Thank you
He has been out of sight a couple of times when the condition has changed.

Corrected. But he did not take action.

 if (mts < ma30 && mts > ma50)

 
Nuri Doğanay: But he did not take action
Print out your variables, and find out why.