[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trendline Help...



PureBytes Links

Trading Reference Links

Hello All,
As requested here is the entire code. Sorry for the redundancy.
 
John- I hope this helps.....Thanks
 
JTraDer421
 
Inputs: 
  StandardColor(blue),
  FirstDate(LastCalcDate), NumDays(3),
  ExtLeft (FALSE) , ExtRight(FALSE) ,
  iniTime (0800), endTime (currenttime+15),
  PriceLine1( 0 ) , window1(1) ,
  PriceLine2( 0 ) , window2(1) ,
  PriceLine3( 0 ) , window3( 1 ) , 
  PriceLine4( 0 ) , window4( 1 ) , 
  PriceLine5( 0 ) , window5(1) , 
  PriceLine6(0) , window6(1) , 
  PriceLine7(0) , window7(1) , 
  PriceLine8(0) , window8(1) , 
  PriceLine9(0) , window9(1) , 
  PriceLine10(0) , window10(1) ;
 
var:
  ii(-1),
 BeginDate(CalcDate(FirstDate,-NumDays+1)),
 EndDate(FirstDate);
 
var:
    pl1  (  1 ), {pl1 = PriceLine1}
    pl2  (  2 ),
    pl3  (  3 ),
    pl4  (  4 ),
    pl5  (  5 ),
    pl6  (  6 ),
    pl7  (  7 ),
    pl8  (  8 ),
    pl9  (  9 ),
    pl10 ( 10 ),
 wh1 (11 ), {wh = Window High}
 wh2 (12 ),
 wh3 (13 ),
 wh4 (14 ),
 wh5 (15 ),
 wh6 (16 ),
 wh7 (17 ),
 wh8 (18 ),
 wh9 (19 ),
 wh10(20 ),
 wl1 (21 ), {wl = Window Low}
 wl2 (22 ),
 wl3 (23 ),
 wl4 (24 ),
 wl5 (25 ),
 wl6 (26 ),
 wl7 (27 ),
 wl8 ( 28),
 wl9 ( 29),
 wl10( 30);
    
Array:
    LineID   [ 30 ](-1), 
    SRValue  [ 30 ](-1), 
    TextID   [ 30 ](-1), 
    TextLabel[ 30 ](""); 
 
If CurrentBar = 1 then Begin  {Priceline and Window Calculations} 
   TextLabel[ pl1   ] = NumToStr(Priceline1,2);
   TextLabel[ pl2   ] = NumToStr(Priceline2,2);
   TextLabel[ pl3   ] = NumToStr(Priceline3,2);
   TextLabel[ pl4   ] = NumToStr(Priceline4,2);
   TextLabel[ pl5   ] = NumToStr(Priceline5,2);
   TextLabel[ pl6   ] = NumToStr(Priceline6,2);
   TextLabel[ pl7   ] = NumToStr(Priceline7,2);
   TextLabel[ pl8   ] = NumToStr(Priceline8,2);
   TextLabel[ pl9   ] = NumToStr(Priceline9,2);
   TextLabel[ pl10  ] = NumToStr(Priceline10,2);
   TextLabel [ wh1 ] = NumToStr(Priceline1 + (window1 / 2 ),2) ;
   TextLabel [ wh2 ] = NumToStr(Priceline2 + (window2 / 2 ),2) ;
   TextLabel [ wh3 ] = NumToStr(Priceline3 + (window3 / 2 ),2) ;
   TextLabel [ wh4 ] = NumToStr(Priceline4 + (window4 / 2 ),2) ;
   TextLabel [ wh5 ] = NumToStr(Priceline5 + (window5 / 2 ),2) ;
   TextLabel [ wh6 ] = NumToStr(Priceline6 + (window6 / 2 ),2) ;
   TextLabel [ wh7 ] = NumToStr(Priceline7 + (window7 / 2 ),2) ;
   TextLabel [ wh8 ] = NumToStr(Priceline8 + (window8 / 2 ),2) ;
   TextLabel [ wh9 ] = NumToStr(Priceline9 + (window9 / 2 ),2) ;
   TextLabel [ wh10] = NumToStr(Priceline10+ (window10 / 2 ),2) ;
   TextLabel [ wl1 ] = NumToStr(Priceline1 - (window1 / 2 ),2) ;
   TextLabel [ wl2 ] = NumToStr(Priceline2 - (window2 / 2 ),2) ;
   TextLabel [ wl3 ] = NumToStr(Priceline3 - (window3 / 2 ),2) ;
   TextLabel [ wl4 ] = NumToStr(Priceline4 - (window4 / 2 ),2) ;
   TextLabel [ wl5 ] = NumToStr(Priceline5 - (window5 / 2 ),2) ;
   TextLabel [ wl6 ] = NumToStr(Priceline6 - (window6 / 2 ),2) ;
   TextLabel [ wl7 ] = NumToStr(Priceline7 - (window7 / 2 ),2) ;
   TextLabel [ wl8 ] = NumToStr(Priceline8 - (window8 / 2 ),2) ;
   TextLabel [ wl9 ] = NumToStr(Priceline9 - (window9 / 2 ),2) ;
   TextLabel [ wl10] = NumToStr(Priceline10- (window10 / 2 ),2) ;
 
end;
 
If     DataCompression < 2       { intraday or tick bars }
   and Date >= BeginDate and Date <= EndDate then begin
           if Date = Date[ 1 ] then begin { other bars in day }
         For ii = pl1  to wl10 begin
            TL_SetEnd( LineID[ ii ], Date, endTime, SRValue[ ii ] ) ;
         end; { for }
      end { if Date = Date[ 1 ] }
      else Begin                   { first bar in day }
         
 SRValue[ pl1 ] = Priceline1;
 SRValue[ pl2 ] = PriceLine2;
 SRValue[ pl3 ] = Priceline3;       
 SRValue[ pl4 ] = Priceline4;  
 SRValue[ pl5 ] = Priceline5;  
 SRValue[ pl6 ] = Priceline6;
 SRValue[ pl7 ] = Priceline7;
 SRValue[ pl8 ] = Priceline8;
 SRValue[ pl9 ] = Priceline9;
 SRValue[ pl10] = Priceline10;
 SRValue[ wh1 ] = Priceline1 + ( window1 / 2) ;
  SRValue[ wh2 ] = Priceline2 + ( window2 / 2) ;
  SRValue[ wh3 ] = Priceline3 + ( window3 / 2) ;
  SRValue[ wh4 ] = Priceline4 + ( window4 / 2) ;
  SRValue[ wh5 ] = Priceline5 + ( window5 / 2) ;
  SRValue[ wh6 ] = Priceline6 + ( window6 / 2) ;
  SRValue[ wh7 ] = Priceline7 + ( window7 / 2) ;
  SRValue[ wh8 ] = Priceline8 + ( window8 / 2) ;
  SRValue[ wh9 ] = Priceline9 + ( window9 / 2) ;
  SRValue[ wh10 ] = Priceline10 + ( window10/ 2) ;
  SRValue[ wl1 ] = Priceline1 - ( window1 / 2) ;
  SRValue[ wl2 ] = Priceline2 - ( window2 / 2) ;
  SRValue[ wl3 ] = Priceline3 - ( window3 / 2) ;
  SRValue[ wl4 ] = Priceline4 - ( window4 / 2) ;
  SRValue[ wl5 ] = Priceline5 - ( window5 / 2) ;
  SRValue[ wl6 ] = Priceline6 - ( window6 / 2) ;
  SRValue[ wl7 ] = Priceline7 - ( window7 / 2) ;
  SRValue[ wl8 ] = Priceline8 - ( window8 / 2) ;
  SRValue[ wl9 ] = Priceline9 - ( window9 / 2) ;
  SRValue[ wl10 ] = Priceline10 - ( window10/ 2) ;
 
    
 
         For ii = pl1 to wl10 Begin
            { create lines }
            LineID[ ii ] = TL_New(Date,Time,SRValue[ ii
],Date,endTime,SRValue[ ii ]);
            print("created line ", ii:0:0, " at ", SRValue[ ii ]);
            TL_SetExtLeft (LineID[ ii ],ExtLeft);
            TL_SetExtRight(LineID[ ii ],ExtRight);
            TL_SetColor(LineID[ ii ],StandardColor);
             
   { set line style of the "in-between" levels }
            If ii > 0 and ii < 10 then 
               TL_SetStyle(LineID[ ii ],Tool_dotted);
          If ii > 11 then 
               TL_SetStyle(LineID[ ii ],Tool_Solid);
            
   { create text labels }
   TextID[ ii ] = Text_New(Date,time,SRValue[ ii ],TextLabel[ ii ]);
   Text_SetStyle(TextID[ ii ],1,1); { 1: HAlign=right, 2: VAlign=Centered } 
   Text_SetColor(TextID[ ii ],StandardColor);
            Text_SetLocation(TextID[ii],date,endTime,SRValue [ii]);
  
  
 
       end; { for }
      end; { else }
   end;