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

Pullbacks for Amibroker (AFL)

Rating:
3 / 5 (Votes 5)
Tags:
trading system, amibroker

Buy and Short just on pullbacks.

Similar Indicators / Formulas

EMA crossover
Submitted by Ketan-0 over 8 years ago
Kase Peak Osc. V2 batu
Submitted by batu1453 about 5 years ago
Kase CD V2batu
Submitted by batu1453 about 5 years ago
Ichimoku
Submitted by prashantrdx over 5 years ago
buy and sell two EMAS
Submitted by mundo0007 over 7 years ago
Adaptive Price Zone (APZ)
Submitted by AndrewThomas over 8 years ago

Indicator / Formula

Copy & Paste Friendly
("jayeshbhai 1.1 + Roc");
//OptimizerSetEngine("cmae");
 
SetChartOptions(0,chartShowArrows|chartShowDates);


SetChartBkColor(ColorRGB(49,79,79));
 
_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",6,1,21,1),5,21,1);
nbar = 6;
//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.16,0.10,0.50,0.01),0.10,0.50,0.01);
FibNum = 0.16;
//FibNum =FB[FBindex];
//F=Optimize("F",Param("F",10,5,50,1),5,50,1);
f = 10;
// 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;
}
}
}




//Plot(StoMom, _DEFAULT_NAME(), ParamColor("Color", ColorCycle ) );
_SECTION_END();



pivot = ParamToggle("pivot","Show|Hide",0);
Buyselllable = ParamToggle("Buysell-lable","Show|Hide",0);
NormalCandle=ParamToggle("Plot Normal Candle", "No,Yes", 1 );
messageboard = ParamToggle("Message Board","Show|Hide",0);
font = ParamToggle("font","Show|Hide",1);
GraphXSpace = Param( "GraphXSpace", 8, 2, 200, 1 );

p = 4;
//p = Param("p",5,2,100,1);
_SECTION_BEGIN("Trend Lines");
//p1 = Param("TL 1 Periods", 20, 5, 50, 1);
p1 = 29;
p2 = 7;
//p2 = Param("TL 2 Periods", 5, 3, 25, 1);
TL1 = LinearReg(C, p1);
TL2 = MA(TL1, p2);
Col1 = IIf(TL1 > TL2, ParamColor("TL Up Colour", colorGreen), ParamColor("TL Dn Colour", colorRed));
Plot(TL1, "TriggerLine 1", Col1, styleLine|styleThick|styleNoLabel);
Plot(TL2, "TriggerLine 2", Col1, styleLine|styleThick|styleNoLabel);
_SECTION_END();

SetChartOptions(0,chartShowArrows|chartShowDates);
//_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
//SetChartBkGradientFill(ParamColor("Top", colorTeal), ParamColor("Bottom", colorLightGrey), ParamColor("Title", colorTeal));
//SetChartBkColor(colorTeal);
 
 
//SetForeign(Vr);
 

Om=DEMA(O,p);
hm=DEMA(H,p);
lm=DEMA(L,p);
Cm=DEMA(C,p);
HAC=(Om+Hm+Lm+Cm)/4;
//HaC =(O+H+L+C)/4;
HaO = AMA( Ref( HaC, -16 ), 0.5 );
HaH = Max( H, Max( HaC, HaO) );
HaL = Min( L, Min( HaC, HaO) );
HAClose=(Om+Hm+Lm+Cm)/4;
//HaC =(O+H+L+C)/4;
HaOpen = AMA( Ref( HaC, -1 ), 0.5 );
HaHigh = Max( H, Max( HaC, HaO) );
HaLow = Min( L, Min( HaC, HaO) );
BG3=HHV(LLV(HaL,18)+ATR(8),10);
BR3=LLV(HHV(HaH ,4)-ATR(4),2);
co = IIf(Hac>BG3 ,colorDarkGreen,IIf(Hac < BR3,colorDarkRed,colorGrey50));
Plot(4, "", Co,styleArea+styleOwnScale | styleNoLabel, -1, 100);
RestorePriceArrays();
if(NormalCandle==1  )
{
  PlotOHLC( Hac, Hao, Hah, Hal, " " , co, styleCandle | styleThick );
}
else
{
//PlotOHLC( Open, High, Low, Close, " " ,co, styleCandle | styleThick );
 
}
//Plot( C, "Close", colorWhite, styleCandle, Zorder = 1);
SetChartOptions(0,chartShowArrows | chartShowDates);

tempo = TimeNum() > 091000 AND TimeNum() < 165000;
saida = TimeNum() > 170000;



ww=Optimize("ww",1,1,21,1);
//yy=Optimize("yy",1,1,21,1);

Buy = TL1>TL2

AND jackpotsell 
AND tempo
AND ADX(8) > 19

AND TL1 - Haclose < 140
AND TL2 - Haclose < 155

//AND abs(H-L) > 68

//AND abs(Ref(L,-1)-Ref(C,-1)) < 118
AND ADX(34) < 40
AND ADX(21) < 59
AND ADX(9) < 56
AND ADX(4) < 79
AND ADX(2) < 98
AND PDI(89) < 32
AND PDI(34) < 51


//AND ADX(9) > 18
AND PDI(6) > 12

AND Ultimate(4,4,28) < 70
AND Ultimate(9,1,28) < 60

AND Ultimate(7,6,85) > 35
AND Ultimate(6,1,85) > 30
AND Ultimate(21,5,5) > 40
AND Wilders(C,7) < MA(C,3)


AND ADX(5) > MDI(5)
AND MFI(8) > (15)

//AND abs(O-C) < 200
AND abs(C-MA(C,89)) > 3
//AND abs(C-MA(C,21)) < 166

//AND abs(C-MA(C,9)) < 131
//AND abs(C-MA(C,50)) > ww
AND ADX(15) > 11
//AND ADX(10) > ww

AND RWI(2,14) > -0.5
AND RWI(3,3) < 1.5
AND RMI(3,6) > 30
AND RSI(89) < 61
AND RSI(21) < 65
AND RSI(9) < 65
AND RSI(4) < 67
AND RSI(2) < 61


AND MA(C,3) > MA(C,1)
//AND Ultimate(17,6,28) > 40

//AND abs(tl2-Hac) < 185
//AND abs(Hac-C) < 105
//AND abs(Hah-H) < 170
//AND abs(Hac-Ref(C,-21)) > ww
AND abs(Hac-Ref(Hac,-4)) > 1

//AND Trix(30) > -0.4

;


Short = 
TL1<TL2 
AND tempo
AND JackPotCover 
AND Ultimate(12,6,5) < 70
AND Ultimate(21,5,5) < 60

AND Ultimate(7,14,85) < 50

AND Ultimate(3,3,85) > 30
AND Ultimate(12,6,85) > 35
AND Ultimate(1,5,5) > 40

AND ADX(21) > 12
//AND Ultimate(4,19,28) < 59

AND ADX(5) > MDI(5)
AND MA(C,15) > MA(C,5)
AND MA(C,4) < Wilders(C,5)

AND MDI(14) > 12
AND RWI(11,12) < 0
AND ADX(34) < 40
AND ADX(21) < 45
AND ADX(9) < 57
AND ADX(4) < 90
AND ADX(2) < 100
AND ADX(34) > 9
AND ADX(21) > 13
AND ADX(9) > 16


AND RSI(34) > 33
AND RSI(21) > 31
AND RSI(9) > 28
AND RSI(4) > 27
AND RSI(2) > 26
AND RSI(34) < 59
AND RSI(21) < 60
AND RSI(9) < 65
AND RSI(4) < 83


AND RMI(5,6) < 50
//AND RMI(1,12) < 60
//AND RMI(10,1) > 30
//AND RSI(89) < 57
//AND RSI(21) < 68
//AND RSI(9) < 59
AND Trix(1) > -0.2

AND abs(H-L) > 21
//AND abs(O-C) < 110
AND abs(C-MA(C,89)) > 5
//AND abs(C-MA(C,21)) > 46
//AND abs(C-MA(C,200)) > 74
//AND abs(C-MA(C,300)) > 17
AND abs(C-MA(C,50)) > 3
AND MFI(12) > 14
//AND MDI(ww) > yy


//AND MA(C,5) < MA(C,16)
AND RSI(10) < 50
//AND Hac<Bg3  
AND Ultimate(17,4,28) > 39
//AND abs(Hac-C) < 190
AND abs(Hac-Ref(C,-12)) > 2
AND abs(Hac-Ref(Hac,-12)) > 2

;


Buy = ExRem(Buy,Short);
Short = ExRem(Short,Buy);

Sell = Short OR saida;
Cover = Buy OR saida;




PlotShapes( IIf( Buy == 1, shapeUpArrow, shapeNone ), colorLime, 0, Low );
PlotShapes( IIf( Short == 1, shapeDownArrow, shapeNone ), colorRed, 0, High );




GraphXSpace = 8;dist = 1.2*ATR(21);

for( i = 0; i < BarCount; i++)
{

if( Buy[i] ) PlotText( "" + C[ i ], i, L[ i ]-dist[i], colorLime );
if( Short[i] ) PlotText( "" + C[ i ], i, H[ i ]+dist[i], colorRed);





}

7 comments

1. evereadysweta

good

2. hoierman

Doesn’t show trading Arrows. Would like to change chart Background color – how?

Dick

3. administrator

@hoierman you can change background on line 7. Most likely there are no trading arrows because the buy and sell rules are too restrictive and no signals are being generated (My guess without testing).

4. vjragx

very good but downtrend can be indicated with better colours

5. trader888

You guys can change the restrictive signals and change it for each market or stock etc…

6. vjragx

good one

7. sachin11

Great.

Leave Comment

Please login here to leave a comment.

Back