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

Re: Pivot Points and Support/Resistance levels



PureBytes Links

Trading Reference Links

Here is code I wrote that does what you ask.  It only works in subgraph 1
for some reason I have not tried to figure out.  I based the code on the
Daily Hi_Lo indicator in TS 6.0. It plots trend lines for the pivot and S1,
S2, R1 and R2.  Hope this helps.

inputs:
 PivotColor( Yellow ),
 SupportColor( Blue ),
 ResistColor( Red ),
 ShowSR( True ),
 LineStyle( Tool_Dashed),
 DoPrintLog( FALSE );

 variables:
  HavePrevLines( FALSE),
 TLPivot(0),
 TLS1(0),
 TLS2(0),
 TLR1(0),
 TLR2(0),
 DayPivot( 0 ),
 DayS1(0),
 DayS2(0),
 DayS3(0),
 DayR1(0),
 DayR2(0),
 DayR3(0),
 DayClose( 0 ),
 DayHigh( 0 ),
 DayLow( 0 ) ;


DayClose = Close;
if BarType <= 1 then { if minute or tick bars }
 begin
 if Date <> Date[1] then { if new day }
  begin

  { truncate the previous lines if they exist }
  if HavePrevLines then
   begin
   TL_SetEnd( TLPivot, Date[1], Time[1], DayPivot ) ;
   TL_SetExtRight( TLPivot, false ) ;
   if( ShowSR ) then
    begin
    TL_SetEnd( TLS1, Date[1], Time[1], DayS1 ) ;
    TL_SetExtRight( TLS1, false ) ;
    TL_SetEnd( TLS2, Date[1], Time[1], DayS2 ) ;
    TL_SetExtRight( TLS2, false ) ;
    TL_SetEnd( TLR1, Date[1], Time[1], DayR1 ) ;
    TL_SetExtRight( TLR1, false ) ;
    TL_SetEnd( TLR2, Date[1], Time[1], DayR2 ) ;
    TL_SetExtRight( TLR2, false ) ;
    end;

   end ;

  { re-initialize H,L and pivots for the new day }

  DayHigh = High ;
  DayLow = Low ;
  DayPivot = ( DayClose[1] + DayHigh[1] + DayLow[1] ) / 3;
  DayS1 = ( 2 * DayPivot ) - DayHigh[1];
  DayR1 = ( 2 * DayPivot ) - DayLow[1];
  DayR2 = ( DayPivot - DayS1) + DayR1;
  DayS2 = DayPivot - (DayR1 - DayS1);
  DayS3 = DayPivot - (DayR2 - DayS1 );
  DayR3 = ( DayPivot - DayS2 ) + DayR1;

  if( DoPrintLog ) then begin
   Print(GetSymbolName, "  Date: ",ELDateToString(Date), "  Pv:",DayPivot,
",  S1:", DayS1,",  S2:",DayS2,",  R1:",DayR1,",  R2:",DayR2);
   Print("C:",DayClose[1],", H:",DayHigh[1],", L:",DayLow[1]);
  end;

  { insert the new Pivot lines and set their colors/extents/styles }
  TLPivot = TL_New( Date[1], Time[1], DayPivot, Date, Time, DayPivot ) ;
  TL_SetColor( TLPivot, PivotColor ) ;
  TL_SetStyle(TLPivot, LineStyle);
  TL_SetExtLeft( TLPivot, false ) ;
  TL_SetExtRight( TLPivot, true ) ;
  if( ShowSR ) then
   Begin
   TLS1 = TL_New( Date[1], Time[1], DayS1, Date, Time, DayS1 ) ;
   TL_SetColor( TLS1, SupportColor ) ;
   TL_SetStyle(TLS1, LineStyle);
   TL_SetExtLeft( TLS1, false ) ;
   TL_SetExtRight( TLS1, true ) ;
   TLS2 = TL_New( Date[1], Time[1], DayS2, Date, Time, DayS2 ) ;
   TL_SetColor( TLS2, SupportColor ) ;
   TL_SetStyle(TLS2, LineStyle);
   TL_SetExtLeft( TLS2, false ) ;
   TL_SetExtRight( TLS2, true ) ;
   TLR1 = TL_New( Date[1], Time[1], DayR1, Date, Time, DayR1 ) ;
   TL_SetColor( TLR1, ResistColor ) ;
   TL_SetStyle(TLR1, LineStyle);
   TL_SetExtLeft( TLR1, false ) ;
   TL_SetExtRight( TLR1, true ) ;
   TLR2 = TL_New( Date[1], Time[1], DayR2, Date, Time, DayR2 ) ;
   TL_SetColor( TLR2, ResistColor ) ;
   TL_SetStyle(TLR2, LineStyle);
   TL_SetExtLeft( TLR2, false ) ;
   TL_SetExtRight( TLR2, true ) ;
   end;

  { set flag }
  if HavePrevLines = false then
   HavePrevLines = true ;
  end
 else if HavePrevLines = true then
  { if new hi/lo for day, save values  }
  begin
  if High > DayHigh then
   begin
   DayHigh = High ;
   end ;
  if Low < DayLow then
   begin
   DayLow = Low ;
   end ;
  end ;
 end ;



----- Original Message -----
From: "Cody Burgat" <cburgat@xxxxxxxxxxxxxx>
To: <omega-list@xxxxxxxxxx>
Sent: Saturday, March 30, 2002 9:49 PM
Subject: Pivot Points and Support/Resistance levels


>    Hello,
>
> Just searching for an ela file that will plot the Pivot points and
> support/resistance lines using the common floor trader's formula using
daily
> data.  If anyone can help, it would be greatly appreciated.  I am fairly
> certain that this has been discussed before, but I am having no luck
finding
> it.  Thank you!
>
> Cody
>