Left and right extension lines

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
arnie
Posts: 1581
Joined: 11 Feb 2009
Location: Portugal
Has thanked: 471 times
Been thanked: 508 times

Left and right extension lines

Postby arnie » 29 Dec 2012

For those that like to use the HL bars but would like to see the close tick on the last bar I assembled this study:

Code: Select all

// 25-12-2012
// Multicharts forum thread : http://www.multicharts.com/discussion/viewtopic.php?f=5&t=11658

input:
   RightTimeOffSet   (5),
   LeftExtension      (false),
   RightExtension   (true),
   LastPriceColor   (green),
   LastPriceSize      (0);

variables:
   intrabarpersist   lastPrice      (0),
            minute         (0),
            lastPriceRightTL   (-1),
            lastPrideLeftTL   (-1);
         
minute = TimeToMinutes(rightTimeOffSet)*60;
minute = SecondsToTime_s(minute);
lastPrice = close;

tl_delete(lastPriceRightTL);
tl_delete(lastPrideLeftTL);

if RightExtension = true then begin
   lastPriceRightTL= tl_new_s(date, time_s + minute, lastPrice , date + 1, time_s, lastPrice ); 
      tl_setcolor(lastPriceRightTL, lastPriceColor);
      tl_setsize(lastPriceRightTL, lastPriceSize);
      tl_setextright(lastPriceRightTL, true);
end
else begin
   lastPriceRightTL= tl_new_s(date, time_s + minute, lastPrice , date, time_s, lastPrice ); 
      tl_setcolor(lastPriceRightTL, lastPriceColor);
      tl_setsize(lastPriceRightTL, lastPriceSize);
end;   

if LeftExtension = true then begin
   lastPrideLeftTL= tl_new_s(date[1], time_s[1], lastPrice , date, time_s, lastPrice ); 
      tl_setcolor(lastPrideLeftTL, lastPriceColor);
      tl_setsize(lastPrideLeftTL, lastPriceSize);
      tl_setextleft(lastPrideLeftTL, true);
end;   


Image
Attachments
last price line.png
last price line.png (26.61 KiB) Viewed 808 times

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 279 times

Re: Left and right extension lines

Postby MAtricks » 11 Feb 2014

Great job. This might be a bit faster:

Code: Select all

//ShowText to False to speed it up a bit
//Format the indicator once its on the chart and set it to HIDDEN
//Make sure the indicator is set to UPDATE ON EACH TICK

inputs:
   ShowPriceLine( True ),
   LineColor( DarkGray ),
   LineStyle( Tool_Dashed3 ),        //Tool_Solid, Tool_Dotted, Tool_Dashed, Tool_Dashed2, Tool_Dashed3
   ShowText( True ),         
   TextColor( RGB(255,104,32) ),  //RGB(xxx,xxx,xxx) or Color Name eg: Red
   TextSize( 14 ),   
   TextShiftUp( 2 ) ;                //Plot Price Text this amount of ticks up from Close price

variables:
   TL_ID( 0 ),
   int NumDecimals( 0 ),
   Text_ID( 0 ) ;

   if Category = 12 then
     NumDecimals = Log( PriceScale ) / Log( 10 ) - 1
   else
      NumDecimals = Log( PriceScale ) / Log( 10 ) ;
   
   if CurrentBar = 1 and ShowPriceLine then begin
      TL_ID = TL_New( D, T, C, D, T, C ) ; 
      TL_SetColor( TL_ID, LineColor ) ; 
      TL_SetStyle( TL_ID, LineStyle ) ; 
      TL_SetSize( TL_ID, 0 ) ; 
      TL_SetExtRight( TL_ID, True ) ; 
      TL_SetExtLeft( TL_ID, True ) ;
      TL_SetColor( TL_ID, LineColor ) ;
           Text_ID = Text_New( D, T, C, NumToStr( C, NumDecimals ) ) ;
   end ;
 
      TL_SetEnd( TL_ID, D, T, C ); 
      TL_SetBegin( TL_ID, D, T, C );
   
   if ShowText then begin
      Text_SetLocation( Text_ID, D, T, C+ TextShiftUp ) ;
      Text_SetColor( Text_ID, TextColor ) ;
      Text_SetSize( Text_ID, TextSize ) ;
      Text_SetString( Text_ID, Spaces( 0 ) + NumToStr( C, NumDecimals ) ) ;
      Text_SetStyle( Text_ID, 0, 1 ) ;
   end ;
   


Image
Attachments
PriceLine.png
PriceLine.png (26.13 KiB) Viewed 897 times


Return to “User Contributed Studies and Indicator Library”