Download MetaTrader 5

Ichimoku cloud breakout EA

To add comments, please log in or register
Eranar
6
Eranar  

Hello everyone,

I have the following issue with my EA.

I intend for it to Open trades when the price breaks out of the Kumo cloud while being above the Kijun for buys and below for sells,

//indicator setup
   double tenkanSen= iIchimoku(NULL,PERIOD_CURRENT,Tenkan,Kijun,Senkou,MODE_TENKANSEN,0);
   double KijunSen = iIchimoku(NULL,PERIOD_CURRENT,Tenkan,Kijun,Senkou,MODE_KIJUNSEN,0);
   double SenkouSpanA = iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_SENKOUSPANA, 1);
   double SenkouSpanB = iIchimoku(NULL, 0, Tenkan, Kijun, Senkou, MODE_SENKOUSPANB, 1); 
   
   double KumoTop= MathMax(SenkouSpanA, SenkouSpanB);
   double KumoBottom = MathMin (SenkouSpanA, SenkouSpanB);

//Entry Signals

   if((Open[1]<KumoTop && Close[1]>KumoTop)&&(Close[1]>KijunSen))
    BuySignal=true;
   else BuySignal=false;
   if((Open [1]>KumoBottom && Close[1]<KumoBottom) &&  (Close[1]<KijunSen))
    SellSignal=true;
   else SellSignal=false;

with Exits based on Price close crossing below the Kijun for buy orders and above the Kijun for sell orders.

  //Kijun close 
   if(OrderType()==OP_BUY)
   {
    if(Close[1]<KijunSen)
     {ClosePrevious();
     }
   }

   if(OrderType()==OP_SELL)
   {
    if(Close[1]>KijunSen)
     {ClosePrevious();
     }
   }

The EA will make entries as I intend however it will exit it's positions way too late.


Whereas if I set the entry conditions to merely have the price be outside the kumo instead of crossing out of the Kumo, the Kijun exits work without fault.


//Entry Signals


   if((Close[1]>KumoTop) &&  (Close[1]>KijunSen))
    BuySignal=true;
   else BuySignal=false;
   if((Close[1]<KumoBottom) &&  (Close[1]<KijunSen))
   SellSignal=true;
   else SellSignal=false;


I hope anyone here could tell me how slightly altering entry requirements could affect the exits so badly, and how I could rewrite price kumo breakout entry better to avoid having it affect the exits.

Any help would be greatly appreciated.

To add comments, please log in or register