log in     sign up for free
 
Taking advantage of potential major winning trades is not only important to the mental health of the trader but is also critical to winning. Letting winners ride is every bit as important as cutting losses short. If you don't stay with your winners, you are not going to be able to pay for the losers.
Michael Marcus
 
 
Home
systems (284)
 
Special offer: buy AmiBroker and EOD+Real-Time Data
 
Formula Library
 
AmiBroker
MetaTrader
MetaStock
TradeStation
Wealth-Lab
NinjaTrader
 
add your formula
System Library
 
 
Account login
Your email:
Password:
 
Log in
New to s4t? Sign up.
If you forgot your password click here.
Search the Web
 
Custom Search

Weekly Hi-Lo Lines

Formula for: TradeStation

indicator


 

 

Views:  1387

Added: August 23, 2008
 
Rate this code:  Rate: 1 Rate: 2 Rate: 3 Rate: 4 Rate: 5
This formula has not been rated yet
 

email this link

 
 
Tags: TradeStation, indicator
 
Your Ad Here
In "Cueing Off Support And Resistance Levels" in this issue, author Thom Hartle discusses how the previous week's high and low prices can be used as support and resistance levels for the current week.
As Hartle states in the article, the first step is to plot two trendlines going forward, one off the previous week's high and one off the previous week's low. In the article, a how-to on plotting the trendlines manually is given. In TradeStation, however, it is quite straightforward to implement this as an indicator, just like MACD, and we present the EasyLanguage code for such an indicator here. If you have TradeStation 6, you can see that we used the code for the built-in Day Open-Hi-Lo Lines indicator as a starting point for the code presented here.




Type : Indicator, Name : Weekly Hi-Lo Lines

{ This indicator is for use with daily charts and inserts 2 horizontal trendlines for each week, at the high and low of the previous week, respectively.
For the current week, the trendlines are extended to the right. }

inputs:
HighColor( Yellow ),
LowColor( Cyan ) ;

variables:
HavePrevLines( false ),
TLHigh( 0 ),
TLLow( 0 ),
WeekHigh( 0 ),
WeekLow( 1000000 ),
PrevWeekHigh( 0 ),
PrevWeekLow( 0 ) ;
if DayOfWeek( Date ) < DayOfWeek( Date[1] ) then
{ ie, if new week }
begin
{ truncate the previous lines if they exist }
if HavePrevLines then
begin
TL_SetEnd( TLHigh, Date[1], Time[1],
PrevWeekHigh ) ;
TL_SetEnd( TLLow, Date[1], Time[1],
PrevWeekLow ) ;
TL_SetExtRight( TLHigh, false ) ;
TL_SetExtRight( TLLow, false ) ;
end ;
{ insert the new hi/lo lines and set their colors/extents }
TLHigh = TL_New( Date[1], Time[1], WeekHigh, Date, Time, WeekHigh ) ;
TLLow = TL_New( Date[1], Time[1], WeekLow, Date, Time, WeekLow ) ;
TL_SetColor( TLHigh, HighColor ) ;
TL_SetColor( TLLow, LowColor ) ;
TL_SetExtLeft( TLHigh, false ) ;
TL_SetExtLeft( TLLow,false ) ;
TL_SetExtRight( TLHigh, true ) ;
TL_SetExtRight( TLLow, true ) ;
{ re-initialize hi/lo variables }
PrevWeekHigh = WeekHigh ;
PrevWeekLow = WeekLow ;
WeekHigh = High ;
WeekLow = Low ;
{ set flag }
if HavePrevLines = false then
HavePrevLines = true ;
end
else
{ if new hi/lo for week, save values }
begin
if High > WeekHigh then
WeekHigh = High ;
if Low < WeekLow then
WeekLow = Low ;
end ;






This code will also be available for download from the EasyLanguage Library at www.tradestationworld.com .

--Ramesh Dhingra
Director, EasyLanguage Consulting

TradeStation Technologies, Inc. (formerly Omega Research, Inc.) a wholly owned subsidiary of TradeStation Group, Inc.
www.TradeStation.com

 

 



Code:

Type : Indicator, Name : Weekly Hi-Lo Lines

{ This indicator is for use with daily charts and inserts 2 horizontal trendlines for each week, at the high and low of the previous week, respectively.
For the current week, the trendlines are extended to the right. }

inputs:
HighColor( Yellow ),
LowColor( Cyan ) ;

variables:
HavePrevLines( false ),
TLHigh( 0 ),
TLLow( 0 ),
WeekHigh( 0 ),
WeekLow( 1000000 ),
PrevWeekHigh( 0 ),
PrevWeekLow( 0 ) ;
if DayOfWeek( Date ) < DayOfWeek( Date[1] ) then
{ ie, if new week }
begin
{ truncate the previous lines if they exist }
if HavePrevLines then
begin
TL_SetEnd( TLHigh, Date[1], Time[1],
PrevWeekHigh ) ;
TL_SetEnd( TLLow, Date[1], Time[1],
PrevWeekLow ) ;
TL_SetExtRight( TLHigh, false ) ;
TL_SetExtRight( TLLow, false ) ;
end ;
{ insert the new hi/lo lines and set their colors/extents }
TLHigh = TL_New( Date[1], Time[1], WeekHigh, Date, Time, WeekHigh ) ;
TLLow = TL_New( Date[1], Time[1], WeekLow, Date, Time, WeekLow ) ;
TL_SetColor( TLHigh, HighColor ) ;
TL_SetColor( TLLow, LowColor ) ;
TL_SetExtLeft( TLHigh, false ) ;
TL_SetExtLeft( TLLow,false ) ;
TL_SetExtRight( TLHigh, true ) ;
TL_SetExtRight( TLLow, true ) ;
{ re-initialize hi/lo variables }
PrevWeekHigh = WeekHigh ;
PrevWeekLow = WeekLow ;
WeekHigh = High ;
WeekLow = Low ;
{ set flag }
if HavePrevLines = false then
HavePrevLines = true ;
end
else
{ if new hi/lo for week, save values }
begin
if High > WeekHigh then
WeekHigh = High ;
if Low < WeekLow then
WeekLow = Low ;
end ;


 






Author: Thom Hartle
Source: http://www.traders.com

 

View similar (indicator for TradeStation):

CCI Predict
ZigZag
Pretty Weird Late Night Stuff
Ehlers Filter
TRIX Indicator S&C
Regularization
MATCH
CCI - Stochastic (CCI-STO)
LBR_3/10 Oscillator
DIMA Averages
...
 
 
all formulas for TradeStation
all formulas

 

 

Email to friend

Top

 

     
However we try to maintain hiqhest possible level of service - most formulas, oscillators, indicators
and systems are submitted by anonymous users.
Therefore S4T™ does not take any responsibility for it's quality.
If you use any of this information, use it at your own risk. You are responsible for your own trading decisions.
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade.
In no case will S4T™ be responsible for your trading gains or losses.
 
Privacy note | (c) copyrights systems4trading.com 2006-2012