NexusFi: Find Your Edge


Home Menu

 





Timed breakout box


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one TwoHands with 9 posts (0 thanks)
    2. looks_two program with 3 posts (3 thanks)
    3. looks_3 cory with 2 posts (2 thanks)
    4. looks_4 Big Mike with 1 posts (0 thanks)
    1. trending_up 10,726 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 17 posts
    2. attach_file 3 attachments




 
Search this Thread

Timed breakout box

(login for full post details)
  #11 (permalink)
 TwoHands 
Fort Lauderdale, Florida
 
Experience: Beginner
Platform: TradeStation
Trading: ES
Posts: 115 since Apr 2011
Thanks Given: 97
Thanks Received: 150

Thanks Program but this one didn't compile either: it calls Time_s an unknown identifier.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Request for MACD with option to use different MAs for fa …
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Volume profile TradeStation
EasyLanguage Programming
News alerts
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
37 thanks
Deaddogs Stock Trading
27 thanks
GFIs1 1 DAX trade per day journal
25 thanks
Supertradersams Thread Journal on NQ/MNQ
24 thanks
Leaving CFD trading and learning futures
11 thanks

(login for full post details)
  #12 (permalink)
 
program's Avatar
 program 
CA USA
 
Experience: Intermediate
Platform: MultiCharts
Broker: DDT+land/Rithmic/IQ
Trading: S&P500,6E,YM
Posts: 99 since Nov 2010
Thanks Given: 127
Thanks Received: 64


TwoHands View Post
Thanks Program but this one didn't compile either: it calls Time_s an unknown identifier.

I've never used TS, so i probably won't be able help much more... that being said, try changing Time_s to Time easylanguage and powerlanguage "should" be very close.

I have approximate answers, possible beliefs and different degrees of certainty of different things. But I'm not absolutely sure of anything and there are many things i don't know anything about.
Reply With Quote
The following user says Thank You to program for this post:
(login for full post details)
  #13 (permalink)
 TwoHands 
Fort Lauderdale, Florida
 
Experience: Beginner
Platform: TradeStation
Trading: ES
Posts: 115 since Apr 2011
Thanks Given: 97
Thanks Received: 150


As it turns out, TS has a built in indicator called Subsession Hi Lo lines that, except for some minor display tweaks I'd prefer, does almost exactly what I want. Thanks much for your effort.

Started this thread Reply With Quote
(login for full post details)
  #14 (permalink)
Bimi
London
 
Posts: 118 since Mar 2010
Thanks Given: 42
Thanks Received: 58


TwoHands View Post
Has anyone written or know where I can find a breakout box? I'd like it to allow me to input start and end times and show the high and low of that period. Also need it to automatically change for each day based on the chart's session hours.

The image is using manually entered horizontal and vertical lines to give an idea what I'm looking for.


do you need it for backtest? or to run it real time?

Reply With Quote
(login for full post details)
  #15 (permalink)
 TwoHands 
Fort Lauderdale, Florida
 
Experience: Beginner
Platform: TradeStation
Trading: ES
Posts: 115 since Apr 2011
Thanks Given: 97
Thanks Received: 150


Bimi View Post
do you need it for backtest? or to run it real time?

Preferably both but since I have no coding skills I'm having to do my testing real time, viewing daily charts that go back a year or so. I know it's Jesse Livermore-ish but until I learn to program {something I haven't done in 30 years} it's what I've got to work with.

Started this thread Reply With Quote
(login for full post details)
  #16 (permalink)
 TwoHands 
Fort Lauderdale, Florida
 
Experience: Beginner
Platform: TradeStation
Trading: ES
Posts: 115 since Apr 2011
Thanks Given: 97
Thanks Received: 150

Big Mike has given me permission to post the source of the original Tradestation indicator called Subsession Hi Lo Lines hoping that someone can help me get this working the way I want. I'm also posting code from one of the TS employees who made some ineffective changes and then lost interest.

This is a screenshot of several days on a 15 minute chart using TS's original indicator. It allows me to input start and end times and plots the lines for the hi & lo of that period.




 
Code
{ 
This indicator is designed to plot the period high and low for a time period set by
the "StartTime" and "EndTime" inputs.  The OHLCV calculations are reset when the new
time period starts as evaluated by the "ResetCalcs" calculations.  

This indicator is intended for application only to intraday bars (tick or time-
based).  

Commentary on the use of vectors for OHLCV, along with calculation explanations,
can be found in the "OHLCVCollection" function.
}

{ code will use classes from these namespaces }
using elsystem ;
using elsystem.collections ;

inputs:
	int NumSubSessionsAgo( 1 ), { number of sub-sessions ago;  use zero to refer to
	 the current sub-session }
	int StartTime( 0930 ), { start time for OHLCV calculations }
	int EndTime( 1600 ) ; { end time for OHLCV calculations }
	
variables:
	Vector OHLCV_Vector( NULL ), { this is the vector that will be passed by
	 reference to the function OHLCVCollection;  it will hold all the OHLCV values }
	Vector HighVector( NULL ), { High Prices }
	Vector LowVector( NULL ), { Low Prices }
	bool ResetCalcs( false ),
	bool IncludeThisBar( false ),
	int RtnValOrErrorCode( 0 ), { variable to hold the value returned by call to
	 OHLCVCollection function }
	intrabarpersist bool ValuesAvailable( false ), { used to ensure that there is
	 enough data in the vector before requesting a value }
	double SubSessionHigh( -1 ), { holds High of NumSessionsAgo }
	double SubSessionLow( -1 ) ; { holds Low of NumSubSessionAgo }
		
{ check bar type;  instantiate the vectors }	
method void Init( Object InitSender, InitializedEventArgs InitArgs ) 
	begin
	
	if BarType >= 2 then 
		RaiseRuntimeError( "Price Channel (Time-based) can be applied to " +
		 "intraday bars only." ) ;
	
	OHLCV_Vector = new Vector ;
	HighVector = new Vector ;	
	LowVector = new Vector ;
	
	end ;

{ condition upon which OHLCV values will be reset for next period }
ResetCalcs = ( Time > StartTime and Time[1] <= StartTime )
	or ( Time > StartTime and Time[1] > Time )
    or ( Time[1] > Time and StartTime > Time[1] ) ;

{
IncludeThisBar is passed in to OHLCVCollection to designate whether this bar is to 
be used in the OHLCV calcultions.  This variable is true if the bar falls within the
time frame established by the StartTime and EndTime inputs and false if the bar is
outside the time frame.
}
IncludeThisBar = IFFLogic( StartTime > EndTime, Time > StartTime or Time <= EndTime,
 Time > StartTime and Time <= EndTime ) ;

RtnValOrErrorCode = OHLCVCollection( ResetCalcs, IncludeThisBar, OHLCV_Vector ) ;

{ set-up HighVector and LowVector }
once 
	begin
	HighVector = OHLCV_Vector[1] astype Vector ; { [1] = High Price }
	LowVector = OHLCV_Vector[2] astype Vector ;  { [2] = Low Price }
	end ;
	
{ only allow retrieval of data once there is enough data loaded into the vector }
once ( RtnValOrErrorCode > NumSubSessionsAgo ) 
	ValuesAvailable = true ;

if ValuesAvailable then
	begin
	SubSessionHigh = HighVector.At( NumSubSessionsAgo ) astype double ;
	SubSessionLow = LowVector.At( NumSubSessionsAgo ) astype double ;
	Plot1( SubSessionHigh, "SubSessHigh" ) ;
	Plot2( SubSessionLow, "SubSessLow" ) ;
	end
else if LastBarOnChart then
	RaiseRuntimeError( "High and low not available for requested session.  " +
	 "Try loading more historical data or increasing 'load additional bars'" +
	 " setting." ) ;


{ ** Copyright (c) 2001 - 2010 TradeStation Technologies, Inc. All rights reserved. ** 
  ** TradeStation reserves the right to modify or overwrite this analysis technique 
     with each release. ** }
I made some requests in the TS forum and one of the TS coders came back with another version of it. I asked for

1. No need for the indi to plot beyond session hours
2. No need to show variations in the hi/lo for the input period
3. Text labels showing the value of the lines.


He came back with code that displays strangely…



His code plots correctly if I use the previous day's data on todays chart, which I don't want -- it's a breakout strategy so it needs todays data. When I use todays data, this is what I get. I have no idea how he calculated the ending point so I don't know why the lines are angled.

His code:

 
Code
{  
This indicator is designed to plot the period high and low for a time period set by 
the "StartTime" and "EndTime" inputs.  The OHLCV calculations are reset when the new 
time period starts as evaluated by the "ResetCalcs" calculations.   
 
This indicator is intended for application only to intraday bars (tick or time- 
based).   
 
Commentary on the use of vectors for OHLCV, along with calculation explanations, 
can be found in the "OHLCVCollection" function. 
 
*** This indicator was customized to allow the start and ending times of when 
    the trend lines are draw can be controlled with inputs and the trend line 
    values are labeled. 
} 
 
{ code will use classes from these namespaces } 
using elsystem ; 
using elsystem.collections ; 
 
inputs: 
	int NumSubSessionsAgo( 0 ), { number of sub-sessions ago;  use zero to refer to 
	 the current sub-session } 
	int StartTime( 1200 ), { start time for OHLCV calculations } 
	int EndTime( 1300 ), { end time for OHLCV calculations } 
	 
	int DrawStartTime( 1200 ),  //  *** user input to control when trend lines start 
	int DrawEndTime( 1600 ) ;   //  *** user input to control when trend lines end 
	 
variables: 
	Vector OHLCV_Vector( NULL ), { this is the vector that will be passed by 
	 reference to the function OHLCVCollection;  it will hold all the OHLCV values } 
	Vector HighVector( NULL ), { High Prices } 
	Vector LowVector( NULL ), { Low Prices } 
	bool ResetCalcs( false ), 
	bool IncludeThisBar( false ), 
	int RtnValOrErrorCode( 0 ), { variable to hold the value returned by call to 
	 OHLCVCollection function } 
	intrabarpersist bool ValuesAvailable( false ), { used to ensure that there is 
	 enough data in the vector before requesting a value } 
	double SubSessionHigh( -1 ), { holds High of NumSessionsAgo } 
	double SubSessionLow( -1 ), { holds Low of NumSubSessionAgo } 
	 
	Int HighTLID( 0 ),  //  *** add these variables 
	Int LowTLID( 0 ),   //  *** add these variables 
	 
	Int TextID( 0 ) ;    //  *** add these variables 
 
//  *** Change from Init to InitializeComponent so this code runs 
//  first thing before the OHLCVCollections function does, else we 
//  we will get an object not found error 
method override void InitializeComponent() begin 
		 
	if BarType >= 2 then  
		RaiseRuntimeError( "Price Channel (Time-based) can be applied to " + 
		 "intraday bars only." ) ; 
	 
	OHLCV_Vector = new Vector ; 
	HighVector = new Vector ;	 
	LowVector = new Vector ; 
	 
end ; 
 
{ condition upon which OHLCV values will be reset for next period } 
ResetCalcs = ( Time > StartTime and Time[1] <= StartTime ) 
	or ( Time > StartTime and Time[1] > Time ) 
    or ( Time[1] > Time and StartTime > Time[1] ) ; 
 
{ 
IncludeThisBar is passed in to OHLCVCollection to designate whether this bar is to  
be used in the OHLCV calcultions.  This variable is true if the bar falls within the 
time frame established by the StartTime and EndTime inputs and false if the bar is 
outside the time frame. 
} 
IncludeThisBar = IFFLogic( StartTime > EndTime, Time > StartTime or Time <= EndTime, 
 Time > StartTime and Time <= EndTime ) ; 
 
RtnValOrErrorCode = OHLCVCollection( ResetCalcs, IncludeThisBar, OHLCV_Vector ) ; 
 
{ set-up HighVector and LowVector } 
once  
	begin 
	HighVector = OHLCV_Vector[1] astype Vector ; { [1] = High Price } 
	LowVector = OHLCV_Vector[2] astype Vector ;  { [2] = Low Price } 
	end ; 
	 
{ only allow retrieval of data once there is enough data loaded into the vector } 
once ( RtnValOrErrorCode > NumSubSessionsAgo )  
	ValuesAvailable = true ; 
 
if ValuesAvailable then begin 
	 
	SubSessionHigh = HighVector.At( NumSubSessionsAgo ) astype double ; 
	SubSessionLow = LowVector.At( NumSubSessionsAgo ) astype double ; 
	 
	//  *** If the prior bar time is less than the draw start time but the 
	//  current bar time is greater than the draw start time then we are on the 
	//  first bar of the draw time window, so create the high and low trend lines 
	//  as initial points with the start and end values 
	if Time[1] < DrawStartTime and Time >= DrawStartTime then begin 
	 
		HighTLID = TL_New( Date, Time, SubSessionHigh, Date, Time, SubSessionHigh ) ; 
		LowTLID  = TL_New( Date, Time, SubSessionLow, Date, Time, SubSessionLow ) ;	 
		 
		//  Set the high trend line to light blue and the low trend line to purple 
		Value1 = TL_SetColor( HighTLID, Cyan ) ; 
		Value1 = TL_SetColor( LowTLID, Magenta ) ; 
		 
		//  Create a text label of the subsession high value above the subsession high trend line 
		TextID = Text_New( Date, Time, SubSessionHigh, NumToStr( SubSessionHigh, 2 ) ) ; 
		Value1 = Text_SetStyle( TextID, 0, 1 ) ;  //  Place label to the right and above trend line 
		 
		//  Create a text label of the subsession low value below the subsession low trend line		 
		TextID = Text_New( Date, Time, SubSessionLow, NumToStr( SubSessionLow, 2 ) ) ; 
		Value1 = Text_SetStyle( TextID, 0, 0 ) ;   //  Place label to the right and below trend line	  
			 
	end 
	 
	//  *** Else if we have a high trend line ID defined and the time is between 
	//      the draw start and end times, stretch out the end of the high and low 
	//      trend lines to the current date/time 
	else if HighTLID > 0 and Time >= DrawStartTime and Time <= DrawEndTime then begin 
		Value1 = TL_SetEnd( HighTLID, Date, Time, SubSessionHigh ) ; 
		Value1 = TL_SetEnd( LowTLID,  Date, Time, SubSessionLow ) ;	 
	end ; 
	 
end 
else if LastBarOnChart then 
	RaiseRuntimeError( "High and low not available for requested session.  " + 
	 "Try loading more historical data or increasing 'load additional bars'" + 
	 " setting." ) ;
I'm grateful to anyone that can tweak this for me.

Started this thread Reply With Quote
(login for full post details)
  #17 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350

@TwoHands, is this a "timed breakout box"?

If not, you might also post here:



Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor


For the best trading education, watch our webinars
Searching for trading reviews? Review this list


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
(login for full post details)
  #18 (permalink)
 TwoHands 
Fort Lauderdale, Florida
 
Experience: Beginner
Platform: TradeStation
Trading: ES
Posts: 115 since Apr 2011
Thanks Given: 97
Thanks Received: 150


Big Mike View Post
@TwoHands, is this a "timed breakout box"?

If not, you might also post here:



Mike

Thanks Mike. Moved it here, retitled it Open Range indicator.

Started this thread Reply With Quote





Last Updated on July 20, 2012


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts