Open Signal

 

Good evening!
i was trying to fix a open signal inside my EA.

My Problem:
I would like the MyMovingAverage to be a open signal so that when MyMovingAverage<Bid (which will be my Uptrend) gives a Uptrend Signal and my EA executes Buy Trades only each time the conditions are met. But it currently only executes one Trade and waits for the next signal.

i have been trying to slove this without success, i appricate any help Thanks!

void OnTick()
  {
  //current chart, current period, 20 candels, no shift, simple, close price
   double SlowMovingAverage = iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,0);
 
 //current chart, current period, 20 candels, no shift, simple, close price
   double LastSlowMovingAverage =iMA(NULL,0,12,0,MODE_EMA,PRICE_CLOSE,1);
   
 
 
 //current chart, current period, 10 candels, no shift, simple, close price
   double FastMovingAverage =iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,0);
   
   
 //current chart, current period, 10 candels, no shift, simple, close price
   double LastFastMovingAverage =iMA(NULL,0,26,0,MODE_EMA,PRICE_CLOSE,1);
////////////////////////////////Code for crossover ema///////////////////////////////////////


//we claculate a string variable for the signal
string signal="";
///////FOR TREND////////////

//calculate EMA 50
double MyMovingAverage = iMA(NULL,0,50,20,MODE_EMA,PRICE_CLOSE,0);

//find out if the EMA is below the price
if (MyMovingAverage<Bid)

{
//set the signal to buy
signal="buy";
}
//if the EMA is above the Ask prive
if (MyMovingAverage>Ask)
{
//set sell signal
signal="sell";


  {




//define macd
double MACD=iMACD(_Symbol,_Period,12,26,9,PRICE_CLOSE,MODE_EMA,0);

if (MACD>0)
{
signal="sell mcd";

}

if (MACD<0)
{
signal="buy mcd";
}

  }   
  }
  if (MyMovingAverage<Bid)
     //Chart output for Sell Signal
     Comment ("UP");
     
  if (MyMovingAverage>Ask)
     //Chart output for Sell Signal
     Comment ("DOWN");


  
     if((MyMovingAverage<Bid)&&(MACD<0)&&  (LastFastMovingAverage > LastSlowMovingAverage)&&(FastMovingAverage < SlowMovingAverage)&&(OrdersTotal() <3))  
OrderSend(_Symbol,OP_BUY,0.01,Ask,3,0,Ask+150*_Point,NULL,0,0,Green);
   
   
   

return;
}