automate custom indicator into EA

 

I tried to automate it but I got wrong entries even I detect the right numbers of each trend of the indicator .

any idea about wrong entries ? or how to detect the signals ?

this is a part of my code 

 if( redd!=EMPTY_VALUE && orderscnt (OP_SELL)==0){
        if(TakeProfite!=0){TP=Bid-TakeProfite*point;}else TP=0;
        if(StopLoss!=0){SL=Bid+StopLoss*point;}else SL=0; 
        double sell= OrderSend(NULL,OP_SELL,LotSize,Bid,5*Q,SL,TP,NULL,MagicNumber,0,clrRed);
        if(Email)SendMail(Symbol(),"New Sell Order @ "+(string)Ask);
        if(PopUp)Alert(Symbol()+" New Sell Order @ "+(string)Ask);
        if(Mobile)SendNotification(Symbol()+" New Sell Order @ "+(string)Ask);
        NewBar=false;
        }
        
        
        
    if(greenn!=EMPTY_VALUE&& NewBar && orderscnt (OP_BUY)==0 ){
        if(TakeProfite!=0){TP=Ask+TakeProfite*point;}else TP=0;
        if(StopLoss!=0){SL=Ask-StopLoss*point;}else SL=0;
        double buy=OrderSend(NULL,OP_BUY,LotSize,Ask,5*Q,SL,TP,NULL,MagicNumber,0,clrBlue);
        if(Email)SendMail(Symbol(),"New Buy Order @ "+(string)Ask);
        if(PopUp)Alert(Symbol()+" New Buy Order @ "+(string)Ask);
        if(Mobile)SendNotification(Symbol()+" New Buy Order @ "+(string)Ask);
        NewBar=false;
        }
 
  1. Post all relevant code. Your question is about indicator data, yet your posted code contains no such code.

  2. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)
    Just get the value(s) of the indicator(s) into the EA (using iCustom) and do what you want with it.
    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 programming forum
 
i need help in writing icustom function for this indicator for sell and buy signal
i need help in writing icustom function for this indicator for sell and buy signal
  • 2019.07.08
  • www.mql5.com
Need help in writing icustom function for this indicator to produce sell and buy signal...