Traders Laboratory - View Single Post - Various Indicators (Squeeze,2FastMa's,etc)
View Single Post
  #6 (permalink)  
Old 04-15-2008, 07:45 AM
Blu-Ray's Avatar
Blu-Ray Blu-Ray is offline
Blu-Ray is or is not online

Trader Specs
 
Join Date: Nov 2006
Location: England
Posts: 395
Thanks: 89
Thanked 33 Times in 21 Posts
Re: Various Indicators (Squeeze,2FastMa's,etc)

Here's the code :

Inputs: SqLength(20),
Length1(9),
Length2(13),
Length3(21),
CounterTrendMode(false),
ChangeMidLine(false),
nK(1.5),
nBB(2),
AlertLine( 1 );


vars:
CCiValue(0),DownCT(0),UpC T(0),SDev(0),ATR(0),LHMul t(0),Denom(0),BBS_Ind(0);

if ChangeMidLine = false then begin
{MiddleLine - based on BB Squeeze}

if ( barnumber=1 ) then
Begin
If minmove <> 0 then
LHMult = pricescale/minmove;
end;


{-- Calculate BB Squeeze Indicator ----------------------}
ATR = AvgTrueRange(SqLength);
SDev = StandardDev(close, SqLength, 1);

Denom = (nK*ATR);
If Denom <> 0 then
BBS_Ind = (nBB * SDev) /Denom;

If BBS_Ind < Alertline then
SetPlotColor(1, Red)
else
SetPlotColor(1, Blue);


if BBS_Ind crosses below AlertLine then
SetPlotColor(1, green);

{-- Plot the Index & Alert Line -------------------------}
Plot1(0, "Squeeze");
end;

if ChangeMidLine = true then begin
{MiddleLine - based on a Hull Moving Average}

value1 = jthma(H/3+L/3+C/3,Length3);


if (Value1) > (Value1[1]) then
SetPlotColor(1, green);
if (Value1) < (Value1[1]) then
SetPlotColor(1, red);

Plot1(0, "Squeeze");
end;


{Histogram - based on two ema's of Hull MA's}

value3 = xaverage(jthma(close, length1),Length2) - xaverage( jthma(close, length2), length2+7 );

plot4(value3,"DiffHisto") ;

if value3 > 0 then
if value3 > value3[1] then
setplotcolor(4,green)
else
setplotcolor(4,darkgreen) ;

if value3 < 0 then
if value3 < value3[1] then setplotcolor(4,red)
else
setplotcolor(4,darkred);



{++++++++++++++++++++++++ +++++++++++++++++++++++++ +++++++++++++++++++++++++ ++++++++++}



{ Counter Trend Mode - Based on when cci(13) gets below 50 and stays dark red until going back above 100}
if CounterTrendMode = true then begin

CCiValue = CCi(13);

Condition1 = ccivalue[1] > 50;
Condition2 = CCivalue < 50;
Condition3 = CCivalue[1] < 100;
Condition4 = CCiValue > 100;
Condition5 = value3 > 0;
Condition6 = value3[1] > 0;
Condition7 = value3[2] > 0;
Condition8 = ccivalue < 100;


if Condition1 and Condition2 and Condition5 and condition6 and condition7 then begin
setplotcolor(4,DarkRed);
DownCT = 1;
end;

if DownCT = 1 and value3 < 0 then DownCT =0;


if DownCT = 1 and Condition8 and Condition5 then setplotcolor(4,darkred);

if DownCT = 1 and Condition3 and Condition4 then begin
setplotcolor(4,green);
DownCT = 0;
end;

Condition11 = ccivalue[1] < -50;
Condition12 = CCivalue > -50;
Condition13 = CCivalue[1] >- 100;
Condition14 = CCiValue < -100;
Condition15 = value3 < 0;
Condition16 = value3[1] < 0;
Condition17 = value3[2] < 0;
Condition18 = ccivalue >-100;


if Condition11 and Condition12 and Condition15 and condition16 and condition17 then begin
setplotcolor(4,DarkGreen) ;
UpCT = 1;
end;

if UpCT = 1 and value3 > 0 then UpCT =0;


if UpCT = 1 and Condition18 and Condition15 then setplotcolor(4,darkgreen) ;

if UpCT = 1 and Condition13 and Condition14 then begin
setplotcolor(4,Red);
UpCT = 0;
end;


end;


Cheers

Blu-Ray

__________________
Remember - Take the path of least resistance.
Reply With Quote