[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Volatility Filters- ??passing variables as inputs to: Include System



PureBytes Links

Trading Reference Links

{I'm looking for a way to vary the lookback period in a breakout program to
address the problem of trading in excessively low or excessively high
volatility.

Below- Tom Stridsman Futures Mag September 1998 addressing volatilty filters
in the context of develping his DBS model.

So, I try to adapt this filter of Tom's with an Include statement (calling a
subroutine.)  But I need to pass the input values to the Included System, and
of course I would like to do this with Tom's variables; VarA and VarB.  Won't
accept variables.  I've tried setting them equal to value1 and value2 but No.
I would appreciate some ideas.  
Thanks Charlie}

Inputs: Ceil(60), Flr(20),Switch1(0),Switch2(0);

Vars: X1(0), Y1(0), z(0),Z1(0),  X2(0), Y2(0), Z2(0),
	VarA(0), VarB(0), OldVarA(0),VarA2(0),OldVarA2(0),
	EntryL(0), EntryS(0), ExitL(0), ExitS(0);

Y1 = X1;
X1 = Stddev(Close, 30); {volatility}
Z1 = (X1 - Y1) / X1;		{Rate of Change}

Y2 = X2;
X2 = average(Truerange, 30);  {Xaverage better?}
Z2 = (X2 - Y2) / X2;

{Switch test*********************************************
Switch1sets value for Z1 which determines the percentage increase(+) or
decrease (-)in the volatility indicator which changes of the lookback period
- OldVarA*(1+Z) -  for the Entries.  Switch2 does the same thing for the Exits
- Old VarA2, Two differnet volatility calcs; std Dev Z1 and avgtruerange Z2 }

		If Switch1 = 0 then {use difference of stdDev&AvgTruerange, can produce
either a pos or neg value} 
				Z=Z2-Z1 {would think the "greater of" might be better?}
Else	If Switch1 = 1 then {use only the std Dev as volatility}
				Z=Z1
Else 	If Switch1 = 2 then {use only the avg truerange volatility}
				Z=Z2;
{*********************************************
VAr A is the entry lookback period adjustment, initialize here, Is this
MaxList array?}
If CurrentBar = 1 then begin
				VarA = 15;   
				VarA2=15;		
end;

OldVarA = VarA;
VarA = OldVarA * (1 + Z);
VarA = MaxList(VarA, Flr);  { What is this doing? looking thru the list and
overwriting the just produced VarA? }
VarA = MinList(VarA, Ceil);
{*********************************************
Var B is the Exit lookback period adjustment}

If Switch2 = 0 then VarB =  VarA*.5
else If Switch2 = 1 then begin {Again, the adjustment will be the difference
of the two volatilies,  > of?}
			Z = Z1 - Z2; 
{*********************************************}
OldVarA2 = VarA2;
VarA2 = OldVarA2 * (1 + Z);
VarA2 = MaxList(VarA2, Flr);
VarA2 = MinList(VarA2, Ceil);
VarB =  VarA2*.5;
end;

							{Substitute a different program here-----Buy tomorrow at Highest(High,
VarA) Stop;
																	Sell tomorrow at Lowest(Low, VarA) Stop;}

{?????????????????????????????????????????????}

IncludeSystem:"Charlie's Break",VarA,VarB;  {!!!!! ???? variable and arays not
allowed here}

{VarA is a Length/Lookback period , VarB is a length for a DMI trend check}
{?????????????????????????????????????????????}

{ I think I'll keep these to see if these exit signals help}

ExitLong tomorrow at Lowest(Low, VarB) Stop;
ExitShort tomorrow at Highest(High, VarB) Stop;