Download MetaTrader 5

Why does this indicator not work?

To add comments, please log in or register
Brian Lillard
1086
Brian Lillard  

All it does is paint white squares.

whroeder1
16102
whroeder1  
     if( MT(0,i)==MT(1,i) && 
         MT(0,i+1)==EMPTY_VALUE && MT(1,i-1)>0 )
It's a repainting indicator, useless for trading.
Naguisa Unada
121
Naguisa Unada  
 //if( MT(0,i)==MT(1,i) &&  
 if ( MT( 0 ,shift)==MT( 1 ,shift) && 

Fixed " i " in parentheses of lines 95 - 96, 103 - 104, 112, 119 to " shift ".

The part of  " i - 1" pointed out by whroeder1 is probably "shift + 1".

Brian Lillard
1086
Brian Lillard  
int start()
  {
  int    counted_bars=IndicatorCounted(),i,shift;
   i=(Bars-counted_bars)-1;
   for(shift=i;shift>=0;shift--)
     {
     
     
     //-- SELL(NEW SIGNAL)
     if( MT(0,i)==MT(1,i) &&
         MT(0,i+1)==EMPTY_VALUE && MT(1,i+1)>0 )
      {
      Pair1Up[shift] = EMPTY_VALUE;  
      Pair1Down[shift] = 22;
      }
      
     //-- BUY(NEW SIGNAL)
     if( MT(0,i)==MT(1,i) &&
         MT(0,i+1)>0 && MT(1,i+1)==EMPTY_VALUE )
      {
      Pair1Up[shift] = 22;  
      Pair1Down[shift] = EMPTY_VALUE;
      }
     
     
     // SELL
     if( MT(0,i)==EMPTY_VALUE && MT(1,i)>0 )
      {
      Pair1Up[shift] = EMPTY_VALUE;  
      Pair1Down[shift] = 22;
      }
      
     // BUY
     if( MT(0,i)>0 && MT(1,i)==EMPTY_VALUE )
      {
      Pair1Up[shift] = 22;  
      Pair1Down[shift] = EMPTY_VALUE;
      }
     
     
     }
   return(0);
  }
Why doesn't this work?
Naguisa Unada
121
Naguisa Unada  
 int start()
  {
   int     counted_bars= IndicatorCounted (),i,shift;
   i=( Bars -counted_bars)- 1 ;
   for (shift=i;shift>= 0 ;shift--)
     {
     
     
     //-- SELL(NEW SIGNAL) 
     //if( MT(0,i)==MT(1,i) && MT(0,i+1)==EMPTY_VALUE && MT(1,i+1)>0 ) 
     if ( MT( 0 ,shift)==MT( 1 ,shift) && MT( 0 ,i+ 1 )== EMPTY_VALUE && MT( 1 ,i+ 1 )> 0 )
      { 
      Pair1Up[shift] = EMPTY_VALUE ;  
      Pair1Down[shift] = 22 ; 
      }
      
     //-- BUY(NEW SIGNAL) 
     //if( MT(0,i)==MT(1,i) && MT(0,i+1)>0 && MT(1,i+1)==EMPTY_VALUE ) 
     if ( MT( 0 ,shift)==MT( 1 ,shift) && MT( 0 ,i+ 1 )> 0 && MT( 1 ,i+ 1 )== EMPTY_VALUE )
      { 
      Pair1Up[shift] = 22 ;  
      Pair1Down[shift] = EMPTY_VALUE ; 
      }
     
     
     // SELL 
     //if( MT(0,i)==EMPTY_VALUE && MT(1,i)>0 ) 
     if ( MT( 0 ,shift)== EMPTY_VALUE && MT( 1 ,shift)> 0 )
      { 
      Pair1Up[shift] = EMPTY_VALUE ;  
      Pair1Down[shift] = 22 ; 
      }
      
     // BUY 
     //if( MT(0,i)>0 && MT(1,i)==EMPTY_VALUE ) 
     if ( MT( 0 ,shift)> 0 && MT( 1 ,shift)== EMPTY_VALUE )
      { 
      Pair1Up[shift] = 22 ;  
      Pair1Down[shift] = EMPTY_VALUE ; 
      }
     
     
     }
   return ( 0 );
  }

You have to fix " i " to "shift", because the variable is "shift" in the "for loop" which you wrote.

To add comments, please log in or register