Test indicator doesn't work; no graphing or anything > need help

 

Hi,


This is a test indicator for me. I'm trying to make an indicator that graphs a horizontal line segment wherever there's two consecutive same lows/highs. Nothing seems to work actually. Corrections are fully appreciated.


The following is the full test code I have:



//+------------------------------------------------------------------+

//| asdf.m4q

//|

//|

//+------------------------------------------------------------------+

#property copyright "Test"

#property link "www.test.com"

//#property indicator_chart_window

//#property indicator_buffers 1

//#property indicator_color1 Red

//---- buffers

double ExtMapBuffer1[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexBuffer(0,ExtMapBuffer1);

//----

return(1);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{
ObjectsDeleteAll(OBJ_TREND);
//----

//----

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

//---- check for possible errors

if (counted_bars<0) return(-1);

//---- last counted bar will be recounted

if (counted_bars>0) counted_bars--;

int pos=Bars-counted_bars;



//---- main calculation loop

while(pos>=0)

{




if ( Low[pos] == Low[pos-1] ) {
   if(!ObjectCreate("lowLine", OBJ_TREND, 0, Time[pos-1], Low[pos], Time[pos+1], Low[pos] ) ) {
      Print("error: can't create text_object! code #",GetLastError());
      return(0);
      }
   ObjectSet("lowLine", OBJPROP_COLOR, Yellow);
   ObjectSet("lowLine", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("lowLine", OBJPROP_WIDTH, 2);
   ObjectSet("lowLine", OBJPROP_RAY, False);
  
}

if ( High[pos] == High[pos-1] ) {
   if(!ObjectCreate("highLine", OBJ_TREND, 0, Time[pos-1], High[pos], Time[pos+1], High[pos] ) ) {
      Print("error: can't create text_object! code #",GetLastError());
      return(0);
      }
   ObjectSet("highLine", OBJPROP_COLOR, Yellow);
   ObjectSet("highLine", OBJPROP_STYLE, STYLE_SOLID);
   ObjectSet("highLine", OBJPROP_WIDTH, 2);
   ObjectSet("highLine", OBJPROP_RAY, False);
}



pos--;

}

//----

return(0);

}
Reason: