Arrow sometimes not appear

 
Hello all,
I really need help to fix a small but inconveniant probleme on a indicator modified by me (original not mine).

I filter AC oscillator with :
- RSI 50 level

and
- Parabolic SAR

My problem is if (in uptrend for exampl) the ac oscillator is already green, there is no arrow when the RSI cross the 50 level, and it wait the ac oscillator to become red and green again, then it draws an arrow.

Can someone kindly fix it very please ?
I really need this to be fixed.

Regards.


//+------------------------------------------------------------------+
//|                                             AcceleratorAlert.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                     Alerts & Arrows added by cja |
//|  Thanks to mladen for the Arrow code & IgorAD for the Alert code |
//|                               Modified and Enhanced by MADAFOREX |
//+------------------------------------------------------------------+
#property  copyright "MADAFOREX"
#property  link      "http://www.madaforex.tk/"
//---- indicator settings
#property indicator_chart_window
//#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Black
#property  indicator_color2  DodgerBlue
#property  indicator_color3  Red
#property  indicator_width2  2
#property  indicator_width3  2


extern bool   PopUP_Alert_ON  = false;
extern bool   SoundAlert_ON   = false;
extern string SoundFile       ="alert.wav";

extern string PSARsetup = "Parabolic SAR";
extern double Step = 0.02;//was .01
extern double Maximum = 0.2;
extern int Precision = 7;

extern bool   Show_Arrows     = true;
extern int    Arrow_Size      = 0;
extern int    ArrowUP         = 233;//241
extern int    ArrowDN         = 234;//242
extern int    Arrow_Shift     = 1;

extern string RSIsetup = "RSI";
extern int RSIPeriod = 14;

//---- indicator buffers
double     ExtBuffer0[];
double     ExtBuffer1[];
double     ExtBuffer2[];
double     ExtBuffer3[];
double     ExtBuffer4[];

bool       UpTrend=false, DownTrend=false;

int      maxArrows;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(5);
//---- drawing settings
   SetIndexStyle(0,DRAW_NONE);
   //SetIndexStyle(1,DRAW_HISTOGRAM);
   //SetIndexStyle(2,DRAW_HISTOGRAM);
   IndicatorDigits(Digits+2);
   //SetIndexDrawBegin(0,38);
   //SetIndexDrawBegin(1,38);
   //SetIndexDrawBegin(2,38);
//---- 4 indicator buffers mapping
   SetIndexBuffer(0,ExtBuffer0);
   SetIndexBuffer(1,ExtBuffer1);
   SetIndexBuffer(2,ExtBuffer2);
   SetIndexBuffer(3,ExtBuffer3);
   SetIndexBuffer(4,ExtBuffer4);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("AC");
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
//---- initialization done
   return(0);
  }
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
     //ObjectsDeleteAll(0,OBJ_ARROW);
    // ObjectDelete("ACC_BUY");
    // ObjectDelete("ACC-SELL");
       DeleteArrows();
     
//----
   return(0);
  }  
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator                               |
//+------------------------------------------------------------------+
int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
   
    double prev,current;
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   //---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      ExtBuffer3[i]=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,i)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,i);
   //---- signal line counted in the 2-nd additional buffer
   for(i=0; i<limit; i++)
      ExtBuffer4[i]=iMAOnArray(ExtBuffer3,Bars,5,0,MODE_SMA,i);
  
   //---- dispatch values between 2 buffers
   bool up=true;
   for(i=limit-1; i>=0; i--)
     {
    
      current=ExtBuffer3[i]-ExtBuffer4[i];
      prev=ExtBuffer3[i+1]-ExtBuffer4[i+1];
      if(current>prev) up=true;
      if(current<prev) up=false;
      if(!up)
        {
         ExtBuffer2[i]=current;
         ExtBuffer1[i]=0.0;
        }
      else
        {
         ExtBuffer1[i]=current;
         ExtBuffer2[i]=0.0;
        }
       ExtBuffer0[i]=current;
     }
         
   if (Show_Arrows)
    for (i=0; i<WindowBarsPerChart() ;i++)//Bars for showing total history of signals
         {
          //---- includes rsi & Psar & distance arrow
          double rsi  = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
          double sar = NormalizeDouble(iSAR(Symbol(),0,Step,Maximum,i),Precision);
          
         
            if( ExtBuffer3[i]-ExtBuffer4[i]<ExtBuffer3[i+1]-ExtBuffer4[i+1] 
            && ExtBuffer3[i+1]-ExtBuffer4[i+1]>ExtBuffer3[i+2]-ExtBuffer4[i+2] 
            && Volume[0]>1
            && rsi<=50//
            && sar >= iHigh(Symbol(),0,i)
            && !UpTrend) DrawArrow(i,"baisse")
            
            ;
            
            if ( ExtBuffer3[i]-ExtBuffer4[i]>ExtBuffer3[i+1]-ExtBuffer4[i+1] 
            && ExtBuffer3[i+1]-ExtBuffer4[i+1]<ExtBuffer3[i+2]-ExtBuffer4[i+2]
            && Volume[0]>1
            && rsi>=50//
            && sar <= iHigh(Symbol(),0,i)
            && !DownTrend)  DrawArrow(i,"hausse")
            
            ;
         }

    
   if ( current>prev && Volume[0]>1 && !UpTrend)
        {
        if ( PopUP_Alert_ON==true ) Alert(""+Symbol()+" M"+Period()+": ACC Signal for BUY &  "+DoubleToStr(Bid,Digits)+"");
        if(SoundAlert_ON==true)PlaySound(SoundFile); 
        UpTrend=true; DownTrend=false;
        } 
                  
        if ( current<prev && Volume[0]>1 && !DownTrend)
        {
        if ( PopUP_Alert_ON==true ) Alert(""+Symbol()+" M"+Period()+": ACC Signal for SELL &  "+DoubleToStr(Bid,Digits)+""); 
        if(SoundAlert_ON==true)PlaySound(SoundFile);
        DownTrend=true; UpTrend=false;
        } 

   //---- done
   return(0);
  }
  
  
void DrawArrow(int i,string type)//Arrow_Size
{
   double dist = iATR(NULL,0,20,i);
   maxArrows++;
      ObjectCreate("AC_ArrowALERT"+maxArrows,OBJ_ARROW,0,Time[i],0);
      if (type=="baisse")
         {
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_PRICE1,High[i]+((Arrow_Shift)*dist/2));
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_ARROWCODE,ArrowDN);
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_WIDTH,Arrow_Size);
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_COLOR,Red);
         }
      else
         {
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_PRICE1,Low[i]-((Arrow_Shift)*dist/2));
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_ARROWCODE,ArrowUP);
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_WIDTH,Arrow_Size);
            ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_COLOR,GreenYellow);
         }
}
void DeleteArrows()
{
   while(maxArrows>0) { ObjectDelete("AC_ArrowALERT"+maxArrows); maxArrows--; }
}



 
MadaForex: Can someone kindly fix it very please?
learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
 
i am learning to code.
I have done all the modification myself (rsi & psar filter + main window chart canceling the histogram view). That's why i request help to finish it as it's a mql community.

If someone want to help me to finish it. It's a very good tool, that can be used after.

Regards.
 
Hello again,
i decided to recode it all with my established kwnoledge.

I wonder you how i can use up and down trend on color change of the ac oscillator ?

I want to use this variable :

double ac  = iAC(NULL,0,0);

For example with the RSI i do this :
double rsi  = iRSI(NULL, 0, RSIPeriod, PRICE_CLOSE, i);
if (rsi>50) trend[i] =  1;

And I cannot find how to do it with "iAC" to use the "up" and "down" trend of the ac ascillator. (not the zero line, but the color change).

Could someone help me please ?


Regards.
 
Ok,I get it.
Sorry for the inconveniant from this post.

Regards.
Reason: