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.ELDFetching info...

@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.ELDFetching info...

20080602233304GL_ATR.ELDFetching info...

20090606150816DMI_GAPLESS.ELDFetching info...

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.ELDFetching info...

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.ELDFetching info...

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
  simterann22 said:
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).txtFetching info...

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
  simterann22 said:

 

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
  dovetree said:
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.


  • Topics

  • Posts

    • My wife Robin just wanted some groceries.   Simple enough.   She parked the car for fifteen minutes, and returned to find a huge scratch on the side.   Someone keyed her car.   To be clear, this isn’t just any car.   It’s a Cybertruck—Elon Musk's stainless-steel spaceship on wheels. She bought it back in 2021, before Musk became everyone's favorite villain or savior.   Someone saw it parked in a grocery lot and felt compelled to carve their hatred directly into the metal.   That's what happens when you stand out.   Nobody keys a beige minivan.   When you're polarizing, you're impossible to ignore. But the irony is: the more attention something has, the harder it is to find the truth about it.   What’s Elon Musk really thinking? What are his plans? What will happen with DOGE? Is he deserving of all of this adoration and hate? Hard to say.   Ideas work the same way.   Take tariffs, for example.   Tariffs have become the Cybertrucks of economic policy. People either love them or hate them. Even if they don’t understand what they are and how they work. (Most don’t.)   That’s why, in my latest podcast (link below), I wanted to explore the “in-between” truth about tariffs.   And like Cybertrucks, I guess my thoughts on tariffs are polarizing.   Greg Gutfield mentioned me on Fox News. Harvard professors hate me now. (I wonder if they also key Cybertrucks?)   But before I show you what I think about tariffs… I have to mention something.   We’re Headed to Austin, Texas This weekend, my team and I are headed to Austin. By now, you should probably know why.   Yes, SXSW is happening. But my team and I are doing something I think is even better.   We’re putting on a FREE event on “Tech’s Turning Point.”   AI, quantum, biotech, crypto, and more—it’s all on the table.   Just now, we posted a special webpage with the agenda.   Click here to check it out and add it to your calendar.   The Truth About Tariffs People love to panic about tariffs causing inflation.   They wave around the ghost of the Smoot-Hawley Tariff from the Great Depression like it’s Exhibit A proving tariffs equal economic collapse.   But let me pop this myth:   Tariffs don’t cause inflation. And no, I'm not crazy (despite what angry professors from Harvard or Stanford might tweet at me).   Here's the deal.   Inflation isn’t when just a couple of things become pricier. It’s when your entire shopping basket—eggs, shirts, Netflix subscriptions, bananas, everything—starts costing more because your money’s worth less.   Inflation means your dollars aren’t stretching as far as they used to.   Take the 1800s.   For nearly a century, 97% of America’s revenue came from tariffs. Income tax? Didn’t exist. And guess what inflation was? Basically zero. Maybe 1% a year.   The economy was booming, and tariffs funded nearly everything. So, why do people suddenly think tariffs cause inflation today?   Tariffs are taxes on imports, yes, but prices are set by supply and demand—not tariffs.   Let me give you a simple example.   Imagine fancy potato chips from Canada cost $10, and a 20% tariff pushes that to $12. Everyone panics—prices rose! Inflation!   Nope.   If I only have $100 to spend and the price of my favorite chips goes up, I either stop buying chips or I buy, say, fewer newspapers.   If everyone stops buying newspapers because they’re overspending on chips, newspapers lower their prices or go out of business.   Overall spending stays the same, and inflation doesn’t budge.   Three quick scenarios:   We buy pricier chips, but fewer other things: Inflation unchanged. Manufacturers shift to the U.S. to avoid tariffs: Inflation unchanged (and more jobs here). We stop buying fancy chips: Prices drop again. Inflation? Still unchanged. The only thing that actually causes inflation is printing money.   Between 2020 and 2022 alone, 40% of all money ever created in history appeared overnight.   That’s why inflation shot up afterward—not because of tariffs.   Back to tariffs today.   Still No Inflation Unlike the infamous Smoot-Hawley blanket tariff (imagine Oprah handing out tariffs: "You get a tariff, and you get a tariff!"), today's tariffs are strategic.   Trump slapped tariffs on chips from Taiwan because we shouldn’t rely on a single foreign supplier for vital tech components—especially if that supplier might get invaded.   Now Taiwan Semiconductor is investing $100 billion in American manufacturing.   Strategic win, no inflation.   Then there’s Canada and Mexico—our friendly neighbors with weirdly huge tariffs on things like milk and butter (299% tariff on butter—really, Canada?).   Trump’s not blanketing everything with tariffs; he’s pressuring trade partners to lower theirs.   If they do, everybody wins. If they don’t, well, then we have a strategic trade chess game—but still no inflation.   In short, tariffs are about strategy, security, and fairness—not inflation.   Yes, blanket tariffs from the Great Depression era were dumb. Obviously. Today's targeted tariffs? Smart.   Listen to the whole podcast to hear why I think this.   And by the way, if you see a Cybertruck, don’t key it. Robin doesn’t care about your politics; she just likes her weird truck.   Maybe read a good book, relax, and leave cars alone.   (And yes, nobody keys Volkswagens, even though they were basically created by Hitler. Strange world we live in.) Source: https://altucherconfidential.com/posts/the-truth-about-tariffs-busting-the-inflation-myth    Profits from free accurate cryptos signals: https://www.predictmag.com/       
    • No, not if you are comparing apples to apples. What we call “poor” is obviously a pretty high bar but if you’re talking about like a total homeless shambling skexie in like San Fran then, no. The U.S.A. in not particularly kind to you. It is not an abuse so much as it is a sad relatively minor consequence of our optimism and industriousness.   What you consider rich changes with circumstances obviously. If you are genuinely poor in the U.S.A., you experience a quirky hodgepodge of unhelpful and/or abstract extreme lavishnesses while also being alienated from your social support network. It’s about the same as being a refugee. For a fraction of the ‘kindness’ available to you in non bio-available form, you could have simply stayed closer to your people and been MUCH better off.   It’s just a quirk of how we run the place and our values; we are more worried about interfering with people’s liberty and natural inclination to do for themselves than we are about no bums left behind. It is a slightly hurtful position and we know it; we are just scared to death of socialism cancer and we’re willing to put our money where our mouth is.   So, if you’re a bum; you got 5G, the ER will spend like $1,000,000 on you over a hangnail but then kick you out as soon as you’re “stabilized”, the logistics are surpremely efficient, you have total unchecked freedom of speech, real-estate, motels, and jobs are all natural healthy markets in perfect competition, you got compulsory three ‘R’’s, your military owns the sky, sea, space, night, information-space, and has the best hairdos, you can fill out paper and get all the stuff up to and including a Ph.D. Pretty much everything a very generous, eager, flawless go-getter with five minutes to spare would think you might need.   It’s worse. Our whole society is competitive and we do NOT value or make any kumbaya exception. The last kumbaya types we had werr the Shakers and they literally went extinct. Pueblo peoples are still around but they kind of don’t count since they were here before us. So basically, if you’re poor in the U.S.A., you are automatically a loser and a deadbeat too. You will be treated as such by anybody not specifically either paid to deal with you or shysters selling bejesus, Amway, and drugs. Plus, it ain’t safe out there. Not everybody uses muhfreedoms to lift their truck, people be thugging and bums are very vulnerable here. The history of a large mobile workforce means nobody has a village to go home to. Source: https://askdaddy.quora.com/Are-the-poor-people-in-the-United-States-the-richest-poor-people-in-the-world-6   Profits from free accurate cryptos signals: https://www.predictmag.com/ 
    • TDUP ThredUp stock, watch for a top of range breakout above 2.94 at https://stockconsultant.com/?TDUP
    • TDUP ThredUp stock, watch for a top of range breakout above 2.94 at https://stockconsultant.com/?TDUP
    • TDUP ThredUp stock, watch for a top of range breakout above 2.94 at https://stockconsultant.com/?TDUP
×
×
  • Create New...

Important Information

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