Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

SHIV SABHU + ROC for Amibroker (AFL)

Rating:
3 / 5 (Votes 7)
Tags:
amibroker, optimize

THIS IS FIBONACI BASED AFL WITH USE OF ROC FOR RIGHT TREND AND IT AVOID TRADE AGAINST TREND.

Similar Indicators / Formulas

Didi Index
Submitted by moapereira almost 8 years ago
CCI System
Submitted by sandipsc over 9 years ago
Automatic Linear Trend (Edited)
Submitted by hariom over 6 years ago
EMA CROSSOVER
Submitted by sudesh over 9 years ago
HaConnorsRSI
Submitted by RBuck over 6 years ago
open brake system
Submitted by pit65 about 9 years ago

Indicator / Formula

Copy & Paste Friendly
_SECTION_BEGIN("SHIVSHAMBHU+ROC 1.1");
_SECTION_BEGIN
("jayeshbhai 1.1 + Roc"); 
OptimizerSetEngine("cmae"); 

SetChartOptions(0,chartShowArrows|chartShowDates); 

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

SetBarsRequired(sbrAll,sbrAll); 

xx =Cum(1); 
//nbar =Optimize("NBar",Param("nbar",5,2,400,1),2,400,1); 
nbar =Optimize("nbar",Param("nbar",10,5,2000,1),5,2000,1); 
//FB[0] = 0.28;FB[1] = 0.28; FB[2] = 0.38; FB[3] = 0.50; FB[4] = 0.61; FB[5] = 1; FB[6] =1.61; FB[7] = 2.61; FB[8] = 4.23; 
FibNum = Optimize("FBindex",Param("FBindex",0.56,0.10,0.50,0.01),0.10,0.50,0.01); 
//FibNum =FB[FBindex]; 
F=Optimize("F",Param("F",15,5,50,1),5,50,1);

// define fractals 
PHigh = C > Ref(HHV(C,nbar),-1) AND Ref(HHV(C,nbar),0) <= C; 
PHighPrice =ValueWhen(PHigh,C); 
PLow = C < Ref(LLV(C,nbar),-1) AND Ref(LLV(C,nbar),0) >= C; 
PLowPrice = ValueWhen(PLow,C); 
PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10); 
PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10); 
R = PHighPrice - PLowPrice; 
// range 
//R4 = PHighPrice-(R *0.11 ); 
//S4 = PLowPrice +(R *0.11); 
R4 = PHighPrice -(R * FibNum ); 
S4 = PLowPrice + (R * FibNum ); 
BSL= PLowPrice; 
SSL= PHighPrice; 


Plot(R4, "",colorOrange,styleStaircase); 
Plot(S4, "",colorGreen,styleStaircase); 
Plot(SSL, "",colorAqua,styleStaircase); 
Plot(BSL, "",colorAqua,styleStaircase); 

//Buy = Cover = Cross(C, S4); 
//Sell = Short = Cross(R4, C); 
BuyFlag_ = False; 
SellFlag =False; 
BuyFlag = False; 
temp1 =True; 
temp2= True; 
FinalSell =False; 
FinalBuy = False; 

for
(i=1 ; i < BarCount ; i++){ 
if(PHigh[i]){ 
SellFlag =True; 
BuyFlag = False; 
} 
if(SellFlag){ 
if( (C[i-1] > R4[i-1] AND C[i] < R4[i]) AND temp1 ) { 
SellFlag=False;
FinalSell[i]=True;
temp2=True; 
temp1=False; 
}
} 
if(temp2){ 
if( C[i] > PHighPrice[i-1] ){ 
FinalBuy[i]=True; 
temp2=False;
temp1=True;
} 
} 
if(PLow[i]){ 
BuyFlag = True; 
SellFlag =False; 
} 
if(BuyFlag){ 
if( (C[i-1] < S4[i-1] AND C[i] > S4[i]) AND temp2 ){ 
BuyFlag=False; 
BuyFlag_=True; 
FinalBuy[i]=True; 
temp2=False; 
temp1=True; 
} 
} 
if(temp1){ 
if( C[i] < PLowPrice[i-1] ){ 
FinalSell[i]=True;
temp2=True; 
temp1=False; 
} 
} 



} 
test1Flag = False;
test2Flag = False;
test1Flag_ = False;
test2Flag_ = False;
JackPotSell = False;
JackPotBuy = False;
JackPotCover = False;
JackPotShort = False;
t1 = False;
t2 = False;
t3 = False;
t4 = False;
t5 = False;
R = ROC(Close,F);

for
(i=1 ; i < BarCount ; i++){ 
if((FinalBuy[i])){
if(t5){
JackPotCover[i]= True;
t5 =False;
}
t1 = True;
}
if(R[i] > 0 ){
if(t1){
JackpotBuy[i] = True;
t3 = True;
t1= False;
}
}
if((FinalSell[i])){
if(t3){
JackPotSell[i]= True;
t3 =False;
}
t4 = True;
}
if(R[i] < 0 ){
if(t4){
JackPotShort[i] = True;
t5 = True;
t4= False;
}
}
}
Buy= JackPotBuy;
Sell= JackPotSell;
Short= JackPotShort;
Cover= JackPotCover;
/*Buy = FinalBuy AND ROC(Close,10)>0; 
Sell= FinalBuy AND ROC(Close,10)<0 OR FinalSell AND ROC(Close,10)>0; 
Short= FinalSell AND ROC(Close,10)<0; 
Cover= FinalSell AND ROC(Close,10)>0 OR FinalBuy AND ROC(Close,10)<0; 
*/
// plot arrows 
shape = Buy * shapeUpArrow + Short * shapeDownArrow; 
PlotShapes( shape, IIf( Buy, colorGreen, colorRed ), 0, IIf( Buy, Low, High ) ); 
shape11 = Cover * shapeUpTriangle+ Sell * shapeDownTriangle;
//PlotShapes( shape11, IIf( Cover , colorGreen, colorRed ), 0, IIf( Cover , Low, High ) ); 
//PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10); 
PlotShapes(shape11 ,IIf( Cover , colorGreen, colorRed ),0,IIf( Cover , Low, High ),-20);
_SECTION_END
();
_SECTION_END();

5 comments

1. arian

well done! and thanks for sharing.

2. navin

guru good

3. ole

Why are you using Optimize() when charting as it only returns the default value? If you want to optimize see the syntax description about the need to run in optimization mode.

4. kv_maligi

Hi Jay,

AfterLongtime, i have come across Very Good AFL.
Excellent & thanks for sharing for Group members

Viswanath

5. cute_marwarichora200

error shown in my amibroker 5.00 version

Leave Comment

Please login here to leave a comment.

Back