//#property indicator_separate_window #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 LawnGreen #property indicator_color2 Red // Bring in ErrorDescription(), among others. #include //---- input parameters // None // Variables color UpColor = Cyan ; color DnColor = Red ; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { int err ; bool status ; ObjectsDeleteAll(); // remove all objects from the chart. return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int idx, first_idx, jdx, limit, counter, loop, BN, err ; bool c1, c2, c3 ; int Counted_Bars = IndicatorCounted(); // General error checks if(Counted_Bars < 0) return(-1); //---- force re-processing of latest bar (just in case ...) if(Counted_Bars > 0) Counted_Bars--; first_idx = Bars - Counted_Bars - 1 ; // Index of the first uncounted - we will start processing here, decrementing with each pass idx = first_idx ; err = GetLastError(); if( err == 4002 ){ Print( " Time[idx]: " + TimeToStr(Time[idx], TIME_DATE|TIME_SECONDS) + " idx: " + DoubleToStr(idx, 0) + " Before loop error(", err, "): ", ErrorDescription(err) ); return(-1) ; } // This loop runs from a higher numbered index down thru 0. // In terms of the OHLC arrays, this is from past to future. // while(idx >= 0){ // Loop for uncounted bars //Print( " Time[idx]: " + TimeToStr(Time[idx], TIME_DATE|TIME_SECONDS) + " idx: " + DoubleToStr(idx, 0) + " Loop top" ); BN = Bars - idx ; // BarNumber with low count at left of chart if( Open[idx] < Close[idx] ){ // bool ObjectCreate( string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0) ObjectCreate("" + idx, OBJ_TEXT, 0, Time[idx], Low[idx] ); ObjectSetText("" + idx, "U", 10, "Arial", UpColor); } if( Open[idx] > Close[idx] ){ // bool ObjectCreate( string name, int type, int window, datetime time1, double price1, datetime time2=0, double price2=0, datetime time3=0, double price3=0) ObjectCreate("" + idx, OBJ_TEXT, 0, Time[idx], High[idx] ); ObjectSetText("" + idx, "D", 10, "Arial", DnColor); } idx--; } // end of: while(idx >= 0) WindowRedraw() ; return(0); }