Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 05-30-2010, 12:18 PM   #9

Join Date: Dec 2006
Location: new york
Posts: 31
Ignore this user

Thanks: 1
Thanked 13 Times in 8 Posts

Re: HowTo Determine then Barnumber of a Pivot

This is Version 2.5, Rev3-2
insideday is offline  
Reply With Quote
The Following 2 Users Say Thank You to insideday For This Useful Post:
aaa (05-31-2010), Tams (05-30-2010)
Old 06-23-2010, 07:56 PM   #10

Join Date: May 2010
Posts: 31
Ignore this user

Thanks: 0
Thanked 20 Times in 14 Posts

Re: HowTo Determine then Barnumber of a Pivot

Jojojo, here's a small tradestation program that calculates the bar number for a swing high or low and prints the number above/below the swing.

It first determines how many bars ago the swing occured, then subtracts that from the current bar number to determine the bar number of the swing. The bottom of the program simply prints the number on the chart.

Inputs:
SwingStrength(5);

Variables:
SwingHiBarsAgo(0),
SwingLoBarsAgo(0),
SwingHiBarNum(0),
SwingLoBarNum(0);

SwingHiBarsAgo = SwingHighBar(1, high, SwingStrength, SwingStrength+1) ;

if SwingHiBarsAgo <> -1 then begin
SwingHiBarNum = CurrentBar - SwingHiBarsAgo ;
//You can add code here to store the bar number in an array, or do whatever other calculations you need
end ;

SwingLoBarsAgo = SwingLowBar(1, Low, SwingStrength, SwingStrength+1) ;

if SwingLoBarsAgo <> -1 then begin
SwingLoBarNum = CurrentBar - SwingLoBarsAgo ;
//You can add code here to store the bar number in an array, or do whatever other calculations you need
end ;

Variables:
TextSwingHi(0),
TextSwingLo(0);

if SwingHiBarsAgo <> -1 then begin
TextSwingHi = Text_New(date[SwingHiBarsAgo], time[SwingHiBarsAgo], High[SwingHiBarsAgo], NumToStr(SwingHiBarNum,0) ) ;
Text_SetStyle(TextSwingHi , 2, 1) ;
end ;

if SwingLoBarsAgo <> -1 then begin
TextSwingLo = Text_New(date[SwingLoBarsAgo], time[SwingLoBarsAgo], Low[SwingLoBarsAgo], NumToStr(SwingLoBarNum, 0)) ;
Text_SetStyle(TextSwingLo , 2, 0) ;
end ;
Attached Thumbnails
HowTo Determine then Barnumber of a Pivot-swingbarnum.jpg  
TraderWill is offline  
Reply With Quote
The Following User Says Thank You to TraderWill For This Useful Post:
aaa (06-26-2010)

Reply

Tags
zigzag

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:


All times are GMT -4. The time now is 02:49 PM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.