formula result doesn't match the graphical plot view..

 
Greetings,

Something doesn't match between the formula result to the graphical plot view.
I run an EA routine that notes me when there is a cross event at each of my indicators.

The problem is that sometimes (not always), I get the crossing signal from the EA's formula but looking at the graph, doesn't show crossing.

In the attached picture, you see the M15 RSI plot (RSI[7] - Bright yellow and RSI[21] - Brown).
there was a cross signal ('M15 RSI cross'), but on the graph it doesn't show.

 

 


All RSI are calculated for "close" prices.

Is there any explanation?  solution?

 /*-----------------+
  | cross signal    |
  +-----------------+
  This routine announce on cross event on one of th emakor indicators */

int cross ()
 {
//  Print ("entring cross()");
  int timeframe[5], candle_life[5], i, n=1, result;
  double position[3], iWPR7, iWPR21, ADxPlus, ADxMinus;
  string sound_file, word;

  timeframe[0]=5;
  timeframe[1]=15;
  timeframe[2]=30;
  timeframe[3]=60;
  timeframe[4]=240;

  for (i = 0; i <=4; i++) // for the candle timeframes
      {
      if  (i==0) sound_file="bird_chirping_little.wav";
      if  (i==1) sound_file="bird_chirp_simple.wav";
      if  (i==2) sound_file="bird_chirping_medium.wav";
      if  (i==3) sound_file="bird_crow.wav";
      if  (i==4) sound_file="bird_hawk.wav";

       candle_life[i]=100*(MathMod(TimeCurrent(),(timeframe[i]*60))/(timeframe[i]*60)); //each candle starts again when = 100
       position[0]=iWPR(Symbol(),timeframe[i],7,0)-iWPR(Symbol(),timeframe[i],21,0); // current Williams position (positive or negative)
       position[n]=iWPR(Symbol(),timeframe[i],7,n)-iWPR(Symbol(),timeframe[i],21,n);
       if (position[n]!=0&&position[0]!=0)
          {
           position[0]=position[0]/MathAbs(position[0]);
           position[n]=position[n]/MathAbs(position[n]);
           if (position[0]>position[n]) word="upwards";  else word="downwards";
           if (position[0]!=position[n]&&candle_life[i]<=2&&candle_life[timeframe[0]]<=2) Sound(sound_file,StringConcatenate("Williams crossing ",word," on ",timeframe[i]),timeframe[i]);
          }

       position[0]=iRSI(Symbol(),timeframe[i],7,PRICE_CLOSE,0)-iRSI(Symbol(),timeframe[i],21,PRICE_CLOSE,0); // current RSI position (positive or negative)
       position[n]=iRSI(Symbol(),timeframe[i],7,PRICE_CLOSE,n)-iRSI(Symbol(),timeframe[i],21,PRICE_CLOSE,n);
       if (position[n]!=0&&position[0]!=0)
          {
           position[0]=position[0]/MathAbs(position[0]);
           position[n]=position[n]/MathAbs(position[n]);
           if (position[0]>position[n]) word="upwards";  else word="downwards";
           if (position[0]!=position[n]&&candle_life[i]<=2&&candle_life[timeframe[0]]<=2) Sound(sound_file,StringConcatenate("RSI crossing ",word," on ",timeframe[i]),timeframe[i]);
          }

       position[0]=iCCI(Symbol(),timeframe[i],9,PRICE_CLOSE,0)-iCCI(Symbol(),timeframe[i],50,PRICE_CLOSE,0); // current CCI position (positive or negative)
       position[n]=iCCI(Symbol(),timeframe[i],9,PRICE_CLOSE,n)-iCCI(Symbol(),timeframe[i],50,PRICE_CLOSE,n);
       if (position[n]!=0&&position[0]!=0)
          {
           position[0]=position[0]/MathAbs(position[0]);
           position[n]=position[n]/MathAbs(position[n]);
           if (position[0]>position[n]) word="upwards";  else word="downwards";
//           if (position[0]!=position[n]&&candle_life[i]<=2&&candle_life[timeframe[0]]<=2) Sound(sound_file,StringConcatenate("CCI crossing ",word," on ",timeframe[i]),timeframe[i]);
           if (position[0]!=position[n]&&candle_life[i]<=2&&candle_life[timeframe[0]]<=2)
              {
               Print ("[",timeframe[i],"];  CCI9(0)=",iCCI(Symbol(),timeframe[i],9,PRICE_CLOSE,0),";  CCI50(0)=",iCCI(Symbol(),timeframe[i],50,PRICE_CLOSE,0),";   
               CCI9(1)=",iCCI(Symbol(),timeframe[i],9,PRICE_CLOSE,1),";  CCI50(1)=",iCCI(Symbol(),timeframe[i],50,PRICE_CLOSE,1));
               Sound(sound_file,StringConcatenate("CCI crossing ",word," on ",timeframe[i]),timeframe[i]);
              }

          }

       position[0]=iADX (Symbol(), timeframe[i], 9, PRICE_CLOSE, MODE_PLUSDI, 0)-iADX (Symbol(), timeframe[i], 9, PRICE_CLOSE, MODE_MINUSDI, 0); // current ADX position (positive or negative)
       position[n]=iADX (Symbol(), timeframe[i], 9, PRICE_CLOSE, MODE_PLUSDI, n)-iADX (Symbol(), timeframe[i], 9, PRICE_CLOSE, MODE_MINUSDI, n);
       if (position[n]!=0&&position[0]!=0)
          {
           position[0]=position[0]/MathAbs(position[0]);
           position[n]=position[n]/MathAbs(position[n]);
           if (position[0]>position[n]) word="upwards";  else word="downwards";
           if (position[0]!=position[n]&&candle_life[i]<=2&&candle_life[timeframe[0]]<=2) Sound(sound_file,StringConcatenate("ADX crossing ",word," on ",timeframe[i]),timeframe[i]);
          }
      } // end of the 'for i = 0'..

//  Print ("exiting cross()");

return (result);
 }

 

 

Thank you,

James
 
JJF:
Greetings,

Something doesn't match between the formula result to the graphical plot view.
I run am EA routine that notes me when there is a cross event at each of my indicators.

The problem is that sometimes (not always), I get the crossing signal from the EA's formula but looking at the graph, doesn't show crossing.

In the attached picture, you see the M15 RSI plot (RSI[7] - Bright yellow and RSI[21] - Brown).
there was a cross signal ('M15 RSI cross'), but on the graph it doesn't show.


Isn't this going to "re-paint" ?  as it's bar 0 ?

position[0] = iRSI(Symbol(),timeframe[i],7,PRICE_CLOSE, 0) - iRSI(Symbol(),timeframe[i],21,PRICE_CLOSE, 0);
 
JJF:

All RSI are calculated for "close" prices.

By the way,  Close[0]  is == Bid
 
RaptorUK:
By the way,  Close[0]  is == Bid


Read Here:  https://docs.mql4.com/constants/prices 

 James 

 
JJF:


Read Here:  https://docs.mql4.com/constants/prices 

 James 

Yes,  but that doesn't alter the fact that Bar 0 is never closed,  during it's life it is forming and while that is happening Close[0] == Bid
 
RaptorUK:
Yes,  but that doesn't alter the fact that Bar 0 is never closed,  during it's life it is forming and while that is happening Close[0] == Bid


I don't understand what is the connection between close[0]==Bid and my question.
I am asking about RSI formula , not other things.

I'll appreciate if you'll be more clear in your responds.


James
 
RaptorUK:

Isn't this going to "re-paint" ?  as it's bar 0 ?

position[0] = iRSI(Symbol(),timeframe[i],7,PRICE_CLOSE, 0) - iRSI(Symbol(),timeframe[i],21,PRICE_CLOSE, 0);

 

Isn't that clear enough ?  what is your opinion ?  will it re-paint or not ?
Reason: