// Go to www.woodiescciclub.com to learn everything about this system.
// You must be a registered user to see the images and downloads.
///////////////////////////////
// Setup Axes and Grid section (right click on chart panel, click on Parameters):
// Scaling: Custom , Min=-250 Max=250
// Show Date Axis = Yes , Show Middle Lines = No
///////////////////////////////
// To activate the timer properly, make sure the following is set:
// click on Tools==>Preferences==>Intraday....
// make sure "Allign minute bars to market hours" is checked...
// make sure "Start time of interval" is checked...
// make sure "Override: Weekly/monthly bars use day of last trade" is checked.
///////////////////////////////
// Tic/PIP values: YM=1.0, ER2=0.10, NQ=0.25, EUR/USD=.0001, USD/JPY=0.01, Stocks=0.01
///////////////////////////////
// Rangebar Settings :
// ER2 1.50
// YM 25
// ES 3
// NQ 3.75
// DAX 5
// ZG 1.5
///////////////////////////////
// Discalimer: For educational purposes only. Trade at your own risk.
///////////////////////////////
// Timer
TTMperiod = 6;
Low_ma = EMA(L, TTMperiod);
High_ma = EMA(H, TTMperiod);
Low_third = (High_ma - Low_ma) / 3 + Low_ma;
High_third = 2 * (High_ma - Low_ma) / 3 + Low_ma;
tempnum = Now( 4 ) - TimeNum();
TimeRem = Interval() - ((int(tempnum[BarCount - 1] / 100) * 60) + (tempnum[BarCount - 1] - int(tempnum[BarCount - 1] / 100) * 100));
if (TimeRem[BarCount - 1] < 0) TimeRem = 0;
MinuteVar = int(TimeRem / 60);
SecondsVar = int(frac(TimeRem / 60) * 60);
if (TimeRem[BarCount - 1] > 60)
{
TitleTimeRem = EncodeColor(colorWhite) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar;
}
else if (TimeRem[BarCount - 1] > 20)
{
TitleTimeRem = EncodeColor(colorYellow) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar;
}
else
{
TitleTimeRem = EncodeColor(colorRed) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar;
}
// Background color
SetChartBkColor(ParamColor("Panel color ",colorPaleBlue));
// CCI colors
zcolor= ParamColor("WCCI color",colorBlack);
z6color= ParamColor("TCCI color",colorBrown);
// CCI periods
zperiod=Param("WCCI period",14,0,100);
z = CCI(zperiod);
z6period=Param("TCCI period",6,0,1000);
z6 = CCI(z6period);
// Tic/PIP value
TicMult= Param("Tic multiplier(ER2=10,YM=1,ES=4,FOREX=1)",1,0,1000000);
TicDiv= Param("Tic or PIP value(ER2=0.1,YM=1,FOREX=1)",1,0,1000000);
// Rangebar interval
rbint= Param("Rangebar interval:(YM=25.0,AB=1.5,NQ=3.75,ES=3.0)",1.0,0.25,1000000);
// Rangebar counter
rbcounter= round(((rbint-(H-L))) * ticmult);
rbcounterpercent= round((rbcounter/(rbint * ticmult))*100);
// Timer/counter title
timercode= Param("Timer:(minutes=1,rangebar=2)",1,1,2);
timetitle= WriteIf(timercode==1,TitleTimeRem, EncodeColor(colorWhite) + "Countdown " + rbcounter + " (" + rbcounterpercent + "%)");
// Spread
spread= Param("Spread (included in stop)",0,0,1000000);
// Stop value
stopval= Param("Stop above/below entry bar",2,0,1000000);
// Plot grids
PlotTheGrids = ParamToggle("Plot grids","No|Yes",0);
if (PlotTheGrids ==1)
{
PlotGrid(0);
PlotGrid(-100);
PlotGrid(100);
PlotGrid(-200);
PlotGrid(200);
}
// Angle variables
PI = atan(1.00) * 4;
periods = 30;
HighHigh = HHV(H, periods);
LowLow = LLV(L, periods);
range = 25 / (HighHigh - LowLow) * LowLow;
// EMA34 Angle
EMA34 = EMA(C,34);
x1_EMA34 = 0;
x2_EMA34 = 1;
y1_EMA34 = 0;
y2_EMA34 = (Ref(EMA34, -1) - EMA34) / Avg * range;
c_EMA34 = sqrt((x2_EMA34 - x1_EMA34)*(x2_EMA34 - x1_EMA34) + (y2_EMA34 - y1_EMA34)*(y2_EMA34 - y1_EMA34));
angle_EMA34 = round(180 * acos((x2_EMA34 - x1_EMA34)/c_EMA34) / PI);
angle_EMA34 = IIf(y2_EMA34 > 0, - angle_EMA34, angle_EMA34);
// LSMA25 Angle
LSMA25 = LinearReg(C, 25 );
x1_LSMA25 = 0;
x2_LSMA25 = 1;
y1_LSMA25 = 0;
y2_LSMA25 = (Ref(LSMA25, -1) - LSMA25) / Avg * range;
c_LSMA25 = sqrt((x2_LSMA25 - x1_LSMA25)*(x2_LSMA25 - x1_LSMA25) + (y2_LSMA25 - y1_LSMA25)*(y2_LSMA25 - y1_LSMA25));
angle_LSMA25 = round(180 * acos((x2_LSMA25 - x1_LSMA25)/c_LSMA25) / PI);
angle_LSMA25 = IIf(y2_LSMA25 > 0, - angle_LSMA25, angle_LSMA25);
// Color the bars for Woodies Trend Following
function Consecutive( array )
{
return BarsSince( NOT( array ) );
}
function Occurrences( array , period )
{
return Sum( array, period );
}
array = z;
HighBars = Consecutive( array > 0 );
LowBars = Consecutive( array < 0 );
UpCondition = BarsSince( HighBars >= 6 AND Occurrences( array > 100 , 5 ) > 0 );
DnCondition = BarsSince( LowBars >= 6 AND Occurrences( array < -100 , 5 ) > 0 );
UpTrend = ( array > 0 ) AND ( UpCondition < DnCondition );
DnTrend = ( array < 0 ) AND ( UpCondition > DnCondition );
TrTrend = ( HighBars >= 5 AND NOT UpTrend ) OR ( LowBars >= 5 AND NOT DnTrend );
Color = IIf( UpTrend, colorBlue, IIf( DnTrend, colorRed, IIf( TrTrend, colorYellow, colorGrey40 ) ) );
// CCI Line
Plot(round(z),"WCCI", zcolor, styleLine | styleThick);
// Turbo CCI
Plot(round(z6),"TCCI", z6color, styleLine);
// CCI Histogram
Plot( array, "", colorDefault, styleLine | styleThick | styleNoLabel);
Plot( array, "", Color, styleHistogram | styleThick| styleNoLabel);
// Zero line 25lsma
Plot(0,"", IIf(C > LSMA25,colorBrightGreen,IIf(C < LSMA25,colorRed,colorTeal)), styleLine | styleThick | styleNoLabel);
// Plot the Mock CZI on the 100s
ColorANGLE_EMA = IIf(angle_EMA34 >=5,colorTurquoise,
IIf(angle_EMA34 <5 AND angle_EMA34 >=3.57,colorDarkGreen,
IIf(angle_EMA34 <3.57 AND angle_EMA34 >=2.14,colorPaleGreen,
IIf(angle_EMA34 <2.14 AND angle_EMA34 >=.71,colorLime,
IIf(angle_EMA34 <=-1*5,colorDarkRed,
IIf(angle_EMA34 >-1*5 AND angle_EMA34 <=-1*3.57,colorRed,
IIf(angle_EMA34 >-1*3.57 AND angle_EMA34 <=-1*2.14,colorOrange,
IIf(angle_EMA34 >-1*2.14 AND angle_EMA34 <=-1*.71,colorLightOrange,colorYellow))))))));
Plot(100,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel);
Plot(-100,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel);
// Plot the Mock Sidewinder on the 200s
SW = IIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), IIf(angle_LSMA25 > 0, 2, -2),
IIf((abs(angle_EMA34) >= 0) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 5), IIf(angle_LSMA25 > 0, 1, -1), 0));
ColorSW = IIf(abs(SW) == 2, colorBrightGreen,
IIf(abs(SW) == 1, colorYellow, colorRed));
Plot(200,"", ColorSW, styleLine | styleThick | styleNoLabel);
Plot(-200,"", ColorSW, styleLine | styleThick | styleNoLabel);
// CCI Points
CCipointmove= z-Ref(z,-1);
CCIpointmovetitle= WriteIf(abs(CCipointmove)<15,EncodeColor(colorRed) + "\n" + "DIFF " +
abs(round(CCipointmove)),WriteIf(abs(CCipointmove)>=15 AND abs(CCipointmove)<20,EncodeColor(colorYellow) + "\n" + "DIFF " +
abs(round(CCipointmove)),WriteIf(abs(CCIpointmove)>=20,EncodeColor(colorBrightGreen) + "\n" + "DIFF " +
abs(round(CCipointmove)),"")));
// Price Panel
Lastpricetitlehi= WriteIf(H>Ref(H,-1),EncodeColor(colorBrightGreen) + Ref(H,-1) + " " + H , EncodeColor(colorWhite)+ Ref(H,-1) + " " + H);
Lastpricetitlelo= WriteIf(L<Ref(L,-1),EncodeColor(colorRed) + Ref(L,-1) + " " + L , EncodeColor(colorWhite) + Ref(L,-1) + " " + L);
Closecolor=WriteIf(C==H AND H>Ref(H,-1),EncodeColor(colorBrightGreen),WriteIf(C==L AND L<Ref(L,-1),EncodeColor(colorRed),EncodeColor(colorWhite)));
// Stop in
Longbar= L+rbint;
Shortbar= H-rbint;
sstoptitle=WriteIf(timercode==2, EncodeColor(colorBlue) + "\n" + "Stop In Long " + Longbar + EncodeColor(colorRed) + "\n" + "Stop In Short " + Shortbar + "\n","");
// Stop out
stopCode=ParamToggle("Display stop-out ","No|Yes",0);
StopLong1= C -(L - (stopval*ticdiv) - (spread*ticdiv));
stoplong1c=C-stoplong1;
stoplong= round(StopLong1/ticdiv);
StopShort1= (H + (stopval*ticdiv) + (spread*ticdiv)) - C;
stopshortc= C+StopShort1;
StopShort= round(StopShort1/ticdiv);
stoptitle= WriteIf(stopcode==1,EncodeColor(colorBlue) + "\n" + "Stop Out Long " + stoplong1c + " " + stoplong + "\n" +
EncodeColor(colorRed) + "Stop Out Short " + stopshortc + " " + stopshort + "\n","");
// Title
Title = "\n" + "" + EncodeColor(colorWhite) + Date() + "\n" + "\n" +
timetitle + "\n" + "\n" + Lastpricetitlehi + "\n" + Closecolor + C +
"\n" + Lastpricetitlelo + "\n" + CCIpointmovetitle + "\n" + sstoptitle + stoptitle;