Turtles CCI

VJAY

Well-Known Member
#71
Dear rajputz,
I backtested minifty of last 20 days with 5 min using bar reply ,no trade comes as per rules!it's surprice to me....how can you find trades from bulk of scrips?Please share it with us....
 

crown

Well-Known Member
#72
rajput bhai
jo aapne cci alf code diya tha wo amibroker me daal diya hai
now bhai, one little querry
there are some numbers appearing in the alf like 1 2 3 4 5
can you plz explain what these numbers denoting
waise I am reading the cci e book that you have given
thanks bhai
I have some of my opinion to share, just wanted to seek ur permission that if I can share my amateur views on ur thread
thanks again bhai
 

rajputz

Well-Known Member
#73
Dear rajputz,
I backtested minifty of last 20 days with 5 min using bar reply ,no trade comes as per rules!it's surprice to me....how can you find trades from bulk of scrips?Please share it with us....
Hi VJAY,

it all depends upon the opportunity and the number of stocks or indeces you are scanning. Some time you may miss the opportunity. But if you check only a single stock regularly then you wont get much of trades. Cause the price of stocks does not keep on breaking. Some times it moves steadily, some times range bound. So we need to scan heavy volatile stocks. With heavy volumes. I have around 80 stocks which i keep on scanning. If i find a stock or an index trying to break, i wait for it there to fullfill or the requirements.

Although i am trying to get rid of this problem also. Some thing is in my mind and i am testing it. Whenever it works i will post it here. Untill then keep on scanning. May be breakout is there in 5 minute or 15 minutes.

As soon as i get a hitch i will post it here.
 

rajputz

Well-Known Member
#74
rajput bhai
jo aapne cci alf code diya tha wo amibroker me daal diya hai
now bhai, one little querry
there are some numbers appearing in the alf like 1 2 3 4 5
can you plz explain what these numbers denoting
waise I am reading the cci e book that you have given
thanks bhai
I have some of my opinion to share, just wanted to seek ur permission that if I can share my amateur views on ur thread
thanks again bhai
Share whatever you feel crown. I have just started this thread to know all the possibilities. Single man cant do that. So fire up.

these 1 2 3 4 5 are some pattern that it detects automatically. You shouldnt concentrate on them as they are code generated where as pattern requires human mind and experience, and many hidden factors which cant be built into a code. Just ignore the numbers. That is the main reason, when linkon sir told me about them, i didnt remembered it.
 
Last edited:

vinodkiyer

Well-Known Member
#75
Here afl for turtle pvt breakout.
I have coded in such a way that if h pivot level breaks and simultaneously cci 14 crosses +100 and cci6 and 14 points upwards then buy and vice versa with shorts with cci -100 downwards.
Take profit when cci crosses back 100 downwards for buy and -100 upwards for short.
I have added money management and also profit/loss per trade in explorer.
In explorer u can see entry and exit and p/l and quantity to trade.
Rajputz, please advise if the entry exit rules are correct or not otherwise we improve.
 

crown

Well-Known Member
#76
Share whatever you feel crown. I have just started this thread to know all the possibilities. Alone man cant do that. So fire up.

these 1 2 3 4 5 are some pattern that it detects automatically. You shouldnt concentrate on them as they are code generated where as pattern requires human mind and experience, and many hidden factors which cant be built into a code. Just ignore the numbers. That is the main reason, when linkon sir told me about them, i didnt remembered it.
Thanks for the permission Rajput bhai

now coming to the point
yesterday and day before yesterday, I was only and only occupied wid understanding CCI and

its implementations on the chart on the basis of the ebook that you provided to me and with

googling. And, I observed that CCI has following charactersticks:

First, it did not take volume into account at all and has its only weightage on the price of the

commodity or share.

Second, it calculate its points on the basis of typical price of the commodity
Typical Price (TP) = (H+L+C)/3 where H = high, L = low, and C = close
and in that way the balanced price of the commodity after a given interval (minutes, hours or

days etc.) is calculated; and that shows that the buyers and sellers have agreed to that price

unanimously. The importance of taking typical price appears to be in the point that it caters to

the comfort of both buyers (low price ) and sellers (high price).
Then the average i.e. SMATP (simple moving average of typical price) for a specific period

(example 14 days or candles) is generated on the basis of the typical price. and then the

mean deviation is calculated. The mean deviation is basically the average of the difference

between SMATP and the actual price i.e. Typical price.
Following example denotes calculatio of mean deviation.
typical price for 6 intervals of time- 12, 14, 10, 9, 13, 15
average (SMTPA)- (12+14+10+9+13+15)/6 = 73/6 = 12.16
so the average comes out to be 12.16
then how much these daily prices are actually deviating from this average price is counted

and their average is calculated which is the mean deviation.
diff between first period 12.16 - 12 = 0.16
second period = 12.16 -14 = 1.84
third period = 12.16 - 10 = 2.16
fourth period = 12.16 - 9 = 3.16
fifth period = 12.16 - 13 = 0.84
sixth period = 12.16 - 15 = 2.84
average of these differences
(0.16+1.84+2.16+3.16+0.84+2.84)/6 = 11/6 = 1.83
this mean deviation denote that the price can easily deviate 1.83 in either side of the average

price; and also that no trade should be taken in either side of smpta till the difference of 1.83.
Or in other simple words if the smtpa is 12.16 for a given period and the mean deviation is 1.83; one should not enter long or short between 10.33 (12.16-1.83) and 13.99 (12.16+1.83)

because this price range is based upon the mean deviation which can take place on average basis.
muje nahi pata ki jo mene likha hai wo kisi kaam ka hai ya nahi
par meri samajh me jo aaya mene likh diya
ab iska koi fayada hai ya nahi, ye aap batao
thanks
 
D

darkstar

Guest
#77
I have been using Woodies CCI for long time. It has given me very nice results in intraday trading. But from last few months, i have got my back apart from scalping and now my try is to get one good trade every day. A single or two good trades with some nice moves.

So in order to accomplish this i looked into the CCI method once again. While working on it, i got an idea to collaborate it with Turtles method of pivot based trading system. When ever i was working with the Turtles pivot method, the one point i noticed was that Whenever price breaks and close above or below the higher or lower pivot, the price continues in that direction for atleast 2+ bars. These bars were mostly positive and never giving wrong trades. Even if price reverted back into the channel (false breakout), then the loss was minimal. But problem was still there as i dont want the loosing trades. Entry was not yet my problem, exit was. So i looked into my CCI system, as i knw that it can give me good exit. It gives good exit, then any other system. gets us out two or three candles before rest of the world. Then i tried over it. And the results were fabulous. Then i tried to comprise it with the entry also. And it worked fine then also. but still some whipsaws were there as i needed to tweak the time frame most suited for the good entries and exit. Untill now i havent come out with perfect solution for that, and using it on 5 min and 15 min time frame. Bigger time frames were not good for intraday and also missed the major moves. And i wanted to keep it simply for intraday. Till now the results are good.

Reasoning: - Pivot high and pivot low are the point of opposite forces at the moment. Price tries to remain between it, when there is indecision. Once that indecision is broken with good volumes, the traders have made there mind to buy it higher, or sell it lower. Range is broken, and we expect further upward movement and further downward movement. CCI being a good momentum indicator comprised with it can give good results. As cci gives us the direction of the momentum and that too earlier then other system, plus the force of demand broken in the same direction by turtles, gives sound reasoning to the approach. Both Indicator based, and reasoning based.

Method: -


Entry

Turtle Pivots: -

We look for Closing of the price above or below the higher or lower pivot. That means we have to get prepared for entry 20 seconds before the bar closes. After that we have to take a look at the CCI panel.

CCI panel: -

1. We look for trend reversal pattern, if lower or higher pivot failed to break and price move to opposite direction. Or CCI changing momentum smoothly.

2. We look for trend continuation pattern, in the direction of the pivot break.

The one must condition to meet is that for Buy side, CCI must be between 0 to +100 when pivot high is broken. When in sell side, CCI must be between 0 - -100 when pivot low is broken. If price is beyond that level, we dont take the trade.

Some times the breakout of pivot is done by a large candle. In that case, CCI wildly goes out of 100 area into 200 areas. In that case we check the volume plus range of the price bar. Plus Direction of CCI pointing in that direction. And it should be CCI's first or second bar in that direction.



Exit

CCI panel: -
In buy side, when CCI crosses the +100 line from upside. But if the price is still going up, while CCI is coming down, then we wait for CCI crossing 0 Line. Most probably in this case when CCi is going down and price is moving up, the cci will also revert and we can exit at next crossing of +100 line. Vice Versa For sell Side.


Being the Momentum Indicator both of these in combination brings good results, and the trades are breakout trades.

For those who doesnt know abt the patterns of CCI i am posting the book in pdf version. You can download it below: -

http://www.mediafire.com/?izmgo3zyazx


Amibroker Code for Price Chart of Turtles Pivot: -

Code:
_SECTION_BEGIN("Simple Pivot based Trading System");

// User defined parameters.

GraphXSpace = 10; //defines how much extra space should be added above and below graph line (in percent).

dist = 0.25*ATR(10); 
Capital=Param("Total capital",100000,10000,1000000,1000);
drawdown=Param("Max. loss per trade as % of Capital", 1.0,0.5,25.0,0.1);
room=Param("Room for S/L as % of Pivot value",0.001,0.001,0.02,0.001);

SetChartBkColor(ParamColor("Panel color ",colorBlack)); 
// Now calculate pivots. 

PH= ValueWhen(
(Ref(H,-2) > Ref(H, -4)) AND
(Ref(H,-2) > Ref(H, -3)) AND
(Ref(H,-2) > Ref(H, -1)) AND
(Ref(H,-2) > H), Ref(H,-2));

PL= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));

// filter lines

phfilter=PH+(room*PH);
plfilter=PL-(room*PL);

//Uncomment following code if you wish to see the pivot lines.
//Plot(Ref(PH,2), "UpPivot", ParamColor("UpPivot Color",colorRed), styleDashed);
//Plot(Ref(PL,2), "DownPivot",ParamColor("DownPivot Color",colorGreen), styleDashed);

Plot(Ref(Phfilter,2), "Upfilter", ParamColor("upfilter Color",colorBlue), styleLine);
Plot(Ref(Plfilter,2), "Downfilter",ParamColor("dnfilter Color",colorOrange), styleLine);


//Plot(Ref(UpFractal,2), "Up Fractal", ParamColor("Up Fractal Color",colorRed),8);
//Plot(Ref(DownFractal,2), "Down Fractal",ParamColor("Down Fractal Color",colorGreen),8);



/* 
for (a=4;a<BarCount;a++)
{
if ((H[a-2] >= H[a-4]) AND
(H[a-2] >= H[a-3]) AND
(H[a-2] >= H[a-1]) AND
(H[a-2] >= H[a]))
PlotText("PH \n"+H[a-2], a-2, H[a-2], colorGreen);

if ((L[a-2] <= L[a-4]) AND
(L[a-2] <= L[a-3]) AND
(L[a-2] <= L[a-1]) AND
(L[a-2] <= L[a]))
PlotText("PL \n"+L[a-2], a-2, L[a-2]-dist[a-2], colorRed);
}
*/
//Condition for buy : Enter when Close crosses latest pivot high.
Buy = C> (PH+(room*PH));

initialStopBuy=Ref(PL,2)-(Ref(PL,2)*room/100);
trailStopBuy=IIf(C>PH,Ref(initialStopBuy,-1),initialStopBuy);

newStopBuy=trailStopBuy;

BuyLimitCapital=int(Capital/C);
SLbuy=round(C-initialStopBuy);
BuyLimitSL=int((Capital*drawdown)/(100*SLbuy));

//Condition for sell : Exit when previous pivot low is cracked.
Sell = C< (PL-(room*PL));

Buy = ExRem(Buy,Sell);
Sell= ExRem(Sell,Buy);

//Short = Sell;
//Cover = Buy;

//Short=ExRem(Short,Cover);
//Cover=ExRem(Cover,Short);

shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ),0, IIf( Buy, Low, High ) );


_SECTION_END();
/*
Q=Param("% Change",0.2,0.1,10,0.1);
Z= Zig(C ,q ) ;
HH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2)));
LH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(Z,q,1 ) <Peak(Z,q,2)));
HL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2)));
LL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) <Trough(Z,q,2)));
GraphXSpace = 5;
dist = 0.5*ATR(20); 

for( i = 0; i < BarCount; i++ ) 
{ 
if( HH[i] ) PlotText( "HH  \n"+Ref(H[i],-1), i, H[ i ]+dist[i], colorBlack,colorGreen );
if( LH[i] ) PlotText( "SAR \n"+Ref(H[i],-1), i, H[ i ]+dist[i], colorBlack, colorRed ); 
if( HL[i] ) PlotText( "SAR \n"+Ref(L[i],-1), i, L[ i ]-dist[i], colorBlack, colorGreen );
if( LL[i] ) PlotText( "LL  \n"+Ref(L[i],-1), i, L[ i ]-dist[i], colorBlack,colorRed );

}
*/

SL = ( HHV( H, 26 ) + LLV( L, 26) )/2;
TL = ( HHV( H, 9 ) + LLV( L, 9 ) )/2;
Plot (TL, "Stop line", colorAqua,styleThick); 

breakeven = Param ("brokerage",2,0,500,0.05);


risk_long = PH -SL-breakeven;
risk_short = SL - PL-breakeven;
range = PH-PL;
key = range / 2;
Short_tgt1 = PL- range*1.68;
Short_tgt2 = PL- range*2.68;
Long_tgt1 = PH + range*1.68;
Long_tgt2 = PH + range*2.68;

Color_buy = IIf (Close > sl AND Close > TL, colorGreen, IIf (Close < sl AND Close < TL,colorRed,colorYellow));
PlotOHLC( Open, High, Low, Close, "", Color_buy, styleBar ); 


 Title = EncodeColor(colorWhite)+ "RAJPUTZ'S PIVOT SYSTEM" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) +
 "  - " + Date() +" - "+"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+ "Cl-"+C+"  "+ "Vol= "+ WriteVal(V) + WriteIf ( V > MA(V,26),EncodeColor(colorGreen)+"  UP "+ ((V/MA(V,26))*100-100) + " %", EncodeColor(colorRed)+"  DOWN "+ ((100- V/MA(V,26)*100)) + " %")
+ EncodeColor(colorRed)+   "\n Pivot High : "+ EncodeColor(colorWhite)+PH+EncodeColor(colorRed)+ "  Place LONG    Trigger at :"+EncodeColor(colorWhite)+ phfilter + EncodeColor(colorRed)+ "   SL of :"+ EncodeColor(colorWhite)+SL+ EncodeColor(colorRed)+ "    Risk of " + EncodeColor(colorWhite)+risk_long
+ EncodeColor(colorYellow)+ "\n Long Target of : "+Long_tgt1 +"  and second target of :" + Long_tgt2   
+ "\n"
+ EncodeColor(colorGreen)+ "\n Pivot  Low : "+EncodeColor(colorWhite)+PL+EncodeColor(colorGreen)+"  Place SHORT Trigger at :"+ EncodeColor(colorWhite)+plfilter + EncodeColor(colorGreen)+"   SL of :"+ EncodeColor(colorWhite)+SL+ EncodeColor(colorGreen)+"    Risk of " + EncodeColor(colorWhite)+risk_short
+ EncodeColor(colorYellow)+ "\n Short Target of : "+short_tgt1 +"  and second target of :" + short_tgt2   
;

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 4 );
_SECTION_END();
Amibroker COde for CCI panel Underneat the Price chart: -

Code:
_SECTION_BEGIN("CCI Panel for Amibroker"); 
/////////////////////////////// 
// CCI Panel for Amibroker
// Codded/Added by Dennis, Kris, Wring, Santacs 
// Last Update: 1/02/2008
/////////////////////////////// 
// 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 ",colorBlack)); 

// CCI colors

zcolor= ParamColor("WCCI color",colorWhite);
z6color= ParamColor("TCCI color",colorYellow);

// 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 


d=0.03;
z6t=z6+HHV(z6,100)*d;
z6b=z6-HHV(z6,100)*d;

Plot(round(z6),"TCCI", z6color, styleThick);
//PlotOHLC(z6t,z6t,z6b,z6b,"",z6color,styleCloud,styleNoLabel);

d=0.02;
zt=z+HHV(z,100)*d;
zb=z-HHV(z,100)*d;
 
//PlotOHLC(zt,zt,zb,zb,"",zcolor,styleCloud,styleNoLabel);


periods = Param( "Periods", 20, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );

periods = Param( "Periods", 20, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
D1smooth = Param( "%D1 avg", 2, 1, 200, 1 );
 
A = StochK( periods , K1smooth);
B = StochD( periods , K1smooth, D1Smooth );


periods = Param( "Periods", 8, 1, 200, 1 );
K2smooth = Param( "%K1 avg", 3, 1, 200, 1 );
D2smooth = Param( "%D1 avg", 3, 1, 200, 1 );

M = StochK( periods , K2smooth);
N = StochD( periods , K2smooth, D2Smooth );

ColorK=IIf(A>B,colorBrightGreen,colorRed);


PlotOHLC(zt,zt,zb,zb,"",zcolor,styleCloud,styleNoLabel);

//PlotOHLC(zt,zt,zb,zb,"",ColorK,styleCloud,styleNoLabel);

Z42=CCI(42); 
//Plot(Z42,"", colorCustom12, styleLine | styleThick); 










// 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(101,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 
Plot(99,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 
Plot(98,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 

Plot(-100,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 
Plot(-101,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 
Plot(-99,"", ColorANGLE_EMA , styleLine | styleThick | styleNoLabel); 
Plot(-102,"", 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, colorBlue, 
IIf(abs(SW) == 1, colorGrey40, colorBlack)); 
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;

Buy=Z42>0 AND (Cross(round(z),-100) OR Cross(round(z),0) OR Cross(round(z),50));
Sell=Z42<0 AND (Cross(100,round(z)) OR Cross(0,round(z)) OR Cross(-50,round(z)));
Filter=Buy OR Sell;

AddColumn( IIf(Buy,1,IIf(Sell,-1,0)) ,"BS",1.0,colorBlack,IIf(Buy,colorGreen,IIf(Sell,colorRed,colorBlack)));

_SECTION_END();





_SECTION_BEGIN("Stochastic_45-4-2_833");

ColorX=colorBlack;
//ColorX=colorWhite;


 
periods = Param( "Periods", 20, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
//Plot( StochK( periods , K1smooth), _DEFAULT_NAME(), colorCustom3, styleNoLabel  | styleThick | styleDots);


periods = Param( "Periods", 20, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 4, 1, 200, 1 );
D1smooth = Param( "%D1 avg", 2, 1, 200, 1 );
//Plot( StochD( periods , K1smooth, D1Smooth ), _DEFAULT_NAME(), colorCustom3, styleNoLabel  | styleThick | styleDots);



A = StochK( periods , K1smooth);
B = StochD( periods , K1smooth, D1Smooth );



PlotOHLC( 300, 300 , 280 , 280 , "", ColorANGLE_EMA, styleCloud | styleNoLabel);
//PlotOHLC( -280, -280 , -300 , -300 , "", IIf(C > LSMA25,colorBrightGreen,IIf(C < LSMA25,colorRed,colorTeal)), styleCloud | styleNoLabel);

periods = Param( "Periods", 8, 1, 200, 1 );
K1smooth = Param( "%K1 avg", 3, 1, 200, 1 );



periods = Param( "Periods", 8, 1, 200, 1 );
K2smooth = Param( "%K1 avg", 3, 1, 200, 1 );
D2smooth = Param( "%D1 avg", 3, 1, 200, 1 );

M = StochK( periods , K2smooth);
N = StochD( periods , K2smooth, D2Smooth );

ColorK=IIf(A>B,colorBrightGreen,colorRed);

//Plot( M,"StoK", ColorK, styleNoLabel|styleThick);
//Plot( N,"StoD", colorDarkYellow, styleNoLabel|styleDashed);



//PlotOHLC( 0, A , B , B , "Cloud", IIf(A > B ,colorAqua,colorRed), styleCloud | styleNoLabel);


_SECTION_END();
_SECTION_BEGIN("Woodie's CCI  Intraday Panel");
//------------------------------------------------------------------------------
//
//  Formula Name:    Woodie's CCI  Intraday Panel
//  Author/Uploader: Dennis Skoblar 
//  E-mail:          [email protected] 
//  Date/Time Added: 2006-07-22 15:27:37
//  Origin:          woodiescciclub.com
//  Keywords:        Woodie's CCI, CCI
//  Level:           medium
//  Flags:           system,exploration,indicator
//  Formula URL:     http://www.amibroker.com/library/formula.php?id=642
//  Details URL:     http://www.amibroker.com/library/detail.php?id=642
//
//------------------------------------------------------------------------------
//
//  Here is Woodie's CCI Intraday panel which was originally coded by
//  Crasher_FL and Wring. It is a modified Daily CCI Panel with the CCI 14, and
//  CCI 6. It is complete with pattern recognition,backtesting, scanning, and
//  exploration options. The Pattern Recognition helps find the ZLR, HFE,
//  GB100(with a 34ema +/- 15 degree nuance), VT,FAMIR,MR and Choppy (Chop mode
//  being defined as the CCI bars inbetween the 100's for 10 or more bars. The
//  reset out of chop is when the CCI hooks from extreme at the 200's). . The
//  pattern recognition is located at the top left corner next to "Signal: ".
//
//  1=zlr
//
//  2-famir
//
//  3=vt
//
//  4=gb100
//
//  5=momentum reversal
//
//  This version has the Mplay Exit Indicator in it. The MPLAY exit is a CCI
//  hook to the oposite direction followed by another with the price closing in
//  the oposite direction of the trade. I have coded the MPLAY Indicator with
//  the CCI panel. It is a series of green and red circles just below the +200
//  line. The nearest green circle that appears after a pattern (any pattern,
//  not just the coded ones) is the exit for a long position. The nearest red
//  circle is the exit after a short pattern. Ignore all the ones inbetween.
//  The circles appear after every and any occurance of an MPLAY Exit,
//  regardless if a pattern has appeared or not. Just use the nearest
//  applicable circle to exit a pattern entered.
//
//  I also added the EMA angle colors to the 100's. Turquoise= uptrend,
//  Red=downtrend, Yellow=not trending. This code was originally in the cci
//  panel coded by Crasher, I just tweeked it to be displayed in visual format.
//  It is identical to woodie's modification to the cci panel, which he uses as
//  a chop inicator as well. If there is a constant color, the trend is in that
//  direction. If the colors are mixed, then there is a chop.
//
//  Trade at your own risk, please use your own descretion, for educational
//  purposes only.
//
//  -Dennis
//
//------------------------------------------------------------------------------

/////////////////////////////// 

// CCI Woodies Style - Started by Wring 

// Codded/Added by Kris 

// Added by Dennis and Greg 

// Version: 1.027 

// Last Update: 11/24/2005 

// Additions: 

// timer, EMA angle, LSMA angle, trending indicator, pattern recognition (Choppy, HFE, ZLR, FAMIR, VT, GB100) 

// Amibroker 4.70 

/////////////////////////////// 

Version(4.70); 

//MarketHours = TimeNum()>=63000 AND TimeNum()<=125959; 

//MArketClose= TimeNum()>=125959 AND TimeNum()<=130000; 

z = CCI(14); 

z6 = CCI(6); 

CCI50_var = CCI(50); 

LSMA25 = LinearReg(C, 25 ); 

EMA34 = EMA(C,34); 

PI = atan(1.00) * 4; 

periods = 30; 

HighHigh = HHV(H, periods); 

LowLow = LLV(L, periods); 

range = 25 / (HighHigh - LowLow) * LowLow; 

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; 

TitleTimeRem = EncodeColor(colorBlueGrey) + "Time Remaining: "; 

MinuteVar = int(TimeRem / 60); 

SecondsVar = int(frac(TimeRem / 60) * 60); 

if (TimeRem[BarCount - 1] > 60) 

{ 

TitleTimeRem = TitleTimeRem + EncodeColor(colorWhite) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 

} 

else if (TimeRem[BarCount - 1] > 20) 

{ 

TitleTimeRem = TitleTimeRem + EncodeColor(colorYellow) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 

} 

else 

{ 

TitleTimeRem = TitleTimeRem + EncodeColor(colorLime) + MinuteVar + ":" + WriteIf(SecondsVar > 9, "", "0") + SecondsVar; 

} 

if(SelectedValue(CCI50_var) < 0) 

{ 

CCI50Title = EncodeColor(colorRed); 

} 

else 

{ 

CCI50Title = EncodeColor(colorLime); 

} 

CCI50Title = CCI50Title + "CCI 50 = " + round(CCI50_var) + ", "; 

stop_range = IIf(O < C, IIf((H - O) < (C - L), C - L, H - O), 

IIf((O - L) < (H - C), H - C, O - L)); 

StopTitle = EncodeColor(colorWhite) + "Stop = " + EncodeColor(colorYellow); 

StopTitle = StopTitle + StrToNum(NumToStr(stop_range, 4.4)); 

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); 

TitleAngleEMA34 = EncodeColor(colorWhite) + "\nEMA34 angle = "; 

angle_EMA34 = IIf(y2_EMA34 > 0, - angle_EMA34, angle_EMA34); 

if(SelectedValue(angle_EMA34) >= 25) 

{ 

TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorTurquoise); 

} 

else if(SelectedValue(angle_EMA34) <= -25) 

{ 

TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorRed); 

} 

else if(SelectedValue(angle_EMA34) >= 5) 

{ 

TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorTurquoise); 

} 

else if(SelectedValue(angle_EMA34) <= -5) 

{ 

TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorRed); 

} 

else 

{ 

TitleAngleEMA34 = TitleAngleEMA34 + EncodeColor(colorYellow); 

} 

TitleAngleEMA34 = TitleAngleEMA34 + angle_EMA34; 

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); 

TitleAngleLSMA25 = EncodeColor(colorWhite) + "LSMA25 angle = "; 

angle_LSMA25 = IIf(y2_LSMA25 > 0, - angle_LSMA25, angle_LSMA25); 

if(SelectedValue(angle_LSMA25) >= 25) 

{ 

TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorTurquoise); 

} 

else if(abs(SelectedValue(angle_LSMA25)) <= -25) 

{ 

TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorRed); 

} 

else if(SelectedValue(angle_LSMA25) >= 5) 

{ 

TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorTurquoise); 

} 

else if(SelectedValue(angle_LSMA25) <= -5) 

{ 

TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorRed); 

} 

else 

{ 

TitleAngleLSMA25 = TitleAngleLSMA25 + EncodeColor(colorYellow); 

} 

TitleAngleLSMA25 = TitleAngleLSMA25 + angle_LSMA25; 

TitleTrending = WriteIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorLime) + "TRENDING", 

WriteIf((abs(angle_EMA34) >= 5) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 30), EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorYellow) + "NORMAL", 

EncodeColor(colorWhite) + ", SW = " + EncodeColor(colorRed) + "FLAT")); 

SW = IIf((abs(angle_EMA34) >= 15) AND (abs(angle_EMA34 + angle_LSMA25) >= 50), IIf(angle_LSMA25 > 0, 2, -2), 

IIf((abs(angle_EMA34) >= 5) AND (((angle_EMA34 >= 0) AND (angle_LSMA25 >= 0)) OR ((angle_EMA34 <= 0) AND (angle_LSMA25 <= 0))) AND (abs(angle_EMA34 + angle_LSMA25) >= 30), IIf(angle_LSMA25 > 0, 1, -1), 0)); 

// Colour the bars for Woodies Trend Following 

Plusbars = BarsSince(z < 0); 

Minusbars = BarsSince(z > 0); 

TrendBarCount = 6; 

Color[0] = colorDefault; 

Trend[0] = 0; 

TTMColor[0] = colorDefault; 

for( i = 1; i < BarCount; i++ ) 

{ 

if (C[i] > High_third[i]) 

{ 

TTMColor[i] = colorDarkGreen; 

} 

else if (C[i] < Low_third[i]) 

{ 

TTMColor[i] = colorDarkRed; 

} 

else 

{ 

TTMColor[i] = TTMColor[i - 1]; 

} 

if (Plusbars[i] >= TrendBarCount) 

{ 

Trend[i] = 1; 

} 

else if (Minusbars[i] >= TrendBarCount) 

{ 

Trend[i] = -1; 

} 

else 

{ 

Trend[i] = Trend[i - 1]; 

} 

if (Trend[i] == 1) 

{ 

if (Minusbars[i] == TrendBarCount - 1) 

{ 

Color[i] = colorYellow; 

} 

else if (z[i] < 0) 

{ 

Color[i] = colorLightGrey; 

} 

else 

{ 

Color[i] = colorLime; 

} 

} 

else if (Trend[i] == -1) 

{ 

if (Plusbars[i] == TrendBarCount - 1) 

{ 

Color[i] = colorYellow; 

} 

else if (z[i] >= 0) 

{ 

Color[i] = colorLightGrey; 

} 

else 

{ 

Color[i] = colorRed; 

} 

} 

else 

{ 

Color[i] = colorDefault; 

} 

} 

// CCI Line 

//Plot(z,"CCI 14", colorSkyblue, styleLine | styleThick); 

// Turbo CCI 

//Plot(z6,"CCI 6", colorLightOrange, styleLine | styleNoLabel); 

// zero line 25lsma 

//Plot(0,"", IIf(C > LSMA25,colorGreen,IIf(C<LSMA25,colorRed,colorTeal)), styleDots | styleNoLine | styleThick | styleNoLabel); 

// CCI Histogram 

//Plot(z,"", Color, styleHistogram | styleNoLabel); 

// CCI 50 

//Plot(CCI50_var,"CCI 50", IIf(CCI50_var < 0, colorDarkRed,colorDarkGreen), styleLine | styleNoLabel); 

// Set up color for the 100s, green if 34ema above red if below 

//Color = IIf(C > EMA34, colorGreen, 

// IIf(C == EMA34, colorTeal, colorRed)); 

//Set Color for the SW 

ColorSW = IIf(abs(SW) == 2, colorGreen, 

IIf(abs(SW) == 1, colorYellow, colorRed)); 

Color=colorWhite; 

// Plot the 100s 

//Plot(100,"",Color,styleDashed|styleNoLabel); 

//Plot(-100,"",Color,styleDashed|styleNoLabel); 

ColorANGLE_EMA = IIf(angle_EMA34 >=5, colorTurquoise, 

IIf(angle_EMA34 <=-5, colorRed, colorYellow)); 

//ColorANGLE_EMA1 = IIf(angle_EMA34 >=25, colorTurquoise, 

// IIf(angle_EMA34 <=-25, colorRed, colorBlack)); 

//ColorANGLE_EMA = IIf(abs(angle_EMA34) >=25, colorGreen, 

// IIf(abs(angle_EMA34) >=15, colorYellow, colorRed)); 

//Plot(100,"", ColorANGLE_EMA , styleDashed | styleThick | styleNoLabel); 

//Plot(-100,"", ColorANGLE_EMA , styleDashed | styleThick | styleNoLabel); 

// Plot the 50s 

//Plot(50,"", colorDarkGrey, styleDashed | styleNoLabel); 

//Plot(-50,"", colorDarkGrey , styleDashed | styleNoLabel); 

//Plot(50,"", TTMColor, styleDots | styleNoLine | styleNoLabel); 

//Plot(-50,"", TTMColor, styleDots | styleNoLine | styleNoLabel); 

// Plot the 200s 

//Plot(200,"", ColorSW, styleThick | styleNoLabel); 

//Plot(-200,"", ColorSW, styleThick | styleNoLabel); /

// Plot the grids 

//PlotGrid(0); 

//PlotGrid(50); 

//PlotGrid(-50); 

//PlotGrid(-100); 

//PlotGrid(100); 

//PlotGrid(-200); 

///PlotGrid(200); 

//// choppy 

A= (HHV(z,10)<=100 AND LLV(z,10)>=-100); 

B= (Ref(z,-1)>200 AND z<200) OR (Ref(z,-1)<-200 AND z>-200); 

bs_a=BarsSince(A); 

bs_b=BarsSince(B); 

bars = IIf( bs_A < Bs_B, bs_a, 0); 

// ZLR Long 

uptrend_a=BarsSince(z<0); 

uptrend_b=BarsSince(z>0); 

Linex_long=Ref(z,-1)>100 AND z<100; 

barsfromline_long=BarsSince(Linex_long); 

CCIhook_long=z>Ref(z,-1) AND Ref(z,-1)>-100 AND Ref(z,-1)<Ref(z,-2) AND Ref(z,-2)>-100 AND z>0; 

SW_trendinglong= sw==1 OR sw==2; 

zlrlong= (Ref(angle_ema34,-2)>=5 AND Ref(angle_ema34,-1)>=5 AND angle_ema34>=5) AND SW_trendinglong AND z<100 AND barsfromline_long<10 AND CCIhook_long AND (uptrend_a>=6 AND z>-100 OR 

(uptrend_b<6 AND LLV(z,uptrend_b)>-100 AND z>-100 AND (Ref(uptrend_a,-6)>=6 AND z>-100 OR Ref(uptrend_a,-5)>=6 AND z>-100 OR Ref(uptrend_a,-4)>=6 AND z>-100 OR Ref(uptrend_a,-3)>=6 AND z>-100 OR 

Ref(uptrend_a,-2)>=6 AND z>-100 OR Ref(uptrend_a,-1)>=6 AND z>-100))); 

PlotShapes(IIf(zlrlong,shapeDigit1,shapeNone),colorLime,0,0,-15); 

// ZLR Short 

downtrend_a=BarsSince(z>0); 

downtrend_b=BarsSince(z<0); 

Linex_short=Ref(z,-1)<=-100 AND z>=-100; 

barsfromline_short=BarsSince(Linex_short); 

CCIhook_short=z<Ref(z,-1) AND Ref(z,-1)<100 AND Ref(z,-1)>Ref(z,-2) AND Ref(z,-2)<100 AND z<0; 

SW_trendingshort= sw==-1 OR sw==-2; 

zlrshort= (Ref(angle_ema34,-2)<=-5 AND Ref(angle_ema34,-1)<=-5 AND angle_ema34<=-5) AND SW_trendingshort AND z>-100 AND barsfromline_short<10 AND CCIhook_short AND (downtrend_a>=6 AND z<100 OR 

(downtrend_b<6 AND HHV(z,downtrend_b)<100 AND z<100 AND (Ref(downtrend_a,-6)>=6 AND z<100 OR Ref(downtrend_a,-5)>=6 AND z<100 OR Ref(downtrend_a,-4)>=6 AND z<100 OR 

Ref(downtrend_a,-3)>=6 AND z<100 OR Ref(downtrend_a,-2)>=6 AND z<100 OR Ref(downtrend_a,-1)>=6 AND z<100))); 

PlotShapes(IIf(zlrshort,shapeDigit1+ shapePositionAbove,shapeNone),colorRed,0,0,-15); 

// Famir Short 

Famir_downtrend_a=BarsSince(z<0); 

Famir_downtrend_b=BarsSince(z>0); 

FamirLinex_short=Ref(z,-1)>=100 AND z<100; 

Famir_barsfromline_short=BarsSince(FamirLinex_short); 

Famir_pivotshort= (Ref(z,-2)<Ref(z,-1)AND Ref(z,-1)<=55 AND Ref(z,-2)<=55) OR (Ref(z,-3)<Ref(z,-1)AND Ref(z,-1)<=55 AND Ref(z,-2)<=55 AND Ref(z,-3)<=55) 

OR (Ref(z,-4)<Ref(z,-1) AND Ref(z,-1)<=55 AND Ref(z,-2)<=55 AND Ref(z,-3)<=55); 

Famirhook_short=Famir_pivotshort AND z<Ref(LLV(z,Famir_barsfromline_short),-1) AND (z>=-55 AND z<=55) AND C<Lsma25; 

Famirshort=  Famir_barsfromline_short<10 AND Famirhook_short AND (Famir_downtrend_a>=6 OR 

(Famir_downtrend_b<6 AND (Ref(Famir_downtrend_a,-6)>=6 OR Ref(Famir_downtrend_a,-5)>=6 OR Ref(Famir_downtrend_a,-4)>=6 OR 

Ref(Famir_downtrend_a,-3)>=6 OR Ref(Famir_downtrend_a,-2)>=6 OR Ref(Famir_downtrend_a,-1)>=6))) AND C<LSMA25; 

PlotShapes(IIf(famirShort,shapeDigit2+ shapePositionAbove,shapeNone),colorRed,0,0,-15); 

// Famir Long 

Famir_uptrend_a=BarsSince(z<0); 

Famir_uptrend_b=BarsSince(z>0); 

FamirLinex_long=Ref(z,-1)<=-100 AND z>-100; 

Famir_barsfromline_long=BarsSince(FamirLinex_long); 

Famir_pivotlong= (Ref(z,-2)>Ref(z,-1)AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55) OR (Ref(z,-3)>Ref(z,-1) AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55 AND Ref(z,-3)>=-55) 

OR (Ref(z,-4)>Ref(z,-1) AND Ref(z,-1)>=-55 AND Ref(z,-2)>=-55 AND Ref(z,-3)>=-55); 

Famirhook_long=Famir_pivotlong AND z>Ref(HHV(z,Famir_barsfromline_long),-1) AND (z>=-55 AND z<=55) AND C>Lsma25; 

Famirlong= Famir_barsfromline_long<10 AND Famirhook_long AND (Famir_uptrend_a<6 OR 

(Famir_uptrend_b>=6 AND(Ref(Famir_uptrend_a,-6)<6 OR Ref(Famir_uptrend_a,-5)<6 OR Ref(Famir_uptrend_a,-4)<6 OR Ref(Famir_uptrend_a,-3)<6 OR 

Ref(Famir_uptrend_a,-3)<6 OR Ref(Famir_uptrend_a,-2)<6 OR Ref(Famir_uptrend_a,-1)<6))) AND C>LSMA25; 

PlotShapes(IIf(famirlong,shapeDigit2,shapeNone),colorLime,0,0,-15); 

// HFE 

HFEshort=(Ref(z,-1)>200 AND z<200); 

HFElong=(Ref(z,-1)<-200 AND z>-200); 

HFE= (Ref(z,-1)>200 AND z<200) OR (Ref(z,-1)<-200 AND z>-200); 

PlotShapes(IIf(Ref(z,-1)>200 AND z<200,shapeDownTriangle,shapeNone),IIf(Ref(z,-1)>200 AND z<200,colorYellow,shapeNone),0,200,-20); 

PlotShapes(IIf(Ref(z,-1)<-200 AND z>-200,shapeUpTriangle,shapeNone),IIf(Ref(z,-1)<-200 AND z>-200,colorYellow,shapeNone),0,-200,-20); 

// VT Long 

vtLinex_long=Ref(z,-1)<=-200 AND z>-200; 

vt_barsfromline_long=BarsSince(vtLinex_long); 

vtlong_A = z<-200; 

vtlong_B = Ref(z,-1)<=Ref(z,-2) OR 

Ref(z,-2)<=Ref(z,-3) OR 

Ref(z,-3)<=Ref(z,-4) OR 

Ref(z,-4)<=Ref(z,-5) OR 

Ref(z,-5)<=Ref(z,-6) OR 

Ref(z,-6)<=Ref(z,-7) OR 

Ref(z,-7)<=Ref(z,-8); 

vtlong_bs_A = BarsSince(vtlong_A); 

vtlong_bs_B = BarsSince(vtlong_b); 

Vtlong_bars = vtlong_bs_A>=5 AND vtlong_bs_B<=0; 

vt_pivotlong= Vtlong_bars; 

swinghibars=BarsSince(z>Ref(HHV(z,vt_barsfromline_long),-1)); 

vthook_long= vt_pivotlong AND z>Ref(HHV(z,vt_barsfromline_long),-1); 

vtlong= vt_barsfromline_long<=11 AND (Ref(HHV(z,vt_barsfromline_long),-1)<0 OR HHV(z,vt_barsfromline_long)<=0) AND vthook_long AND C>Lsma25 AND Ref(swinghibars>=2,-1) AND z>-100; 

PlotShapes(IIf(vtlong,shapeDigit3,shapeNone),colorLime,0,Min(z,0),-45); 

// VT Short 

vtLinex_short=Ref(z,-1)>=200 AND z<200; 

vt_barsfromline_short=BarsSince(vtLinex_short); 

vtshort_A = z>200 ; 

vtshort_B =Ref(z,-1)>=Ref(z,-2) OR 

Ref(z,-2)>=Ref(z,-3) OR 

Ref(z,-3)>=Ref(z,-4) OR 

Ref(z,-4)>=Ref(z,-5) OR 

Ref(z,-5)>=Ref(z,-6) OR 

Ref(z,-6)>=Ref(z,-7) OR 

Ref(z,-7)>=Ref(z,-8); 

vtshort_bs_A = BarsSince(vtshort_A); 

vtshort_bs_B = BarsSince(vtshort_b); 

Vtshort_bars = vtshort_bs_A>=5 AND vtshort_bs_B<=0; 

vt_pivotshort= Vtshort_bars; 

swinglowbars= BarsSince(z<Ref(LLV(z,vt_barsfromline_short),-1)); 

vthook_short= vt_pivotshort AND z<Ref(LLV(z,vt_barsfromline_short),-1); 

vtshort= vt_barsfromline_short<=11 AND (Ref(LLV(z,vt_barsfromline_short),-1)>0 OR LLV(z,vt_barsfromline_short)>0) AND vthook_short AND C<Lsma25 AND Ref(swinglowbars>=2,-1) AND z<100; 

PlotShapes(IIf(vtshort,shapeDigit3+ shapePositionAbove,shapeNone),colorRed,0,Max(z,0),-45); 

// GB 100 Long 

uptrend_a=BarsSince(z<0); 

uptrend_b=BarsSince(z>0); 

Linex_longGB=Ref(z,-1)>100 AND z<100; 

barsfromline_longGB=BarsSince(Linex_longGB); 

CCIhook_longGB= Ref(z,-1)<-100 AND z>-100; 

GB100long= barsfromline_longGB<20 AND angle_EMA34>=5 AND CCIhook_longGB AND (uptrend_b<6 AND(Ref(uptrend_a,-6)>=6 OR Ref(uptrend_a,-5)>=6 OR Ref(uptrend_a,-4)>=6 OR Ref(uptrend_a,-3)>=6 OR 

Ref(uptrend_a,-2)>=6 OR Ref(uptrend_a,-1)>=6)); 

PlotShapes(IIf(GB100long,shapeDigit4,shapeNone),colorLime,0,0,-60); 

// GB100 Short 

downtrend_a=BarsSince(z>0); 

downtrend_b=BarsSince(z<0); 

Linex_shortGB=Ref(z,-1)<-100 AND z>-100; 

barsfromline_shortGB=BarsSince(Linex_shortGB); 

CCIhook_shortGB=Ref(z,-1)>100 AND z<100; 

GB100short= barsfromline_shortGB<20 AND angle_EMA34<=-5 AND CCIhook_shortGB AND 

(downtrend_b<6 AND (Ref(downtrend_a,-6)>=6 OR Ref(downtrend_a,-5)>=6 OR Ref(downtrend_a,-4)>=6 OR 

Ref(downtrend_a,-3)>=6 OR Ref(downtrend_a,-2)>=6 OR Ref(downtrend_a,-1)>=6)); 

PlotShapes(IIf(GB100short,shapeDigit4+ shapePositionAbove,shapeNone),colorRed,0,0,-60); 

// MR Long 

MRuptrend_a=BarsSince(z<0); 

MRuptrend_b=BarsSince(z>0); 

MRLinex_long=Ref(z,-1)>100 AND z<100; 

MRbarsfromline_long=BarsSince(MRLinex_long); 

MRCCIhook_long=z>Ref(z,-1) AND Ref(z,-1)<=Ref(z,-2) AND Ref(z,-2)<Ref(z,-3) AND z>-100 AND z<100; 

MRlong= Ref(z,-1)<=0 AND MRbarsfromline_long<10 AND MRCCIhook_long AND (MRuptrend_a>=6 AND z>-100 OR 

(MRuptrend_b<6 AND LLV(z,MRuptrend_b)>-100 AND z>-100 AND (Ref(MRuptrend_a,-6)>=6 AND z>-100 OR Ref(MRuptrend_a,-5)>=6 AND z>-100 OR Ref(MRuptrend_a,-4)>=6 AND z>-100 OR Ref(MRuptrend_a,-3)>=6 AND z>-100 OR 

Ref(MRuptrend_a,-2)>=6 AND z>-100 OR Ref(MRuptrend_a,-1)>=6 AND z>100))); 

PlotShapes(IIf(MRlong,shapeDigit5,shapeNone),colorLime,0,0,-50); 

// MR Short 

MRdowntrend_a=BarsSince(z>0); 

MRdowntrend_b=BarsSince(z<0); 

MRLinex_short=Ref(z,-1)<=-100 AND z>=-100; 

MRbarsfromline_short=BarsSince(MRLinex_short); 

MRCCIhook_short=z<Ref(z,-1) AND Ref(z,-1)>=Ref(z,-2) AND Ref(z,-2)>Ref(z,-3) AND z<100 AND z>-100; 

MRshort= Ref(z,-1)>=0 AND MRbarsfromline_short<10 AND MRCCIhook_short AND (MRdowntrend_a>=6 AND z<100 OR 

(MRdowntrend_b<6 AND HHV(z,MRdowntrend_b)<100 AND z<100 AND (Ref(MRdowntrend_a,-6)>=6 AND z<100 OR Ref(MRdowntrend_a,-5)>=6 AND z<100 OR Ref(MRdowntrend_a,-4)>=6 AND z<100 OR 

Ref(MRdowntrend_a,-3)>=6 AND z<100 OR Ref(MRdowntrend_a,-2)>=6 AND z<100 OR Ref(MRdowntrend_a,-1)>=6 AND z<100))); 

PlotShapes(IIf(MRshort,shapeDigit5+ shapePositionAbove,shapeNone),colorRed,0,0,-50);

// Columns for exploration 

Filter =(zlrlong OR famirlong OR Vtlong OR gb100long OR mrlong  OR hfe OR zlrshort OR famirshort OR vtshort OR gb100short OR mrlong OR (A OR bars)) AND 1 ; 

Buy = (zlrlong OR famirlong OR Vtlong OR gb100long);// AND MarketHours; 

Sell= (z<Ref(z,-1) AND Ref(z,-1)<Ref(z,-2) AND C<O);// OR MArketClose; ; 

Short = (zlrshort OR famirshort OR Vtshort OR gb100short); //AND MarketHours; 

Cover = (z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2) AND C>O);// OR MArketClose; 

AddColumn( IIf(zlrlong,1,IIf(zlrshort,-1,0)) ,"ZLR",1.0,colorWhite,IIf(zlrlong,colorGreen,IIf(zlrshort,colorRed,colorBlack))); 

AddColumn(IIf(famirlong,1,IIf(famirShort,-1,0)),"Famir",1.0,colorWhite,IIf(famirlong,colorGreen,IIf(famirShort,colorRed,colorBlack))); 

AddColumn(IIf(vtlong,1,IIf(vtShort,-1,0)),"Vegas",1.0,colorWhite,IIf(vtlong,colorGreen,IIf(vtShort,colorRed,colorBlack))); 

AddColumn(IIf(gb100long,1,IIf(gb100Short,-1,0)),"GB100",1.0,colorWhite,IIf(gb100long,colorGreen,IIf(gb100Short,colorRed,colorBlack))); 

AddColumn( IIf(mrlong,1,IIf(mrShort,-1,0)) ,"MR",1.0,colorWhite,IIf(mrlong,colorGreen,IIf(mrShort,colorRed,colorBlack))); 

AddColumn(IIf(hfelong,1,IIf(hfeshort,-1,0)),"HFE",1.0,colorWhite,IIf(hfelong,colorGreen,IIf(hfeshort,colorRed,colorBlack))); 

AddColumn(IIf(A OR bars,1,IIf(A OR bars,-1,0)),"Choppy",1.0,colorWhite,IIf(A OR bars,colorDarkYellow,IIf(A OR bars,colorDarkYellow,colorBlack))); 

//Plot Sell Arrows 

//Sell1=ExRem(Sell,Buy); 

//Cover1=ExRem(Cover,Short); 

//PlotShapes(IIf(Sell1,shapeDownArrow,shapeNone),colorLime,0,200,10); 

//PlotShapes(IIf(Cover1,shapeDownArrow,shapeNone),colorRed,0,200,10); 

//Signal Title 

Signaltitle= WriteIf(zlrlong,EncodeColor(colorYellow) + "ZLR ", 

WriteIf(zlrshort,EncodeColor(colorYellow) + "ZLR ", WriteIf(MRShort,EncodeColor(colorYellow) + "MR ", 

WriteIf(MRlong,EncodeColor(colorYellow) + "MR ", 

WriteIf(Famirshort,EncodeColor(colorYellow) + "FAMIR ", 

WriteIf(Famirlong,EncodeColor(colorYellow) + "FAMIR ",WriteIf(HFE,EncodeColor(colorYellow) + "HFE ",WriteIf(VTlong,EncodeColor(colorYellow) + "VT ", 

WriteIf(VTshort,EncodeColor(colorYellow) + "VT ",WriteIf(GB100long,EncodeColor(colorYellow) + "GB100 ", 

WriteIf(Gb100short,EncodeColor(colorYellow) + "GB100 "," "))))))))))); 

//Choppy Title 

ChoppyTitle= WriteIf(A,EncodeColor(colorYellow) + "CHOPPY",WriteIf(bars,EncodeColor(colorYellow) + "CHOPPY","")); 

//Exit Title 

//Exittitle=WriteIf(Sell1,EncodeColor(colorLime) + "MLAY EXIT LONG",WriteIf(Cover1,EncodeColor(colorRed) + "MPLAY EXIT SHORT","")); 

//Distance from EMA34

Ctoema=round(C-EMA34);

Ctitle= WriteIf(Ctoema>0," points above EMA,",WriteIf(Ctoema<0," points below EMA,"," on EMA,"));

//Number of trending bars

anglelimit= ( angle_ema34<5 AND angle_ema34>-5)  OR (angle_ema34<5 AND angle_ema34>-5);

angletitle= BarsSince(anglelimit);

//Title 

Title = "" + Name() + ", " + Interval(2) + ", " + Date() + "\n" + 

EncodeColor(colorSkyblue) + "CCI 14 = " + round(z) + EncodeColor(colorWhite) + ", " + EncodeColor(colorLightOrange) + 

"CCI 6 = " + round(z6) + EncodeColor(colorWhite) + ", " + 

TitleTimeRem + EncodeColor(colorWhite) + 

TitleAngleEMA34 + EncodeColor(colorWhite) + ", " + TitleAngleLSMA25 + 

TitleTrending + "\n" + EncodeColor(colorWhite)+"Signal = "+Signaltitle + ChoppyTitle; //+ EncodeColor(colorWhite) + Ctoema + Ctitle +  EncodeColor(colorWhite) + " " + angletitle + " " + "bars trending, " + "  " + " "+Exittitle; 

//Mplay Exit 

MplayExitLong= z<Ref(z,-1) AND Ref(z,-1)<Ref(z,-2) AND C<O; 

MplayExitShort= z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2) AND C>O; 

PlotShapes(IIf(MplayExitLong,shapeSmallCircle,shapeNone),colorGreen,0,200,-10); 

PlotShapes(IIf(MplayExitShort,shapeSmallCircle,shapeNone),colorRed,0,200,-10); 
_SECTION_END();
Graphical Overview of the system: -



1. Blue is the Pivot High Line in Price.
2. Orange is the Pivot Low line in Price.
3. Green Bars are when price is above the stoploss line. Red Bars are when price is below Stoploss Line. Yellow is when price closes at Stoploss line.
4. Aqua is the stoploss line. Can be used as trailing stoploss.


For timing the entry, i am posting a link to clock program. Adjust its interval to timeframe you are using, and it will show you time left for next candle to appear.

http://www.mediafire.com/?k3l2ryqljrt



P.S. - This system is just a test. So dont take trades blidnly. As widout proper understanding the results can be severe heart aching. I will be posting the trades based upon this method here. Thanks to linkon sir for motivating me to discuss method here for further tweaking.
whos pic i mean who is that old man
 

rajputz

Well-Known Member
#78
Here afl for turtle pvt breakout.
I have coded in such a way that if h pivot level breaks and simultaneously cci 14 crosses +100 and cci6 and 14 points upwards then buy and vice versa with shorts with cci -100 downwards.
Take profit when cci crosses back 100 downwards for buy and -100 upwards for short.
I have added money management and also profit/loss per trade in explorer.
In explorer u can see entry and exit and p/l and quantity to trade.
Rajputz, please advise if the entry exit rules are correct or not otherwise we improve.
Thanks vinod for your effort in improving the afl. I will try to work on it in real time and will check the results. Even CCI settings and signal is implemented in the code, I will recommend that CCI panel that i have posted should be used and considered.

Reason is that CCI above signal only constitute to little part of the working. Major is understanding of working of the indicator. Some times CCI will be between 0 and 100 or -100. Then it will not give any signal. And also some patterns over cci are to be looked at.

For eg. I have mentioned that I will not be looking at all the signals reffered by woodies. And out of those only: -

1. trend continuation Signal ZLR or Tony Trade. GB100 may miss the major move and fail.
2. trend reversal signal Famir or Ghost. VT is not a good trend reversal signal. Atleast for me.
3. and one I have mentioned, which is not part of book and is not a signal at all i.e momentum change. CCI going from negative to positive crossing and vice versa. Reason being that we are going with the momentum. And on the break of Pivot High or Pivot low if momentum is changing we will want to go wid it. And most of the time when momentum will be coming after an opposite move, CCI will most probably be between 0 and 100 or 0 and -100. Only on rapid breakouts wid high volume go beyond 100.

As far as exit rules are concerned. It can give one a mechanical Exit. But as i said that understanding is also required. I have mentioned two types of exit depending upon the trading personalities.

1. When the price bars again enter between the range of Pivot High and Pivot Low.

2. For more accurate exit. let CCI cross 100 or -100.

3. In a buy trade, if price keeps on rising with falling CCI, then risky traders can wait for 0 line to be crossed. Most probably with price rising and CCI approaching 100, CCI will also turn to upside, and then traders can exit on second cross of 100 line. Now a hitch here is that, what happened at the first moment of cci crossing 100 line can happen again. On second time of crossing 100 line price is still rising. So what to do now. A person understanding the working of CCI will immidiately understand that A ghost is under progress or a Horizontal Trend Line breakup (HTLB), and break for this type of trade is neck line break. This all comes after you have got the understanding of the CCI.

So plot the CCI also with the modified Turtle price you have posted. It will help.

Hope you get the point.
 
Last edited:

rajputz

Well-Known Member
#80
because this price range is based upon the mean deviation which can take place on average basis.
muje nahi pata ki jo mene likha hai wo kisi kaam ka hai ya nahi
par meri samajh me jo aaya mene likh diya
ab iska koi fayada hai ya nahi, ye aap batao
thanks
I Leave it upto you. It depends on how you want to understand the things. For me i go with the quote expressed by Einstein. "Everything should be made as simple as possible, but not one bit simpler".

Its good that you are understanding how the CCI is plotted. But dont complicate it with the working of the system.

Hope you get the point.
 
Last edited:

Similar threads