Hi Programmers!

I'm working on an Amibroker indicator. I realised an interesting problem with 
the view of chart displaying.

When I'm scrolling the chart, sometimes my indicator lines stop working and 
shows different values.

I show you three picture:

http://kepfeltoltes.hu/thumb/090706/chart_0_www.kepfeltoltes.hu_.jpg

http://kepfeltoltes.hu/thumb/090706/chart_1_www.kepfeltoltes.hu_.jpg

http://kepfeltoltes.hu/thumb/090706/chart_2_www.kepfeltoltes.hu_.jpg

You can see, the cursor is always on the same bar: 2008.03.03. 16:00:00

The first and the third picture shows the chart displayed well. But on the 
second one, all of my lines goes to wrong.

I don't the cause of this occurrence or how could I avoid it.

Do you have any idea? What can I do? Why doesn't display my indicator well?


Thank you in advance!


Relative


_____________________________

I use the Amibroker version 5.20 rc1 Professional Edition.

And here is the code of my indicator:


_N(Title = StrFormat("\\c16[ Powered by www.MRHOW.eu © 2009 ] - \\c16{{NAME}} 
-\\c42 {{INTERVAL}}\\c16 \\c10{{DATE}}\\c16 Open \\c47%g\\c16, Hi \\c25%g\\c16, 
Lo \\c34%g\\c16, Close \\c55%g (%.1f%%)\\c16, ", O, H, L, C, SelectedValue( 
ROC( C, 1 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | 
ParamStyle("Style") | GetPriceStyle() | styleClipMinMax ); 

track = 1500    ;

Col0 = 55 ;
Col1 = 29 ;
Col2 = 32 ;

Col7 = 55 ;
Col8 = 29 ;
Col9 = 32 ;

Level1 = 1 ;

LO[0] = 0 ;
SO[0] = 0 ;

the_high = H[0] ;
the_low = L[0] ;

reg_h[0] = 0 ;
reg_l[0] = 0 ;

trend[0] = 0 ;
trend_color = 33 ;
exit[0] = 0 ;

trade_color = 33 ;

priceatbuy[0] = 0 ;
trade[0] = 0 ;

entrance_high[0] = 0 ;
entrance_low[0] = 0 ;
entrance_close[0] = 0 ;

f1 = C ;
f2 = C ;
f3 = C ;

i=0;

//==============================================================================================================
// X Y Variables 
==============================================================================================================

x=0;
y=0;

xEma2 = EMA(x,2)/EMA(y,2) ;
xEma3 = EMA(x,3)/EMA(y,3) ;
xEma4 = EMA(x,4)/EMA(y,4) ;
xEma5 = EMA(x,5)/EMA(y,5) ;
xEma6 = EMA(x,6)/EMA(y,6) ;
xEma7 = EMA(x,7)/EMA(y,7) ;
xEma8 = EMA(x,8)/EMA(y,8) ;
xEma9 = EMA(x,9)/EMA(y,8) ;
xEma10 = EMA(x,10)/EMA(y,10) ;

yEma2 = EMA(y,2)/EMA(x,2) ;
yEma3 = EMA(y,3)/EMA(x,3) ;
yEma4 = EMA(y,4)/EMA(x,4) ;
yEma5 = EMA(y,5)/EMA(x,5) ;
yEma6 = EMA(y,6)/EMA(x,6) ;
yEma7 = EMA(y,7)/EMA(x,7) ;
yEma8 = EMA(y,8)/EMA(x,8) ;
yEma9 = EMA(y,9)/EMA(x,8) ;
yEma10 = EMA(y,10)/EMA(x,10) ;

// end of X Y Variables 
==============================================================================================================
//==============================================================================================================


// 
==============================================================================================================
// FUNCTIONS

function FIBOS() {
        if ( trend[i] == 2 ) {
                f1[i] = the_low[i] + ( the_high[i] - the_low[i] ) * 0.236 ;
                f2[i] = the_low[i] + ( the_high[i] - the_low[i] ) * 0.382 ;
                f3[i] = the_low[i] + ( the_high[i] - the_low[i] ) * 0.618 ;
        }
        if ( trend[i] == 1 ) {
                f1[i] = the_high[i] - ( the_high[i] - the_low[i] ) * 0.236 ;
                f2[i] = the_high[i] - ( the_high[i] - the_low[i] ) * 0.382 ;
                f3[i] = the_high[i] - ( the_high[i] - the_low[i] ) * 0.618 ;
        }
}

// end of FUNCTIONS
// 
==============================================================================================================


// 
==============================================================================================================
// LOOP INTERACTION

for( i = 0; i < BarCount; i++ ) {

        // 
====================================================================================
        // SIGNS
        if ( i > 150 ) {

                // --------------------------------------
                // continuity
                if ( i > 2 ) {
                        trend_color[i] = trend_color[i-1] ;
                        trade_color[i] = trade_color[i-1] ;
                        reg_h[i] = reg_h[i-1] ;
                        reg_l[i] = reg_l[i-1] ;
                        the_high[i] = the_high[i-1] ;
                        the_low[i] = the_low[i-1] ;
                        exit[i] = exit[i-1] ;
                        trend[i] = trend[i-1] ;
                        entrance_high[i] = entrance_high[i-1] ;
                        entrance_low[i] = entrance_low[i-1] ;
                        entrance_close[i] = entrance_close[i-1] ;
                        tracker[i] = the_high[i] - the_low[i] > track ;
                }
                // --------------------------------------


                // --------------------------------------
                // check the new High level
                if ( H[i] > the_high[i] ) {
                        the_high[i] = H[i] ;
                        reg_h[i] = i ;
                }
                // check the new Low level
                if ( L[i] < the_low[i] ) {
                        the_low[i] = L[i] ;
                        reg_l[i] = i ;
                }
                // --------------------------------------


                // --------------------------------------
                FIBOS();
                // --------------------------------------

                // --------------------------------------
                // First OUT
                if ( exit[i] == 0 ) {
                        if ( tracker[i-1] ) {
                                // Exit to Long
                                if (    C[i-2] < the_low[i-2] + ( the_high[i-2] 
- the_low[i-2] ) * 0.382 AND
                                                C[i-1] > the_low[i-1] + ( 
the_high[i-1] - the_low[i-1] ) * 0.382 ) {
                                        // Fibo 1 Crossed
                                        the_high[i] = H[i-1] ;
                                        reg_h[i] = i-1 ;
                                        exit[i] = 1 ;
                                        trend_color[i] = Col0 ;
                                        entrance_high[i] = f3[i] ;
                                        entrance_low[i] = the_low[i] ;
                                        entrance_close[i] = f2[i] ;
                                }
                                // Exit to Short
                                if (    C[i-2] > the_low[i-2] + ( the_high[i-2] 
- the_low[i-2] ) * 0.382 AND
                                                C[i-1] < the_low[i-1] + ( 
the_high[i-1] - the_low[i-1] ) * 0.382 ) {
                                        the_low[i] = L[i-1] ;
                                        reg_l[i] = i-1 ;
                                        exit[i] = 2 ;
                                        trend_color[i] = Col0 ;
                                        entrance_high[i] = the_high[i] ;
                                        entrance_low[i] = f3[i] ;
                                        entrance_close[i] = f2[i] ;
                                }
                        }
                }
                // --------------------------------------


                // --------------------------------------
                // Entrance
                if ( trend[i] == 0 AND exit[i-1] != 0 ) {
                        // Previous was Short
                        if ( exit[i] == 1 ) {
                                if ( tracker[i] ) {
                                        // Enter to Long
                                        if ( C[i-1] > entrance_high[i-1] ) {
                                                trend[i] = 1 ;
                                                trend_color[i] = Col1 ;
                                                trade_color[i] = Col8 ;
                                                FIBOS();
                                        }
                                }
                        }
                        // Previous was Short
                        if ( exit[i] == 1 ) {
                                // Enter to Short
                                if ( C[i-1] < entrance_low[i-1] ) {
                                        trend[i] = 2 ;
                                        trend_color[i] = Col2 ;
                                        trade_color[i] = Col9 ;
                                        FIBOS();
                                }
                        }
                        // Previous was Long
                        if ( exit[i] == 2 ) {
                                // Enter to Long
                                if ( C[i-1] > entrance_high[i-1] ) {
                                        trend[i] = 1 ;
                                        trend_color[i] = Col1 ;
                                        trade_color[i] = Col8 ;
                                        FIBOS();
                                }
                        }
                        // Previous was Long
                        if ( exit[i] == 2 ) {
                                if ( tracker[i] ) {
                                        // Enter to Short
                                        if ( C[i-1] < entrance_low[i-1] ) {
                                                trend[i] = 2 ;
                                                trend_color[i] = Col2 ;
                                                trade_color[i] = Col9 ;
                                                FIBOS();
                                        }
                                }

                        }
                }
                // --------------------------------------


                // --------------------------------------
                // Close section
                if ( tracker[i] ) {
                        // Close the Long trend
                        if ( trend[i] == 1 ) {
                                if ( C[i-1] < f1[i-1] ) {
                                        trend[i] = 0 ;
                                        trend_color[i] = Col0 ;
                                        exit[i] = 2 ;
                                        entrance_high[i] = the_high[i] ;
                                        entrance_low[i] = f3[i] ;
                                        entrance_close[i] = f2[i] ;
                                        the_low[i] = L[i] ;
                                        reg_l[0] = i ;
                                        FIBOS();
                                }
                        }
                        // Close the Short trend
                        if ( trend[i] == 2 ) {
                                if ( C[i-1] > f1[i-1] ) {
                                        trend[i] = 0 ;
                                        trend_color[i] = Col0 ;
                                        exit[i] = 1 ;
                                        entrance_high[i] = f3[i] ;
                                        entrance_low[i] = the_low[i] ;
                                        entrance_close[i] = f2[i] ;
                                        the_high[i] = H[i] ;
                                        reg_h[0] = i ;
                                        FIBOS();
                                }
                        }
                }
                // --------------------------------------


                // --------------------------------------
                // Close 2 section

                // Close the Long trend
                if ( trade_color[i] == Col8 ) {
                        if ( C[i-1] < entrance_close[i-1] ) {
                                trade_color[i] = Col7 ;
                        }
                }
                // Close the Short trend
                if ( trade_color[i] == Col9 ) {
                        if ( C[i-1] > entrance_close[i-1] ) {
                                trade_color[i] = Col7 ;
                        }
                }
                // --------------------------------------

        }

        the_i[i] = i ;
}
// END OF LOOP INTERACTION
// 
==============================================================================================================


// 
==============================================================================================================
// Print

printf("-----------\n") ;
printf("I: %g\n" , the_i ) ;
printf("Trend: %g\n" , trend ) ;

printf(" | Exit Way: %g" , exit ) ;

printf("-----------\n") ;
printf("The High: %g" , the_high ) ;
printf(" | Reg: %g" , reg_h ) ;
printf(" (%g" , the_i - reg_h ) ;
printf(")\n" ) ;
printf("The low: %g" , the_low ) ;
printf(" | Reg: %g" , reg_l ) ;
printf(" (%g" , the_i - reg_l ) ;
printf(")\n" ) ;

printf("H-L: %g" , the_high ) ;
printf(" - %g" , the_low ) ;
printf(" = %g" , the_high - the_low ) ;
printf(" (%g" , track ) ;
printf(")\n" ) ;

printf("Entrace High: %g\n" , entrance_high ) ;
printf("Entrace Low: %g\n" , entrance_low ) ;
printf("Entrace Close: %g\n" , entrance_close ) ;


printf("O: %g\n" , O ) ;
printf("C: %g\n" , C ) ;
printf("H: %g\n" , H ) ;
printf("L: %g\n" , L ) ;


//==============================================================================================================
// Plot

Plot(the_high,"TH",colorRed);
Plot(the_low,"TL",colorBlue);
Plot(f1,"F1",colorLime);
Plot(f2,"F2",colorPink);
Plot(f3,"F3",colorYellow);

Plot(Level1 ,"line_1",trend_color,32+2048+32768, Minvalue=-5, Maxvalue=20 );
Plot(0 ,"Trade",trade_color,2048+32768, Minvalue=-5, Maxvalue=20 );


Reply via email to