Hello Progster
I use Market Profile formula in 15 minutes chart. My database is a future in 1 minute. I run AB v: 5.17 My Intraday settings are : Day session RTH Start 08:00 End 21:59 and Night session ETH Start 22:00 End 07:59 Sometimes an extra tick appears at 22:00 (not every day) and it opens a new bar that stay as a dash (open = close and no wick) As Market Profile formula calculates three days based on the start of a new day, this extra quotation open a new day at the wrong moment and has no higher, no lower and the indicator's draw is wrong for the last day. Mainly the open is wrong, it finds the 22:00 quotation and not the 08:00 quotation to display the real open value. Higher and lower are wrong too for specific day. I was on a wrong track with the day() calculation as I misunderstood the array. Fortunately Steve show me a clever way to see what appends in the array. Something that should be taugh in the best AB schools. Thanks to this array plotting, I discoverd this dash at 22:00. As I am writing this post I discovered that Filtering is "Show day and night session only". I am surprised I thought my setting was "Show day session". I never change it intentionally, the software does it for me. Anyway this could be the cause of my problem. I set it again to "Show day session". The extra dash (22:00) should be removed. This unwilling change of setting could be caused by one of this two things maybe. I recently build a continuous contract with merge functionnality, maybe this is the trigger that modified my Intraday Settings. I keep an eye on it. The second cause is a new year contracts series for 2009. But I think the continous contract has made the change. I see nothing else pertinent. Best regards Thank you for your blog in CodeForTraders.com http://codefortraders.com/phpBB3/viewforum.php?f=60&sid=a614f0e0a95c3e3fd2f412b5c93b8931 The formula I use is this one : // I modified this line, I think it was wrong : I changed BarIndex()-1, it was BarIndex() // endi = LastValue(IIf(q == 1, BarCount, ValueWhen(NewDay, BarIndex()-1, q-1)));//BarIndex() // Market profile SetChartOptions( 3, chartShowDates ); GfxSetOverlayMode( mode = 1 ); nn = StrToNum( ParamList( "Days", "1|2|3", 2 ) ); box = Param( "step", 10, 1, 100, 1 ) * TickSize; NewDay = Day() != Ref( Day(), 1 ); DH = LastValue( HighestSince( NewDay, H, nn ) ); DL = LastValue( LowestSince( NewDay, L, nn ) ); Range = DH - DL; steps = ceil( Range / box ); // linage height = Status( "pxheight" ) - 50; // width of the profile (indention overhand 30 from below 20 pixels) boxheight = LastValue( height / steps ); // size of the box width = ( Status( "pxwidth" ) - 110 ) / 3; // offset of the profiles bars = Highest( BarsSince( NewDay ) ); _TRACE( "bars = " + bars ); ColorStep = LastValue( 185 / bars ); // L = IIf( C > Ref( C, -1 ) AND L > Ref( C, - 1 ) AND NOT NewDay, Ref( C, -1 ), L ); H = IIf( C < Ref( C, -1 ) AND H < Ref( C, - 1 ) AND NOT NewDay, Ref( C, -1 ), H ); function GetDayPrice( fild, shift ) { DayPrice = LastValue( TimeFrameGetPrice( fild, inDaily, -shift ) ); return DayPrice; } function pixlev( price ) { result = 30 + ( DH - price ) / box * boxheight; return result; } procedure PlotProfile( DH, DL, begini, endi, disp ) { m = 0; for ( j = DH; j > DL; j = j - box ) { n = 0; for ( i = begini; i < endi; i++ ) { if ( H[i] >= j AND L[i] <= j ) { GfxSelectPen( colorBlack, 1, 0 ); GfxSelectSolidBrush( ColorHSB( ( i - begini )*ColorStep, 255, 255 ) ); GfxRectangle( disp + n*boxheight, 30 + m*boxheight, disp + ( n + 1 )*boxheight, 30 + ( m + 1 )*boxheight ); n++; } } m++; } } procedure PlotLine( x1, y1, x2, y2, Color ) { GfxSelectPen( Color, 1, 0 ); GfxPolyline( x1, y1, x2, y2 ); } procedure PlotRect( x1, y1, x2, y2, Color ) { GfxSelectPen( Color, 0, 5 ); GfxSelectSolidBrush( Color ); GfxRectangle( x1, y1, x2, y2 ); } procedure PlotPrice( Text, FontName, FontSize, Color, x, y, yAlign, xAlign ) { GfxSetBkMode( 1 ); GfxSetTextColor( Color ); GfxSetTextAlign( xAlign | yAlign ); GfxSelectFont( FontName, FontSize, 600 ); // dont work orientation GfxTextOut( Text, x, y ); } for ( q = nn; q > 0; q-- ) { begini = LastValue( ValueWhen( NewDay, BarIndex(), q ) ); endi = LastValue( IIf( q == 1, BarCount, ValueWhen( NewDay, BarIndex() - 1, q - 1 ) ) );//was BarIndex() _TRACE( "begini = " + begini ); _TRACE( "endi = " + endi ); _TRACE( "BarCount= " + BarCount ); _TRACE( "BarIndex= " + BarIndex() ); PlotRect( 50 + width*( nn - q ), pixlev( GetDayPrice( "H", q - 1 ) ), // day range 50 + width*( nn - q + 1 ), pixlev( GetDayPrice( "L", q - 1 ) ), colorLightYellow ); PlotRect( 50 + width*( nn - q ), pixlev( GetDayPrice( "O", q - 1 ) ), // open-close range 50 + width*( nn - q + 1 ), pixlev( GetDayPrice( "C", q - 1 ) ), IIf( GetDayPrice( "O", q - 1 ) > GetDayPrice( "C", q - 1 ), ColorHSB( 15, 40, 255 ), ColorHSB( 80, 40, 255 ) ) ); PlotLine( 50 + width*( nn - q ), pixlev( GetDayPrice( "C", q - 1 ) ), // close line 50 + width*( nn - q + 1 ), pixlev( GetDayPrice( "C", q - 1 ) ), IIf( GetDayPrice( "O", q - 1 ) > GetDayPrice( "C", q - 1 ), colorRed, colorGreen ) ); PlotProfile( DH, DL, begini, endi, 50 + width*( nn - q ) ); PlotLine( 50 + width*( nn - q ), height + 40, 50 + width*( nn - q ), 0, colorBlack ); // vertical line PlotPrice( " close " + NumToStr( GetDayPrice( "C", q - 1 ) ) + " ", "Tahoma", 10, // plot close price IIf( GetDayPrice( "O", q - 1 ) > GetDayPrice( "C", q - 1 ), colorRed, colorGreen ), 50 + width*( nn - q + 1 ), pixlev( GetDayPrice( "C", q - 1 ) ), IIf( GetDayPrice( "O", q - 1 ) > GetDayPrice( "C", q - 1 ), 0, 8 ), 2 ); PlotPrice( " open " + NumToStr( GetDayPrice( "O", q - 1 ) ) + " ", "Tahoma", 10, // plot open price colorBlack, 50 + width*( nn - q + 1 ), pixlev( GetDayPrice( "O", q - 1 ) ), IIf( GetDayPrice( "O", q - 1 ) > GetDayPrice( "C", q - 1 ), 8, 0 ), 2 ); _TRACE( "q = " + q ); _TRACE( "daypriceOpen = " + NumToStr( GetDayPrice( "O", q - 1 ) ) ); PlotPrice( " " + NumToStr( GetDayPrice( "H", q - 1 ) ), "Tahoma", 10, // plot high price colorBlack, 50 + width*( nn - q ), pixlev( GetDayPrice( "H", q - 1 ) ), 8, 0 ); PlotPrice( " " + NumToStr( GetDayPrice( "L", q - 1 ) ), "Tahoma", 10, // plot low price colorBlack, 50 + width*( nn - q ), pixlev( GetDayPrice( "L", q - 1 ) ), 0, 0 ); } progster01 a écrit : > > --- In [email protected] <mailto:amibroker%40yahoogroups.com>, > reinsley <reins...@...> wrote: > > > > An extra quotation produced a wrong result. Some days, a tick gives > > an extra minute. > > Hi. Could you elaborate that a little bit? > > Since the original code "seems like" it should work as intended, I'd > like to understand the circumstances under which it does not. > > If you'd be so kind as to address: > > What is the timeframe of the chart you are observing? > > What is the "extra minute"? > > What is the significance of the "extra minute" in this context? > > Thanks! > >
