Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

simterann22

Gapless Squeeze

Recommended Posts

Here is a new squeeze indicator I have modified from open source code to ignore or partially ignore an opening gap. This may be helpful with futures but more so with stocks gapping in the opening of the session....so you can get in earlier ;)

 

I am still somewhat of a newbie and since joining this site I have grown exponentially. So I want to give something back.

 

The idea was taken from John McCormick's gapless code:

 

https://www.tradestation.com/Discussions/Topic.aspx?Topic_ID=77574

 

I've converted the gapless code into a function 'Gapless'...see ELD. You can then cut and paste the Gapless indicator addin code below into any indicator that will benefit and allow you to replace the o,h,l,c values within the code. eg. BBs, Stoch, RSI, MACD etc.

 

******* Please note I have placed a limit in the function so that the gapless addin will only work with tick or intraday charts. If you switch to a larger timeframe the values will default to the real o,h,l,c and your indicator will look 'normal' again. You do not have to touch a thing, just realise it will do this. Also 60min charts may come out distorted as the gaps are too close together in time. Lower time frame charts work best*******

 

Please feel free to modify it to suit your needs and make it better.....and make sure you post of course. :)

 

As per the 'Squeeze'....

 

the BB Squeeze: Enter after dots turn from red to green in the direction of the histogram. Confirm with Gaussean squeeze dots (BB False)....green up, red down, simple. Go flat when the BB dots turn red or there is loss of momentum (histogram turns). Remember you must always confirm with other indicators.

 

Here is the code addin:

 

{-------------Gapless Addin----------------------------}
{'Gapless code' initially written by John McCormick May 2008
Converted by Simterann22 2009

The idea is that at a gap opening any indicator that relies 
on previous bars to calculate its values will be distorted. This addin 'ignores' the gap.
Function 'Gapless' will only return gapless value if tick or intraday chart else normal value.}

// Simply cut and paste this into your code below your current vars :

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0);		// Relative Close


relO=Gapless(1.0,O);
//set Gapless coefficent to 1.0 to ignore gap(Gapless),0.5 Halfgap,0.0 Include Gap(Normal)	
relH=Gapless(1.0,H);
relL=Gapless(1.0,L);
relC=Gapless(1.0,C);

//now replace all O,H,L,C with RelO,RelH,RelL,RelC in your code

{--------------End Gapless Addin-------------------------}

@SK_SQUEEZE.ELD

@sk_Squeeze.thumb.jpg.7eb145a965202233f2a84ead52927f69.jpg

Edited by simterann22

Share this post


Link to post
Share on other sites

Now I understand why John didn't make 'gapless' into a function....because indicators plotted on the same scale as the underlying eg. BBs will not plot correctly. He writes that for these 'accum' has to be added to the plot price. I made the gapless function for indicators in the subgraph.

 

If you wish here is a copy of the raw code without the need of a function:

 

variables:
Avg( 0 ),
SDev( 0 ),
LowerBand( 0 ),
UpperBand( 0 ),
Price( 0 );

// gapless day transitions - John McCormick May 2008

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0),		// Relative Close
gap(0),			// the opening gap (modified by the gap coefficient)
GapCoef(1.0),	// Gap Coefficient
Accum(0);		// The sum of all the daily gaps

if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;

// Gapless - end

 

For the BB code for eg. your code should look like this:

 

inputs:
BollingerPrice( Close ),
TestPriceUBand( Close ),
TestPriceLBand( Close ),
Length( 20 ),
NumDevsUp( 2 ),
NumDevsDn( -2 ),
Displace( 0 ) ;

variables:
Avg( 0 ),
SDev( 0 ),
LowerBand( 0 ),
UpperBand( 0 ),
Price( 0 );

// gapless day transitions - John McCormick May 2008

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0),		// Relative Close
gap(0),			// the opening gap (modified by the gap coefficient)
GapCoef(1.0),	// Gap Coefficient
Accum(0);		// The sum of all the daily gaps

if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;

// Gapless - end

price = RelC;
If BollingerPrice=open then price = RelO;
If BollingerPrice=high then price = RelH;
If BollingerPrice=low then price = RelL;
Avg = AverageFC( Price, Length ) ;
SDev = StandardDev( Price, Length, 1 ) ;
UpperBand = Avg + NumDevsUp * SDev;
LowerBand = Avg + NumDevsDn * SDev;

if Displace >= 0 or CurrentBar > AbsValue( Displace ) then 
begin
Plot1[Displace]( UpperBand + [HIGHLIGHT GREEN]accum[/HIGHLIGHT GREEN], "UpperBand" ) ;
Plot2[Displace]( LowerBand + [HIGHLIGHT GREEN]accum[/HIGHLIGHT GREEN], "LowerBand" ) ;
Plot3[Displace]( Avg + [HIGHLIGHT GREEN]accum[/HIGHLIGHT GREEN], "MidLine" ) ;

{ Alert criteria }
if Displace <= 0 then
	begin
	if TestPriceLBand crosses over LowerBand then
		Alert( "Price crossing over lower price band" ) 
	else if TestPriceUBand crosses under UpperBand then
		Alert( "Price crossing under upper price band" ) ;
	end ;
end ;


{ ** Copyright (c) 2005 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

Find attached ELDs for a few of his indicators

 

Enjoy.

20080601080830GAPLESS.ELD

20080602233304GL_ATR.ELD

20090606150816DMI_GAPLESS.ELD

Edited by simterann22
Added intra code

Share this post


Link to post
Share on other sites

Bear in mind that John's original code in the above ELDs do not include an intra day filter. You may remove

 

RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

 

and replace with

 

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;

Share this post


Link to post
Share on other sites

ThanX simterann22 for all your informations

 

I'm wondering if it works fine with averages

 

Is there a MACD Gapless indicator ?

 

Is there an Average Gapless indicator ?

Share this post


Link to post
Share on other sites

That's a bit strange.... here is another attachment....

 

and the code just in case....

 

inputs: Price(close),FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ), ZeroLine(False), Histogram(true);
variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ) ;

// gapless day transitions - John McCormick May 2008

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0),		// Relative Close
gap(0),			// the opening gap (modified by the gap coefficient)
GapCoef(1.0),	// Gap Coefficient
Accum(0);		// The sum of all the daily gaps

if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;

// Gapless - end

Var: GL_Price(0);

GL_price = RelC;
If Price=open then GL_price = RelO;
If Price=high then GL_price = RelH;
If Price=low then GL_price = RelL;


MyMACD = MACD( GL_price, FastLength, SlowLength ) ;
MACDAvg = XAverage( MyMACD, MACDLength ) ;
MACDDiff = MyMACD - MACDAvg ;

Plot1( MyMACD, "MACD" ) ;
Plot2( MACDAvg, "MACDAvg" ) ;
if Histogram=True then
Plot3( MACDDiff, "MACDDiff" ) ;
if ZeroLine=True then
Plot4( 0, "ZeroLine" ) ;

{ Alert criteria }
if MACDDiff crosses over 0 then
Alert( "Bullish alert" )
else if MACDDiff crosses under 0 then
Alert( "Bearish alert" ) ; 


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

inputs:
Price( Close ),
Length( 8),
Displace(  0 ) ;

variables:
AvgExp( 0 );

// gapless day transitions - John McCormick May 2008

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0),		// Relative Close
gap(0),			// the opening gap (modified by the gap coefficient)
GapCoef(1.0),	// Gap Coefficient
Accum(0);		// The sum of all the daily gaps

if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;

// Gapless - end

Var: GL_Price(0);

GL_price = RelC;
If Price=open then GL_price = RelO;
If Price=high then GL_price = RelH;
If Price=low then GL_price = RelL;


AvgExp = XAverage( GL_Price, Length ) ;

if Displace >= 0 or CurrentBar > AbsValue( Displace ) then 
begin
Plot1[Displace]( AvgExp + Accum, "AvgExp" ) ;

{ Alert criteria }
if Displace <= 0 then 
	begin
	if Price > AvgExp and AvgExp > AvgExp[1] and AvgExp[1] <= AvgExp[2] then
		Alert( "Indicator turning up" ) 
	else if Price < AvgExp and AvgExp < AvgExp[1] and AvgExp[1] >= AvgExp[2] then
		Alert( "Indicator turning down" ) ;
	end ;
end ;


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

MACD AND EMA GL.ELD

Share this post


Link to post
Share on other sites

Saw this thread about gapless indicators at TS, really like the additions and thank you simterann22. What would be the corrrect way to code a gapless Parabolic SAR indicator? I've been trying to snug the Parabolic SAR recently so it doesn't under or overshoot as much, stays right next to the price and reverses with it, without too much luck. It helps a little to change the 2nd number to .01 from .02, but still needs additional tweaking. Thanks for any help with that if possible and the gapless SAR, and thanks again for adding the extra gapless indicators.

Share this post


Link to post
Share on other sites

Okay....here it goes. I've never used Parabolic SAR so I don't know if this is what you want. I don't know if it turned out right, so let me know.

 

Well, anyway to make any indicator gapless first have a look at the EL for the indicator itself. If any form of 'price' appears in it say O,H,L,C then you can simply paste the gap code in. If it does not, you have to paste the gap code in the FUNCTION that the indicator uses (save and modify a new one of course ;) . Now MACD was easy for this, but because the Parabolic SAR needs both a modified gapless function AND have 'accum' added to it (because it is plotted on price action....see previous posts) this was a problem.

 

I simply got around this by adding

 

	gap(0),			
	GapCoef(1.0),	
	Accum(0);		


if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

 

into the indicator code since 'accum' is an independent little program in itself. Just make sure at the 'plot' line to add 'accum' to the value being plotted. (see ELD).

 

Compare the ELDs and the standard ones and you'll figure it all out.

5aa70ef190744_GaplessParaSAR.thumb.jpg.677363cb98f99211b154d305c8f7221a.jpg

GAPLESS PARABOLIC SAR.ELD

Edited by simterann22

Share this post


Link to post
Share on other sites

Check the above ELD. I just uploaded a new one in the original's place....I think it worked. I had to modify the code to work properly on daily and above. If it plots different to the standard Parabolic SAR on an intraday/tick chart and exactly the same on a daily and above then it's all good. Otherwise let me know.

Share this post


Link to post
Share on other sites

Thanks for this code, WOuld this code be also able to account for gap in data during a period of the day (say when you had a hour down time) and not just the opening gap.

 

Thanks

Share this post


Link to post
Share on other sites

I'm assuming you mean at the end of futures sessions, weekend etc.?

 

Paste

 

if currentsession(0)<> currentsession(0)[1] or 

 

directly in front of date<>date[1]. So in otherwords this part of your code should look like this

if currentsession(0)<> currentsession(0)[1] or date<>date[1] then
begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

 

You must do this for BOTH the indicator AND the function.

 

I've tested it. It should be what you are after. ;)

 

BTW I use the 'currentsession' function to get my pivot point indicator to change values at the session times for Globex futures and Forex, not midnight. Works a treat.

Share this post


Link to post
Share on other sites
Just thought you might like this image. It looks promising.....

 

 

I don't see the promises...

Both got stopped out at various inopportune times;

if its not this one, its that one. :-(

Share this post


Link to post
Share on other sites

Thanks Simerann22, I was actually meaning, say if you lost an hour of data during a trading session because of ISP problems? but I think I see what your getting at anyway.

 

I use TS2000i so cannot use ELD's do you have the code for the gapless "function" that you could post?

 

Thanks

Share this post


Link to post
Share on other sites

gapless function:

 

 

 

 //**************** gapless day transitions - John McCormick May 2008********************
//***************** modified and made into function by Simon Kennedy 2009********************	
Inputs: GapCoef(numeric),	//1.0 to ignore gap -----> 0.5 half the gap -----> 0.0 to include gap
	Price(numeric);		//open,high,low or close

Vars:
RelPrice(0),	// Relative price
gap(0),			// the opening gap (modified by the gap coefficient)
Accum(0);		// The sum of all the daily gaps

if date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday

Gapless= Price - Accum
else Gapless=Price;

gapless_(function).txt

Share this post


Link to post
Share on other sites

GAPLESS PARABOLIC SAR.ELD (11.6 KB, 7 views)

 

Dear Simterann22

 

It's impossible to access to the code

 

Do you have TS 8.06.10.2525 ?

 

If so, all eld created after the 8.5 is not compatible with older versions

 

Would you mind to (always) post the text code for MC users ?

 

ThanX in advance

Share this post


Link to post
Share on other sites

Sure, I'll keep that in mind next time. BTW I do not use the Parabolic SAR indicator but if you have any requests I'll help where I can. I am still a newbie coder so all of these indicators are simply put together with a bit of logic and the good old 'cut and paste' :) I also like the gapless code and it's flexibility and common sense but I rarely trade gaps since I trade Forex.

 

Here is the PSAR code:

 

inputs: AfStep( 0.02), AfLimit( 0.2 ) ;
variables: oParCl( 0 ), oParOp( 0 ), oPosition( 0 ), oTransition( 0 ), Str( "" ), 
		gap(0),			// the opening gap (modified by the gap coefficient)
		GapCoef(1.0),	// Gap Coefficient
		Accum(0);		// The sum of all the daily gaps


Value1 = PSAR( AfStep, AfLimit, oParCl, oParOp, oPosition, oTransition ) ;

if currentsession(0)<> currentsession(0)[1] or date<>date[1] then
begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;


If bartype<=1 then
Plot1( oParCl + Accum, "ParCl" )
else
Plot1( oParCL,"ParCL");

{ Alert criteria }
if oTransition = 1 then 
	Alert( "Bullish reversal" ) 
else if oTransition = -1 then 
	Alert( "Bearish reversal" ) ;

{
Alternate alert criteria to write next reversal level to alert dialog box
Str = NumToStr( oParOp, 2 ) ;
if oPosition = 1 then
Alert( "At next bar, stop and reverse current long position at " + Str ) 
else if oPosition = -1 then
Alert( "At next bar, stop and reverse current short position at " + Str ) ;
}


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

The PSAR function (just a modified Para SAR function):

{ Parabolic Stop and Reverse multiple-output function; see MULTIPLE-OUTPUT FUNCTIONS 
 note below Gapless Version}

inputs: 
AfStep( numericsimple ), { acceleration factor step, generally set to 0.02 }
AfLimit( numericsimple ), { acceleration factor limit, generally set to 0.2 }
oParCl( numericref ), { final stop for today, diff from init stop on revrsl days }
oParOp( numericref ), { initial stop for tomorrow }
oPosition( numericref ), { position at end of day, can be 1 or -1 }
oTransition( numericref ) ; { revrsl days return 1 or -1, holding days return 0 }

variables: 
TradeHH( 0 ), 
TradeLL( 0 ), 
Af( 0 ) ;

// gapless day transitions - John McCormick May 2008

Vars:
RelO(0),		// Relative Open
RelH(0),		// Relative High
RelL(0),		// Relative low
RelC(0),		// Relative Close
gap(0),			// the opening gap (modified by the gap coefficient)
GapCoef(1.0),	// Gap Coefficient
Accum(0);		// The sum of all the daily gaps


if currentsession(0)<> currentsession(0)[1] or date<>date[1] then 
 begin
gap		=	GapCoef*(O-C[1]);
Accum	=	Accum+gap;   
 end;

if BarType<=1 then  //Valid only for Tick or Intraday	 

begin

	RelO	=	O-Accum;
	RelC	=	C-Accum;
	RelH	=	H-Accum;
	RelL	=	L-Accum;

	end

	else begin

	RelO	=	O;
	RelC	=	C;
	RelH	=	H;
	RelL	=	L;

end;


// Gapless - end




if CurrentBar = 1 then
begin
oParOp = RelH ;
oPosition = -1 ;
TradeHH = RelH ;
TradeLL = RelL ;
end ;

oTransition = 0 ;
if RelH > TradeHH then TradeHH = RelH ;
			{ UPDATE Highest High of current Trade }
if RelL  < TradeLL then TradeLL = RelL ;
			{ UPDATE Lowest Low of current Trade }

if oPosition = 1 then
			{ CHECK FOR INCOMING LONG POSITIONS }
begin
if RelL <= oParOp then
			{ ie, if OPENING STOP for this bar was breached }
	begin
	oPosition = -1 ;
	oTransition = -1 ;
			{ Rev pos & alert - this is a LONG TO SHORT reversal bar }
	oParCl = TradeHH ;
			{ Set the CLOSING STOP for this bar }
	TradeHH = RelH ;
			{ Re-initialize TradeHH with the current HIGH }
	TradeLL  = RelL ;
			{ Re-initialize TradeLL with the current LOW }
	Af = AfStep ;
			{ Re-initialize the Af }
	oParOp = oParCl + Af * ( TradeLL - oParCl ) ;
			{ Calculate the OPENING STOP for the next bar }
	if oParOp < RelH    then oParOp = RelH ;
			{ Make sure it is not below the current bar's high }
	if oParOp < RelH[1] then oParOp = RelH[1] ;
			{ or the previous bar's high }
	end
else
			{ ie, if this is a LONG TO LONG holding bar }
	begin
	oParCl = oParOp ;
			{ set CLOSING STOP for current bar = OPENING STOP for current bar }
	if TradeHH > TradeHH[1] and Af < AfLimit then
			{ calculate Af to use for OPENING STOP for next bar }
		Af = MinList( Af + AfStep, AfLimit ) ;
			{ maxing out at AfLimit }
	oParOp = oParCl + Af * ( TradeHH - oParCl ) ;
			{ calculate OPENING STOP for next bar }
	if oParOp > RelL    then oParOp = RelL ;
			{ Make sure it is not above the current bar's low }
	if oParOp > relL[1] then oParOp = RelL[1] ;
			{ or the previous bar's low }
	end ;
end
else
			{ CHECK FOR INCOMING SHORT POSITIONS }
begin
if relH >= oParOp then
			{ ie, if OPENING STOP for this bar was breached }
	begin
	oPosition = 1 ;
	oTransition = 1 ;
			{ Rev pos & alert - this is a SHORT TO LONG reversal bar }
	oParCl = TradeLL ;
			{ Set the CLOSING STOP for this bar }
	TradeHH = RelH ;
			{ Re-initialize TradeHH with the current HIGH }
	TradeLL  = RelL ;
			{ Re-initialize TradeLL with the current LOW }
	Af = AfStep ;
			{ Re-initialize the Af }
	oParOp = oParCl + Af * ( TradeHH - oParCl ) ;
			{ Calculate the OPENING STOP for the next bar }
	if oParOp > RelL    then oParOp = RelL;
			{ Make sure it is not above the current bar's low }
	if oParOp > RelL[1] then oParOp = RelL[1] ;
			{ or the previous bar's low }
	end
else
			{ ie, if this is a SHORT TO SHORT holding bar }
	begin
	oParCl = oParOp ;
			{ set CLOSING STOP for current bar = OPENING STOP for current bar }
	if TradeLL < TradeLL[1] and Af < AfLimit then
			{ calculate Af to use for OPENING STOP for next bar }
		Af = MinList( Af + AfStep, AfLimit ) ;
			{ maxing out at AfLimit }
	oParOp = oParCl + Af * ( TradeLL - oParCl ) ;
			{ calculate OPENING STOP for next bar }
	if oParOp < RelH    then oParOp = RelH ;
			{ Make sure it is not below the current bar's high }
	if oParOp < RelH[1] then oParOp = RelH[1] ;
			{ or the previous bar's high }
	end ;
end ;

PSAR = 1 ; { function return always 1, not used; only outputs used }

{
MULTIPLE-OUTPUT FUNCTIONS

A multiple-output function has two types of parameters or "inputs" - input parameters 
and input/output parameters.  The values of the input parameters are passed into the 
multiple-output function, but not modified by the function.  The values of the input/
output parameters are passed into the multiple-output function, modified by it, and 
the modified values are then inherited by - or output to - the calling routine.

The input/output parameters are often used for output purposes only, i.e., the 
incoming values are ignored.  The outputs are in addition to the function return.  In 
multiple-output functions, the function return is generally used to return an error 
code, though sometimes the return may simply be a dummy value.

The input/output parameters are declared with a "ref" suffix (such as "numericref") in 
the multiple-output function's declaration statements.  For further clarity, the names 
of the input/output parameters are generally prefixed with an "o" in the function as 
well as in all the routines that call the function.

The built-in single-return WRAPPER FUNCTIONS that call the multiple-output functions 
are specialized calling routines designed to offer simplified, alternate pathways to 
the functionality of the underlying multiple-output functions.  In the wrapper 
functions, the input/output parameters are declared as local variables and generally 
initialized to zero.  They are passed through to the multiple-output function without 
further modification.  After the call, the wrapper function picks out the single 
output of interest and assigns it as the return of the wrapper function.
}

{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

Edited by simterann22

Share this post


Link to post
Share on other sites

 

BTW I use the 'currentsession' function to get my pivot point indicator to change values at the session times for Globex futures and Forex, not midnight. Works a treat.

 

Here is the link to Floor Trader Pivots if anyone is interested:

 

http://www.traderslaboratory.com/forums/f46/floor-trader-pivots-session-times-6256.html#post69419

Edited by simterann22

Share this post


Link to post
Share on other sites
Thanks Simerann22, I was actually meaning, say if you lost an hour of data during a trading session because of ISP problems? but I think I see what your getting at anyway.

 

Dovetree I was thinking about your request regarding down time. You could try this code:

 

if currentsession(0)<>currentsession(0)[1] or date<>date[1] or [HIGHLIGHT GREEN]open<low[1] or open>high[1][/HIGHLIGHT GREEN] then 

 

I'm assuming that any gap would mean that the open is outside the range of the previous bar and that means during a down time as well. I'm still a newbie coder and I'm not sure if this would do the trick.

Share this post


Link to post
Share on other sites

Thanks Simterann22,

I will have a look at what you suggest. The one problem being currentsession is not a command in Prosuite 2000i( which I use).

 

Thanks again for an interesting code.

Share this post


Link to post
Share on other sites

I tried just the "open>high[1] or open<low[1]" without the currentsession or date coding and it works. So give it a go.

 

Goes to show you sometimes simple things work! LOL

 

Here is the currentsession function for you if you still want it:

 

{ Returns the session number of the session to which the current bar belongs; if the 
current bar does not belong to any session of the specified type, the function
returns -1. }

inputs:
SessionType( numericsimple ) ; { 0 = autodetect, 1 = regular}

variables:
Initialized( false ),
MySessionCount( 0 ),
BarLocation( 0 ),
BT( 0 ) ;

arrays:
SessionStart[ 1, 50 ]( 0 ),
SessionEnd[ 1, 50 ]( 0 ) ; { these arrays allow for a maximum 50 sessions per
 week }

CurrentSession = -1 ;

if Initialized = false then
begin
for Value1 = 0 to 1
	begin
	MySessionCount = SessionCount( Value1 ) ;
	for Value2 = 1 to MySessionCount
		begin
		SessionStart[ Value1, Value2 ] = MinutesIntoWeek( SessionStartDay(
		 Value1, Value2 ), SessionStartTime( Value1, Value2 ) ) ;
		SessionEnd[ Value1, Value2 ] = MinutesIntoWeek( SessionEndDay( Value1, 
		 Value2 ), SessionEndTime( Value1, Value2 ) ) ;
		end ;
	end ;
Initialized = true ;
BT = BarType ;
end ;

BarLocation = MinutesIntoWeek( DayOfWeek( Date ), Time ) ;
MySessionCount = SessionCount( SessionType ) ;
for Value1 = 1 to MySessionCount
begin
if ( BarLocation > SessionStart[ SessionType, Value1 ] or ( BT = 0 and
 BarLocation >= SessionStart[ SessionType, Value1 ] ) ) and BarLocation <=
 SessionEnd[ SessionType, Value1 ] then
	begin
	CurrentSession = Value1 ;
	Value1 = MySessionCount ; { this short circuits the loop }
	end ;
end ;


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

MinutesIntoWeek Function:

 

inputs: 
XDay( numericsimple), { pass in 0-6 for Sun-Sat }
XTime( numericsimple ) ; { pass in 24 hr HHMM time }

MinutesIntoWeek = 1440 * XDay + TimeToMinutes( XTime ) ;


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

TimeToMinutes Function:

 

inputs: XTime( numericsimple ) ;

Value1 = XTime * .01 ;

TimeToMinutes = 60 * IntPortion( Value1 ) + 100 * FracPortion( Value1 ) ;


{ ** Copyright (c) 2001 - 2009 TradeStation Technologies, Inc. All rights reserved. ** 
 ** TradeStation reserves the right to modify or overwrite this analysis technique 
    with each release. ** }

 

Hope that helps.

Edited by simterann22

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.