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

HRM INDEX RSI for Amibroker (AFL)

Rating:
4 / 5 (Votes 17)
Tags:
trading system, amibroker, exploration, pattern

modification done… harmonic generated signal buy/sell and
exploration and percentage change check by explore…

Screenshots

Similar Indicators / Formulas

Break away Candlesticks
Submitted by chandulal almost 12 years ago
double top in an uptrend
Submitted by caveroute over 13 years ago
quadra safe indicator
Submitted by vinay over 11 years ago
Intraday Trend Break System
Submitted by nishantndk almost 14 years ago
Double Dojis Exploration
Submitted by ami4me almost 11 years ago
20 Day High Breakout
Submitted by ashokram1 over 12 years ago

Indicator / Formula

Copy & Paste Friendly
font = ParamToggle("font","Show|Hide",0);
messageboard = ParamToggle("Message Board","Show|Hide",0);
prexplore= ParamToggle("perce/buysell","pers|buysell",1);

plotFractals = ParamToggle("Plot Fractals","Off|On",0);
if(font==0)
{
_SECTION_BEGIN("Name");
GfxSetOverlayMode(0);
GfxSelectFont("Tahoma", Status("pxheight")/8 );
GfxSetTextAlign( 6 );// center alignment
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
GfxSetBkMode(0); // transparent
GfxTextOut( Name(), Status("pxwidth")/2, Status("pxheight")/12 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxTextOut("" , Status("pxwidth")/2, Status("pxheight")/4 );
GfxSelectFont("Tahoma", Status("pxheight")/18 );
GfxSelectFont("Tahoma", Status("pxheight")/36 );
GfxTextOut( "", Status("pxwidth")/2, Status("pxheight")/3 );
_SECTION_END();

//Magfied Market Price
GfxSetTextAlign( 6 );// center alignment
FS=Param("Font Size",72,11,100,1);
GfxSelectFont("Times New Roman", FS, 700, True ); 
GfxSetBkMode(0); // transparent 
GfxSetTextColor( ColorHSB( 42, 42, 42 ) );
Hor=Param("Horizonta Position",615,1,1200,1);
Ver=Param("Vertica Position",152,1,830,1); 
GfxTextOut(""+C, Hor , Ver );
YC=TimeFrameGetPrice("C",inDaily,-1);
DD=Prec(C-YC,2);
GfxSetTextAlign( 6 );// center alignment
xx=Prec((DD/YC)*100,2);
FS2=Param("Font Size2",35,11,100,1);
GfxSelectFont("Times New Roman", FS2,11, 700, True ); 
GfxSetBkMode( colorBlack );
Hor1=Param("Horizontal Position",615,1,1200,1);
Ver1=Param("Vertical Position",188,1,830,1);   
GfxSetTextColor( ColorHSB( 42, 42, 42 ) ); 
GfxTextOut(""+DD+"  ("+xx+"%)", Hor1 , Ver1+45 );
}
else
{{
//Magfied Market Price
GfxSetTextAlign( 6 );// center alignment
fse=Param("Font Sizee",35,11,100,1);
GfxSelectFont("Times New Roman", fse, 700, True ); 
GfxSetBkMode( colorGold );  
GfxSetTextColor( ParamColor("Color",colorGold) ); 
Hora=Param("Horizontal Positiona",525,1,1200,1);
Vera=Param("Vertical Positiona",17,1,830,1); 
GfxTextOut(""+C, Hora , Vera );
YCa=TimeFrameGetPrice("C",inDaily,-1);
DDa=Prec(C-YCa,2);
GfxSetTextAlign( 6 );// center alignment
xxa=Prec((DDa/YCa)*100,2);
FSb=Param("Font Sizeb",16,11,100,1);
GfxSelectFont("Times New Roman",fsb, 700, True ); 
GfxSetBkMode( colorBlack );  
GfxSetTextColor(ParamColor("Color",colorYellow) ); 
GfxTextOut(""+DDa+"  ("+xxa+"%)", Hora , Vera+45 );
 _SECTION_END();
}}

_SECTION_BEGIN("EMA Time Frame");
r= RSI(14);
Plot(r,"",colorBlack,styleDots+styleThick);
W1=ValueWhen(HHV(r,14),r,2);
Plot(30 , "", colorDarkRed); 
Plot(50, "", colorWhite,styleDashed);
Plot(70, "", colorDarkRed);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "",3.2,3.2);
hts = Param ("Text Shift", -50,-100,100,10);
PlotText(">>>" + WriteVal(r,fraction),
SelectedValue(BarIndex())-(numbars/hts),SelectedValue(r),1);
PlotText("Bot= " + WriteVal(30,fraction),
SelectedValue(BarIndex()+2)-(numbars/hts),SelectedValue(30),colorDarkRed);
PlotText("Top= " + WriteVal(70,fraction),
SelectedValue(BarIndex()+2)-(numbars/hts),SelectedValue(70),colorDarkRed);
_SECTION_END();

_SECTION_BEGIN("Gartley");
GBmin = Param("Swing B Min.",0.55,0.3,1,0.01);
GBmax = Param("Swing B Max.",0.72,0.4,1,0.01);
GCmin = Param("Swing C Min.",0.38,0.3,1.27,0.01);
GCmax = Param("Swing C Max.",1.0,0.4,1.27,0.01);
GDmin = Param("Swing D Min.(XA)",0.55,0.3,1,0.01);
GDmax = Param("Swing D Max.(XA)",1.0,0.4,1.0,0.01);
_SECTION_END();

_SECTION_BEGIN("Bat");
BatBmin = Param("Swing B Min.",0.38,0.3,1,0.01);
BatBmax = Param("Swing B Max.",0.55,0.4,1,0.01);
BatCmin = Param("Swing C Min.",0.38,0.3,1.62,0.01);
BatCmax = Param("Swing C Max.",1.27,0.4,1.62,0.01);
BatDmin = Param("Swing D Min.(XA)",0.5,0.3,1,0.01);
BatDmax = Param("Swing D Max.(XA)",1.0,0.4,1.0,0.01);
_SECTION_END();

_SECTION_BEGIN("Butterfly");
BtBmin = Param("Swing B Min.",0.55,0.3,1,0.01);
BtBmax = Param("Swing B Max.",0.9,0.4,1,0.01);
BtCmin = Param("Swing C Min.",0.38,0.3,1.62,0.01);
BtCmax = Param("Swing C Max.",1.27,0.4,1.62,0.01);
BtDmin = Param("Swing D Min.(XA)",1,1,1.8,0.01);
BtDmax = Param("Swing D Max.(XA)",1.38,1,1.8,0.01);
_SECTION_END();

_SECTION_BEGIN("Crab");
CBmin = Param("Swing B Min.",0.38,0.3,1,0.01);
CBmax = Param("Swing B Max.",0.65,0.4,1,0.01);
CCmin = Param("Swing C Min.",0.38,0.3,1.62,0.01);
CCmax = Param("Swing C Max.",1.270,0.4,1.62,0.01);
CDmin = Param("Swing D Min.(XA)",1.25,1,1.8,0.01);
CDmax = Param("Swing D Max.(XA)",1.8,1,2,0.01);
_SECTION_END();

_SECTION_BEGIN("Patterns");
strength = Param("Strength",5,2,15,1);
bu = ParamToggle("Bullish Pattern","Off|On",1);
be = ParamToggle("Bearish Pattern","Off|On",1);
bi = Cum(1)-1;
function GetTop(bars) 
{
Top =r== HHV(r,2*bars) AND Ref(HHV(r,bars),bars) < r;
Top = Top AND LastValue(bi)-ValueWhen(Top,bi) > bars;
return Top;
}
function GetValley(bars)
{
Valley = W1== LLV(W1,2*bars) AND Ref(LLV(W1,bars),bars) >W1;
Valley = Valley AND LastValue(bi)-ValueWhen(Valley,bi) > bars;
return Valley;
}
P1 = GetTop(strength);
V1 = GetValley(Strength);
P1 = IIf(P1,IIf(ValueWhen(P1,bi,2) < ValueWhen(V1,bi),P1,IIf(ValueWhen(P1,r,2) >r,False,P1)),P1);
P1 = IIf(P1 AND ValueWhen(P1,bi,0) > bi AND NOT(ValueWhen(V1,bi,0) > 0 AND ValueWhen(V1,bi,0)<ValueWhen(P1,bi,0)),IIf(ValueWhen(P1,r)<=ValueWhen(P1,r,0), False,P1),P1);
V1 = IIf(V1,IIf(ValueWhen(V1,bi,2) < ValueWhen(P1,bi),V1,IIf(ValueWhen(V1,W1,2)<W1,False,V1)),V1);
V1 = IIf(V1 AND ValueWhen(V1,bi,0) > bi AND NOT(ValueWhen(P1,bi,0) > bi AND ValueWhen(P1,bi,0)<ValueWhen(V1,bi,0)) , IIf(ValueWhen(V1,W1)>=ValueWhen(V1,W1,0),False,V1),V1);

P1H1 = ValueWhen(P1,r);
P1Bar1 = ValueWhen(P1,bi);
P1H2 = ValueWhen(P1,r,2);
P1Bar2 = ValueWhen(P1,bi,2);
V1L1 = ValueWhen(V1,W1);
V1Bar1 = ValueWhen(V1,bi);
V1L2 = ValueWhen(V1,W1,2);
V1Bar2 = ValueWhen(V1,bi,2);
PTvalid = (P1Bar1 > V1Bar1 AND V1Bar1 > P1Bar2 AND P1bar2 > V1Bar2) AND P1; 
BullGartley4 = PTvalid AND (P1H2-V1L1)/(P1H2-V1L2) > GBmin AND (P1H2-V1L1)/(P1H2-V1L2) < GBmax
AND (P1H1-V1L1)/(P1H2-V1L1) > GCMin AND (P1H1-V1L1)/(P1H2-V1L1) < GCMax; 
BullBat4 = PTvalid AND (P1H2-V1L1)/(P1H2-V1L2) > BatBmin AND (P1H2-V1L1)/(P1H2-V1L2) < BatBmax
AND (P1H1-V1L1)/(P1H2-V1L1) > BatCMin AND (P1H1-V1L1)/(P1H2-V1L1) < BatCMax; 
BullButterfly4 = PTvalid AND (P1H2-V1L1)/(P1H2-V1L2) > BtBmin AND (P1H2-V1L1)/(P1H2-V1L2) < BtBMax
AND (P1H1-V1L1)/(P1H2-V1L1) > BtCmin AND (P1H1-V1L1)/(P1H2-V1L1) < BtCmax; 
BullCrab4 = PTvalid AND (P1H2-V1L1)/(P1H2-V1L2) >CBmin AND (P1H2-V1L1)/(P1H2-V1L2) < CBmax 
AND (P1H1-V1L1)/(P1H2-V1L1) > CCmin AND (P1H1-V1L1)/(P1H2-V1L1) < CCmax; 
BullGartley = IIf(LowestSince(BullGartley4,W1) < ValueWhen(BullGartley4,P1H2)-(ValueWhen(BullGartley4,P1H2)-ValueWhen(BullGartley4,V1L2))*GDmin AND
LowestSince(bullGartley4,W1) > ValueWhen(BullGartley4,P1H2)-(ValueWhen(BullGartley4,P1H2)-ValueWhen(BullGartley4,V1L2))*GDmax AND
HighestSince(BullGartley4,r) <= ValueWhen(BullGartley4,P1H1 ) AND
LowestSince(bullGartley4,W1)==W1, True,False);
BullGartley = BullGartley AND LowestSince(BullGartley4,W1) < ValueWhen(BullGartley4,V1L1);
BullBat = IIf(LowestSince(BullBat4,W1) < ValueWhen(BullBat4,P1H2)-(ValueWhen(BullBat4,P1H2)-ValueWhen(BullBat4,V1L2))*BatDmin AND
LowestSince(BullBat4,W1) > ValueWhen(BullBat4,P1H2)-(ValueWhen(BullBat4,P1H2)-ValueWhen(BullBat4,V1L2))*BatDmax AND
HighestSince(BullBat4,r) <= ValueWhen(BullBat4,P1H1 ) AND
LowestSince(BullBat4,W1)==W1, True,False);
BullBat = BullBat AND LowestSince(BullCrab4,W1) < ValueWhen(BullCrab4,V1L1);
BullCrab = IIf(LowestSince(BullCrab4,W1) < ValueWhen(BullCrab4,P1H2)-(ValueWhen(BullCrab4,P1H2)-ValueWhen(BullCrab4,V1L2))*CDmin AND
LowestSince(BullCrab4,W1) > ValueWhen(BullCrab4,P1H2)-(ValueWhen(BullCrab4,P1H2)-ValueWhen(BullCrab4,V1L2))*CDmax AND
HighestSince(BullCrab4,r) <= ValueWhen(BullCrab4,P1H1 ) AND
LowestSince(bullGartley4,W1)==W1, True,False);
BullCrab = BullCrab AND LowestSince(BullCrab4,W1) < ValueWhen(BullCrab4,V1L2);
BullButterfly = IIf(LowestSince(BullButterfly4,W1) < ValueWhen(BullButterfly4,P1H2)-(ValueWhen(BullButterfly4,P1H2)-ValueWhen(BullButterfly4,V1L2))*BtDMin AND
LowestSince(BullButterfly4,W1) > ValueWhen(BullButterfly4,P1H2)-(ValueWhen(BullButterfly4,P1H2)-ValueWhen(BullButterfly4,V1L2))*BtDmax AND
HighestSince(BullButterfly4,r) <= ValueWhen(BullButterfly4,P1H1 ) AND
LowestSince(bullButterfly4,W1)==W1, True,False);
BullButterfly = BullButterfly AND LowestSince(BullButterfly4,W1) < ValueWhen(BullButterfly4,V1L2);
BullHar4 = BullGartley4 OR BullButterfly4 OR BullBat4 OR BullCrab4 ;
BullHar = BullGartley OR BullButterfly OR BullBat OR BullCrab ;
Point4 = IIf(BullHar,ValueWhen(BullHar4,bi),Null);
BullHar = IIf(BullHar, IIf(Point4 == ValueWhen(BullHar,point4,0) AND ValueWhen(BullHar,bi,0) > bi ,False,BullHar),BullHar);
X = ValueWhen(BullHar4,V1L2);
Xbar = ValueWhen(BullHar4,V1Bar2);
A = ValueWhen(BullHar4,P1H2);
Abar = ValueWhen(BullHar4,P1bar2);
B = ValueWhen(BullHar4,V1L1);
Bbar = ValueWhen(BullHar4,V1bar1);
C1 = ValueWhen(BullHar4,P1H1);
C1bar = ValueWhen(BullHar4,P1bar1);
D = ValueWhen(BullHar,W1);
Dbar = ValueWhen(BullHar,bi);
ABdXA = (A-B)/(A-X);
BCdAB = (C1-B)/(A-B);
ADdXA = (A-D)/(A-X);
BCdCD = (C1-D)/(C1-B);
PlotPattern = Dbar > C1bar;
if(LastValue(PlotPattern) AND bu)
{
Plot( LineArray(LastValue(Xbar),LastValue(X),LastValue(Abar),LastValue(A)),"",colorBlue,styleThick);
Plot(LineArray(LastValue(Abar),LastValue(A),LastValue(Bbar),LastValue(B)),"",colorBlue,styleThick);
Plot(LineArray(LastValue(Bbar),LastValue(B),LastValue(C1bar),LastValue(C1)),"" ,colorBlue,styleThick);
Plot(LineArray(LastValue(C1bar),LastValue(C1),LastValue(Dbar),LastValue(D)),"" ,colorBlue,styleThick);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Bbar),LastValue(B)),"",colorBlue,styleDashed);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Abar),LastValue(A)),"",colorBlue,styleThick);
Plot(LineArray(LastValue(Abar),LastValue(A),LastValue(C1bar),LastValue(C1)),"" ,colorBlue,styleDashed);
Plot(LineArray(LastValue(Bbar),LastValue(B),LastValue(Dbar),LastValue(D)),"",colorBlue,styleDashed);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Dbar),LastValue(D)),"",colorBlue,styleDashed);
PlotText(NumToStr(LastValue(ABdXA),1.2),(LastValue(Bbar)+LastValue(Xbar))/2,(LastValue(B)+LastValue(X))/2,colorBlue);
PlotText(NumToStr(LastValue(BCdAB),1.2),(LastValue(C1bar)+LastValue(Abar))/2,(LastValue(C1)+LastValue(A))/2,colorBlue);
PlotText(NumToStr(LastValue(ADdXA),1.2) ,(LastValue(Dbar)+LastValue(Xbar))/2,(LastValue(D)+LastValue(X))/2,colorBlue);
PlotText(NumToStr(LastValue(BCdCD),1.2),(LastValue(Bbar)+LastValue(Dbar))/2,(LastValue(B)+LastValue(D))/2,colorBlue);
}
PTvalid = (V1Bar1 > P1Bar1 AND P1Bar1 > V1Bar2 AND V1Bar2 > P1Bar2) AND V1;
BearGartley4 = PTvalid AND (P1H1-V1L2)/(P1H2-V1L2) > GBmin AND (P1H1-V1L2)/(P1H2-V1L2) < GBmax AND
(P1H1-V1L1)/(P1H1-V1L2) > GCmin AND (P1H1-V1L1)/(P1H1-V1L2) < GCmax;
BearBat4 = PTvalid AND (P1H1-V1L2)/(P1H2-V1L2) > BatBmin AND (P1H1-V1L2)/(P1H2-V1L2) < BatBmax AND
(P1H1-V1L1)/(P1H1-V1L2) > BatCmin AND (P1H1-V1L1)/(P1H1-V1L2) < BatCmax;
BearButterfly4 = PTvalid AND (P1H1-V1L2)/(P1H2-V1L2) > BtBmin AND (P1H1-V1L2)/(P1H2-V1L2) < BtBmax AND
(P1H1-V1L1)/(P1H1-V1L2) > BtCmin AND (P1H1-V1L1)/(P1H1-V1L2) < BtCmax;
BearCrab4 = PTvalid AND (P1H1-V1L2)/(P1H2-V1L2) > CBmin AND (P1H1-V1L2)/(P1H2-V1L2) < CBmax AND
(P1H1-V1L1)/(P1H1-V1L2) > CCmin AND (P1H1-V1L1)/(P1H1-V1L2) < CCmax;
BearGartley = IIf(HighestSince(bearGartley4,r) > ValueWhen(BearGartley4,V1L2) + (ValueWhen(BearGartley4,P1H2) - ValueWhen(BearGartley4,V1L2))*GDmin AND
HighestSince(bearGartley4,r) < ValueWhen(BearGartley4,V1L2) + (ValueWhen(BearGartley4,P1H2) - ValueWhen(BearGartley4,V1L2))*GDMax AND 
LowestSince(BearGartley4,W1) >= ValueWhen(BearGartley4,V1L1 ) AND
HighestSince(BearGartley4,r) ==r, True, False);
BearGartley = BearGartley AND HighestSince(BearGartley4,r) > ValueWhen(BearGartley4,P1H1);
BearBat = IIf((HighestSince(BearBat4,r) > ValueWhen(BearBat4,V1L2) + (ValueWhen(BearBat4,P1H2) - ValueWhen(BearBat4,V1L2))*BatDmin AND
HighestSince(BearBat4,r) < ValueWhen(BearBat4,V1L2) + (ValueWhen(BearBat4,P1H2) - ValueWhen(BearBat4,V1L2))*BatDMax AND 
LowestSince(BearBat4,W1) >= ValueWhen(BearBat4,V1L1 ) AND
HighestSince(BearBat4,r) == r), True, False);
BearBat = BearBat AND HighestSince(BearBat4,r) > ValueWhen(BearBat4,P1H1);
BearButterfly = IIf(HighestSince(BearButterfly4,r) > ValueWhen(BearButterfly4,V1L2) + (ValueWhen(BearButterfly4,P1H2) - ValueWhen(BearButterfly4,V1L2))*BtDmin AND
HighestSince(BearButterfly4,r) < ValueWhen(BearButterfly4,V1L2) + (ValueWhen(BearButterfly4,P1H2) - ValueWhen(BearButterfly4,V1L2))*BtDMax AND 
LowestSince(BearButterfly4,W1) >= ValueWhen(BearButterfly4,V1L1 ) AND
HighestSince(BearButterfly4,r) == r, True, False);
BearButterfly = BearButterfly AND HighestSince(BearButterfly4,r) > ValueWhen(BearButterfly4,P1H2);
BearCrab = IIf(HighestSince(BearCrab4,r) > ValueWhen(BearCrab4,V1L2) + (ValueWhen(BearCrab4,P1H2) - ValueWhen(BearCrab4,V1L2))*CDmin AND
HighestSince(BearCrab4,r) < ValueWhen(BearCrab4,V1L2) + (ValueWhen(BearCrab4,P1H2) - ValueWhen(BearCrab4,V1L2))*CDMax AND 
LowestSince(BearCrab4,W1) >= ValueWhen(BearCrab4,V1L1 ) AND
HighestSince(BearCrab4,r) ==r, True, False);
BearCrab =BearCrab AND HighestSince(BearCrab4,r) > ValueWhen(BearCrab4,P1H2);
BearHar4 = BearGartley4 OR BearButterfly4 OR BearBat4 OR BearCrab4 ;
BearHar = BearGartley OR BearButterfly OR BearBat OR BearCrab ;
Point4 = IIf(BearHar,ValueWhen(BearHar4,bi),Null);
BearHar = IIf(BearHar, IIf(Point4 == ValueWhen(BearHar,point4,0) AND ValueWhen(BearHar,bi,0) > bi ,False,BearHar),BearHar);
X = ValueWhen(BearHar4,P1H2);
Xbar = ValueWhen(BearHar4,P1Bar2);
A = ValueWhen(BearHar4,V1L2);
Abar = ValueWhen( BearHar4,V1bar2);
B = ValueWhen(BearHar4,P1H1);
Bbar = ValueWhen(BearHar4,P1bar1);
C1 = ValueWhen(BearHar4,V1L1);
C1bar = ValueWhen(BearHar4,V1bar1);
D = ValueWhen(BearHar,r);
Dbar = ValueWhen(BearHar,bi);
ABdXA = (B-A)/(X-A);
BCdAB = (B-C1)/(B-A);
ADdXA = (D-A)/(X-A);
BCdCD = (D-C1)/(B-C1);
PlotPattern = Dbar > C1bar;
if(LastValue(Plotpattern) AND be)
{
Plot( LineArray(LastValue(Xbar),LastValue(X),LastValue(Abar),LastValue(A)),"",colorWhite,styleThick);
Plot(LineArray(LastValue(Abar),LastValue(A),LastValue(Bbar),LastValue(B)),"",colorWhite,styleThick);
Plot(LineArray(LastValue(Bbar),LastValue(B),LastValue(C1bar),LastValue(C1)),"" ,colorWhite,styleThick);
Plot(LineArray(LastValue(C1bar),LastValue(C1),LastValue(Dbar),LastValue(D)),"" ,colorWhite,styleThick);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Bbar),LastValue(B)),"",colorWhite,styleDashed);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Abar),LastValue(A)),"",colorWhite,styleThick);
Plot(LineArray(LastValue(Abar),LastValue(A),LastValue(C1bar),LastValue(C1)),"" ,colorWhite,styleDashed);
Plot(LineArray(LastValue(Bbar),LastValue(B),LastValue(Dbar),LastValue(D)),"",colorWhite,styleDashed);
Plot(LineArray(LastValue(Xbar),LastValue(X),LastValue(Dbar),LastValue(D)),"",colorWhite,styleDashed);
PlotText(NumToStr(LastValue(ABdXA),1.2),(LastValue(Bbar)+LastValue(Xbar))/2,(LastValue(B)+LastValue(X))/2,colorWhite);
PlotText(NumToStr(LastValue(BCdAB),1.2),(LastValue(C1bar)+LastValue(Abar))/2,(LastValue(C1)+LastValue(A))/2,colorWhite);
PlotText(NumToStr(LastValue(BCdCD),1.2) ,(LastValue(Dbar)+LastValue(Bbar))/2,(LastValue(D)+LastValue(B))/2,colorWhite);
PlotText(NumToStr(LastValue(ADdXA),1.2) ,(LastValue(Dbar)+LastValue(Xbar))/2,(LastValue(D)+LastValue(X))/2,colorWhite);
}
LatPattern = bullHar OR bearHar;
Lastpattern = LastValue(ValueWhen(LatPattern,IIf(BullGartley,1,IIf(BearGartley,-1,IIf(BullBat,2,IIf(BearBat,-2,
IIf(BullButterfly,3,IIf(BearButterfly,-3,IIf(BullCrab,4,IIf(BearCrab,-4,Null))))))))));
PatternName = WriteIf(LastPattern == 1,"Bullish Gartley",WriteIf(LastPattern == -1,"Bearish Gartley",WriteIf(LastPattern == 2,"Bullish Bat",
WriteIf(LastPattern == -2,"Bearish Bat",WriteIf(LastPattern == 3,"Bullish Butterfly",WriteIf(LastPattern == -3,"Bearish Butterfly",
WriteIf(LastPattern == 4,"Bullish Crab",WriteIf(LastPattern == -4,"Bearish Crab","None"))))))));
Buy=bullhar;
Sell=bearhar;
Cover=Buy;
Short=Sell;


PlotShapes(IIf(Buy,shapeUpTriangle,shapeNone),colorGreen,0,r,-10);
PlotShapes(IIf(Buy,shapeHollowUpTriangle,shapeNone),colorWhite,0,r,-10);
//PlotShapes(IIf(Buy,shapeHollowCircle,shapeNone),colorWhite,0,r,-10);
 
PlotShapes(IIf(Sell,shapeDownTriangle,shapeNone),colorRed,0,r,-10);
PlotShapes(IIf(Sell,shapeHollowDownTriangle,shapeNone),colorWhite,0,r,-10);
//PlotShapes(IIf(Sell,shapeHollowCircle,shapeNone),colorWhite,0,r,-10);

PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorGreen,0,r,-10);
PlotShapes(IIf(Buy,shapeHollowUpArrow,shapeNone),colorWhite,0,r,-10);
//PlotShapes(IIf(Buy,shapeHollowSmallCircle,shapeNone),colorWhite,0,r,-10);
 
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,r,-10);
PlotShapes(IIf(Sell,shapeHollowDownArrow,shapeNone),colorWhite,0,r,-10);
//PlotShapes(IIf(Sell,shapeHollowSmallCircle,shapeNone),colorWhite,0,r,-10); 


//PlotShapes(IIf(bullHar,shapeHollowUpTriangle,shapeNone),colorWhite,0,r,-10); 
//PlotShapes(IIf(bullHar,shapeSmallUpTriangle,shapeNone),colorBlack,0,r,-13); 
//PlotShapes(IIf(bearHar,shapeHollowDownTriangle, shapeNone),colorWhite,0,r,-10);
//PlotShapes(IIf(bearHar,shapeSmallDownTriangle, shapeNone),colorBlack,0,r,-13);

if(PlotFractals)
//GfxSetTextColor(IIf(LastPattern > 0, colorGreen,colorYellow));
//GfxTextOut("Last Pattern : " + PatternName,0,50);
_SECTION_END();

SetChartBkGradientFill( ParamColor("BgTop", colorBrightGreen),ParamColor("BgBottom", colorGreen));
SetChartBkColor(ParamColor("Outer panel",colorYellow)); 

_SECTION_BEGIN("AuthorName");
k = (GetPerformanceCounter()/100)%100; 
printf("GetPerformance Counter %g",k);
GfxSelectFont("jokerman", 14,800); 
GfxSetBkMode(1); 
GfxSetTextColor(colorWhite); 
GfxTextOut("Amibroker",-10+k,20); 
RequestTimedRefresh(10); 
_SECTION_END();

_SECTION_BEGIN("CompanySympole");
{	GfxSelectFont("Croobie",15,800 ); 
GfxSetBkMode(1); 
GfxSetTextColor(colorWhite);
//GfxTextOut( Name(),235,20); 
}
_SECTION_END();

_SECTION_BEGIN("CompanyClos");
{	GfxSelectFont("FRENCH SCRIPT MT",20, 800 ); 
GfxSetBkMode(1); 
GfxSetTextColor(colorWhite); 
GfxTextOut("C="+C+" ",850,200); 
}
_SECTION_END();

_SECTION_BEGIN("CompanyHigh");
{	GfxSelectFont("FRENCH SCRIPT MT",17, 800 ); 
GfxSetBkMode(1); 
GfxSetTextColor(colorCustom13); 
GfxTextOut("H="+H+" ",750,20); 
}
_SECTION_END();

_SECTION_BEGIN("CompanyOpen");
{	GfxSelectFont("FRENCH SCRIPT MT",17, 800 ); 
GfxSetBkMode(1); 
GfxSetTextColor(colorWhite); 
GfxTextOut("O="+O+" ",650,20); 
}
_SECTION_END();

_SECTION_BEGIN("CompanyLow");
{	GfxSelectFont("FRENCH SCRIPT MT",17, 800 ); 
GfxSetBkMode(1); 
GfxSetTextColor(colorYellow); 
GfxTextOut("L="+L+" ",550,20); 
}
_SECTION_END();
Cover=Buy;
Short=Sell;

Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
AlertIf( Buy, "", "BUY @ " + C, 1 );
AlertIf( Sell, "", "SELL @ " + C, 2 );
no=Param( "Swing", 8, 1, 55 );
tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

no =  Optimize("TSL",Param("A (Change To Optimise)",10, 1, 55 ,1),1, 55 ,1);

tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
dtsl=IIf(avn==1,sup,res);
SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));


CloseAtEnd = ParamToggle("Close Positions EOD", "No|Yes");
stopreverse =ParamToggle("Switch To Stop And Reverse","No|Yes",0);
Trend = ATR(21) < StDev (C,21);
Range = ATR(21) > StDev (C,21);
no=10;
C13=20;
C14=2.1;
C15=12;

tsl_col=ParamColor( "Color", colorLightGrey );
res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
dtsl=IIf(avd==1,sup,res);

SellPrice=ValueWhen(Short,C,1);
BuyPrice=ValueWhen(Buy,C,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Short,Cover);
Relax = NOT Long AND NOT Buy AND NOT shrt AND NOT Sell AND NOT Sell AND NOT Cover;
SellSL=ValueWhen(Short,DTSL,1);
BuySL=ValueWhen(Buy,DTSL,1);
BuyDifference= BuyPrice - BuySL;
SellDifference = SellSL - SellPrice;

//tar1 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + BuyDifference), (SellPrice - SellDifference));
//tar2 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (2*BuyDifference)), (SellPrice - (2*SellDifference)));
//tar3 = IIf(Buy OR Long AND NOT Relax AND NOT Sell AND NOT Cover, (BuyPrice + (4*BuyDifference)), (SellPrice - (4*SellDifference)));
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar1, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar2 , 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > tar3, 0);
 
sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar1 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < tar3, 0);


// User-defined parameter for EMA periods

EMA_Type		= Param("EMA-1, TEMA-2, JMA-3", 2, 1, 3, 1);
EMA_prds 		= Param("EMA_periods", 7, 1, 30, 1);
Std_MACD		= Param("Standard MACD? No-0, Yes-1", 1, 0, 1, 1);
Plot_fashion	= Param("Bar+Arrows-1, Impulse  Bars-2", 2, 1, 2, 1);


// Allow user to define Weekly and Monthly Ribbon Location and Height
WR_P1 = Param("Weekly Ribbon Location", -10.5, -1000, 1000, 0.1);
WR_P2 = Param("Weekly Ribbon Height", 366.5, -0.001, 500, 0.1);

MR_P1 = Param("Monthly Ribbon Location", 5.2, -1000, 1000, 0.1);
MR_P2 = Param("Monthly Ribbon Height", 199, -0.001, 500, 0.1);


// Compute EMA and MACD Histogram
if(EMA_Type == 1)
{
	DayEMA	= EMA(Close, EMA_prds);
}
if (EMA_Type == 2)
{
	DayEMA	= TEMA(Close, EMA_prds);
}

if(EMA_Type == 3)
{
	// Line below to be used with Jurik JMA
	// DayEMA = JurikJMA(C, EMA_Prds);
}

Histogram	= MACD() - Signal();

// Determine if we have an Impulse UP, DOWN or None
Impulse_Up		=	DayEMA > Ref(DayEMA, -1) AND Histogram > Ref(Histogram, -1);
Impulse_Down	=	DayEMA < Ref(DayEMA, -1) AND Histogram < Ref(Histogram, -1);   
Impulse_None		=	(NOT Impulse_UP) AND (NOT Impulse_Down);

// Compute Weekly MACD and determine whether rising or falling
// Note: uses "non-standard"  parameters!
TimeFrameSet(inWeekly);

if (Std_MACD == 0)
{
MACD_val		=	MACD(5, 8);
Signal_val		=	Signal(5, 8, 5);
}
else
{
MACD_val		=	MACD(12, 26);
Signal_val		=	Signal(12, 26, 9);
}

Hist_in_w		=	MACD_val - Signal_val;

wh_rising = Hist_in_w > Ref(Hist_in_w, -1);
wh_falling = Hist_in_w < Ref(Hist_in_w, -1);

TimeFrameRestore();

// Now get Monthly MACD Histogram....
TimeFrameSet(inMonthly);
MACD_val		=	MACD(5, 8);
Signal_val		=	Signal(5, 8, 5);
Hist_in_m		=	MACD_val - Signal_val;

mh_rising = Hist_in_m > Ref(Hist_in_m, -1);
mh_falling = Hist_in_m < Ref(Hist_in_m, -1);

TimeFrameRestore();

wh_rising 		= TimeFrameExpand( wh_rising, inWeekly, expandLast ); 
wh_falling 		= TimeFrameExpand( wh_falling, inWeekly, expandLast); 
mh_rising 	= TimeFrameExpand(mh_rising, inMonthly, expandLast);
mh_falling 	= TimeFrameExpand(mh_falling, inMonthly, expandLast);

kol 	= IIf( wh_rising, colorGreen,  IIf(wh_falling, colorRed,
colorLightGrey));
mkol 	= IIf( mh_rising, colorBlue,  IIf(mh_falling, colorYellow,
colorLightGrey));

// Plot them all!
if (Plot_fashion == 1)
{
	Plot(Close, "Close", colorTeal, styleBar);
	PlotShapes(shapeUpArrow * Impulse_Up, colorBlue, 0, Low, -12);
	PlotShapes(shapeDownArrow * Impulse_Down, colorRed, 0, High, -12);
	PlotShapes(shapeSmallCircle * Impulse_None, colorWhite, 0, High, 5);
}
else
{
	bar_kol	=	IIf(impulse_UP, colorBlue, IIf(impulse_Down, colorRed,
colorWhite));
	//Plot(C, "Close", bar_kol, styleBar);
}

Plot(10, "ribbon", kol, styleOwnScale|styleArea|styleNoLabel, WR_P1, WR_P2);//Weekly trend

Plot(10, "ribbon", mkol, styleOwnScale|styleArea|styleNoLabel, MR_P1,
MR_P2);	// Monthly Trend

// Explorer Section
// Determine if Impulse status is bullish, neutral or bearish.  Display as Text Column.

Impulse_State		=	WriteIf(Impulse_Up, "Bul", WriteIf(Impulse_Down,
"Bear", "Neut"));

// Set the background color for Impulse Status Column
Impulse_Col		=	IIf(Impulse_Up, colorGreen, IIf(Impulse_Down, colorRed,
colorLightGrey));

// Determine Weekly Trend. Display as Text Column
Weekly_Trend		=	WriteIf(wh_rising, "Rising", WriteIf(wh_falling, "Falling",
"Flat!"));
Weekly_Col		=	IIf(wh_rising, colorGreen, IIf(wh_falling, colorRed,
colorLightGrey));

// Determine Monthly Trend. Display as Text Column
Monthly_Trend	=	WriteIf(mh_rising, "Rising", WriteIf(mh_falling, "Falling",
"Flat!"));
Monthly_Col		=	IIf(mh_rising, colorGreen, IIf(mh_falling, colorRed,
colorLightGrey));

// Determine how many bars has the current state existed
bars_in_bull	=	Min(BarsSince(impulse_none), BarsSince(impulse_down));
bars_in_bear	=	Min(BarsSince(impulse_up), BarsSince(impulse_none));
bars_in_neut	=	Min(BarsSince(impulse_down), BarsSince(impulse_up));

// Set a single variable to show number of bars in current state depending upon

// actual Impulse Status - Bullish, Bearish or Neutral
bars_in_state	=	IIf(Impulse_Up,bars_in_bull, IIf(Impulse_down, bars_in_bear,bars_in_neut));
//AddColumn(Close,"Close",1.2);
// Columns for display in Explorer 
//AddTextColumn(Impulse_State, "Status", 1, colorWhite, Impulse_Col);
//AddColumn(bars_in_state, "Bars", 1, colorWhite, Impulse_col);
//Action = WriteIf(Buy, "BUY", WriteIf(Sell, "SELL", "   "));
//i=0;
//bars_in_statee	=	IIf(Buy, BarCount[i], IIf(Sell, BarCount[i],bars_in_neut));
//bars=BarsSince(IIf(Buy+BarCount+1),OR( Sell-BarCount+1));

plus= Param("plus", 0.8,0,52,1);
Minus = Param("Minus", -0.8,-15,-0,-20);
prch = (C- TimeFrameGetPrice( "C", inDaily, -1 ))/ TimeFrameGetPrice( "C", inDaily, -1 )*100 ;
prcha= (C-Ref(C,-6))/Ref(C,-6)*100;
prche= (C-Ref(C,-2))/Ref(C,-1)*100;
prchjk= (C-Ref(C,-2))+Ref(C,-1)*10/1;
//prchjka=(prchjk)/10;

prchjka = (C+ TimeFrameGetPrice( "C", inDaily, -1 ))- Close;

//Date()
//prchjk= (Date()-Ref(Date(),-1))+Ref(Date(),-1);
prch5=(prche-prch);
prch6= (C-Ref(C,-5))/Ref(C,-5)*100;
prch7= (C-Ref(C,-29))/Ref(C,-29)*100;
prch8= (C-Ref(C,-87))/Ref(C,-87)*100;
prch9= (C-Ref(C,-150))/Ref(C,-150)*100;
prch10= (C-Ref(C,-254))/Ref(C,-252)*100;
prch11= (C-Ref(C,-490))/Ref(C,-490)*100;
prch12= (C-Ref(C,-735))/Ref(C,-735)*100;
prch13= (C-Ref(C,-1283))/Ref(C,-1283)*100;


col=IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorRed,colorLime);
//Col=IIf(( Buy, 66 , 83 ),  formatChar, colorDefault, IIf( plus , colorGreen, colorRed ));

//Filter = prch6 <3 OR prch6  <-3 ;
if(prexplore==0)
{Filter = prch > plus OR prch  < Minus  ;
AddColumn(prchjka ,"prvClose",colorDefault,Col,colorPlum);
AddColumn(Close,"Close",1.2,colorDefault, Col);
AddColumn(prch5,"prviday", 1.2,colorDefault, Col);	
AddColumn(prch,"daily", 1.2,colorDefault, Col); 
//Filter=0;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );

AddColumn(Volume,"Volume",1.0, colorDefault, IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorCustom12,colorLime));
AddColumn(prch6,"weekly", 1.2,colorDefault, Col);
AddColumn(prch7,"monthly", 1.2,colorDefault, Col);
AddColumn(prch8,"qutrly", 1.2,colorDefault, Col);
AddColumn(prch9,"halfyly", 1.2,colorDefault, Col);
AddColumn(prch10,"yearly", 1.2,colorDefault, Col); 
AddColumn(prch11,"twoyrly", 1.2,colorDefault, Col); 
AddColumn(prch12,"thirdyrly", 1.2,colorDefault, Col); 
AddColumn(prch13,"fiveyrly", 1.2,colorDefault, Col); 

}
else
{

//Filter =  Sell>-2 AND i<-3 OR Buy>2 AND i<3 ;
AddColumn(ROC(V,1),"RVol ",1.2, IIf(ROC(V,1) > 0,colorDefault,colorYellow),Impulse_col);

AddColumn(bars_in_state ,"Bars", 1, colorWhite, Impulse_col);
prchjka = (C+ TimeFrameGetPrice( "C", inDaily, -1 ))- Close;

//AddColumn(C + C +1 ,"Close",1.2,colorDefault, Col)/2;
AddColumn(prchjka ,"prvClose",colorDefault,colorWhite, colorBlue);
//AddTextColumn(Weekly_Trend, "W Trend", 1, colorWhite, Weekly_Col);
//AddTextColumn(Monthly_Trend, "M Trend", 1, colorWhite, Monthly_Col);

//Filter = 1;

_SECTION_END();
//Settings for exploration

H1 = SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ) );
L1 = SelectedValue( TimeFrameGetPrice( "L", inDaily, -1 ) );
C1 = SelectedValue( TimeFrameGetPrice( "C", inDaily, -1 ) );
H2 = SelectedValue( TimeFrameGetPrice( "H", inDaily, 0 ) );
L2 = SelectedValue( TimeFrameGetPrice( "L", inDaily, 0 ) );
O1 = SelectedValue( TimeFrameGetPrice( "open", inDaily, 0 ) );
F4 = 0;
D1 = ( H1 - L1 );
D2 = ( H2 - L2 );
F1 = D1 * 0.433;
F2 = D1 * 0.766;
F3 = D1 * 1.35;
if ( D2 <= F1 )
    F4 = F1;
else
    if ( D2 <= F2  )
        F4 = F2;
    else
        F4 = F3;

S_P = ( O1 - F4 );

B_P = ( O1 + F4 );

BP = ( L2 + F4 );

BPTGT = ( BP + ( BP * .0065 ) );//.0015 brokerage

BPSTPLS = ( BP - ( BP * .0085 ) );

SP = ( H2 - F4 );

SPTGT = ( SP - ( SP * .0065 ) );

SPSTPLS = ( SP + ( SP * .0085 ) );


p = ( H1 + L1 + C1 ) / 3;

s1 = ( H1 );

r1 = ( L1 );

r2 = SelectedValue( L2 );

s2 = SelectedValue( H2 );

//CONDITION

if (ParamToggle("Tooltip shows", "All Values|Only Prices"))
{
  ToolTip = StrFormat("Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%) \nVolume: " + NumToStr(V, 1), O, H, L, C, SelectedValue(ROC(C, 1)));
}

//space = Param("Space on Chart", 20,  - 15, 50, 1);
//GraphXSpace = space;
//SetChartBkColor(ParamColor("Background Color", colorBlack));

// ================= Rasheed's original code (with Lookback and Shift default set to his specs) =================

H0 = H;
L0 = L;
C0 = C;
O0 = O;

Lookback = Param("LookBack", 10, 10, 50, 1); // Default for interday commodity currency trading
shift = Param("Shift", 5, 1, 50, 1); // ?
x0 = LastValue(Cum(1));
x1 = x0 - shift;
H = Ref(H,  - shift + 1);
L = Ref(L,  - shift + 1);
H1 = LastValue(Ref(HHV(H, Lookback),  - 1));
L1 = LastValue(Ref(LLV(L, Lookback),  - 1));

//Plot(H1, "H1", colorYellow);
//Plot(L1, "L1", colorYellow);

H = H0;
L = L0;
C = C0;
O = O0;

up = Cross(H, H1)AND Cum(1) > x1;
dn = Cross(L1, L)AND Cum(1) > x1;

//Plot(C, "Close", IIf(Cum(1) > x1 - Lookback AND Cum(1) <= x1, colorBlue, IIf(Up, colorBrightGreen, IIf(Dn, colorRed, IIf(C > O, colorGreen, colorRed)))), 64);
//PlotShapes(shapeDownArrow *(Cum(1) == x1 + 1), colorBlue);

// ======================= Exploration and Signal Code =================
TRIGGER = ParamToggle("Trigger ", "CLOSE|HIGH OR LOW");


XH1 = Cross(C, H1);
XL1 = Cross(L1, C);
XH2 = Cross(H, H1);
XL2 = Cross(L1, L);

if (TRIGGER == 0)
{
  //Buy = XH1;
  //Sell = XL1;
}

else
{
  //Buy = XH2;
  //Sell = XL2;
}


//TradeDisplay = ParamToggle("Remove Extra Trades?", "No|Yes");

//if(TradeDisplay != 0){
	//Buy = ExRem(Buy, Sell);
  	//Sell = ExRem(Sell, Buy); // THIS WILL REMOVE EXESS SIGNALS ON A CHART OR IN AN EXPLORATION 
//}

//Filter =  Buy >2 <3 == BarCount+1 OR Sell >-3<-3 == BarCount+1;
Action = WriteIf(Buy, "BUY", WriteIf(Sell, "SELL", "   "));

//AddTextColumn(IndustryID(1), "Industry Sector  ", 30.0, colorBlue, colorYellow);
AddColumn(C, "Entry ", 2.2, colorWhite, colorBlue);
AddTextColumn(Action, "Action", 8.0, IIf(xh1, colorDarkGreen, colorDarkRed), colorYellow);
AddColumn(IIf(XH1, H1, L1), "BREAKOUT LEVEL", 3.2, colorYellow, IIf(XH1, colorDarkGreen, colorDarkRed));

// -----------------------------------------------------------------------------------  Arrow signals --- FOR TRADES  ----------------------------------------------------------
//PlotShapes(Buy *shapeUpArrow, colorBrightGreen, 0, L /* ENTRY_TRAILARRAY */,  - 30);
//PlotShapes(Sell *shapeDownArrow, colorLightYellow, 0, H,  - 30);
_SECTION_END();


_SECTION_BEGIN("Volume At Price");
PlotVAPOverlay(Param("Lines", 1000, 100, 1000, 10), Param("Width", 15, 1, 100, 1), ParamColor("Color", colorBlue), ParamToggle("Side", "Left|Right", 1) | 4 *ParamToggle("Z-order", "On top|Behind", 1));

_SECTION_END();
//Filter =  Buy OR Sell;

//AddColumn( IIf( Buy, 66, 1 ), "Buy", formatChar, 1, bkcolor = IIf( Buy, 43, 33 ) );

//AddColumn( IIf( Sell, 83, 1 ), "Sell", formatChar, 1, bkcolor = IIf( Sell, 25, 32 ) );



//AddColumn( C, "CMP", 1.2, colorDefault, colorLightBlue );

//AddColumn( BP, "SELL PRICE", 1.2, colorDefault, colorGreen );

//AddColumn( BPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );

//AddColumn( BPSTPLS, "STPLS BUY", 1.2, colorDefault, colorRed );

AddColumn( p, "PIVOT", 1.2, colorDefault, colorYellow );

//AddColumn( SPSTPLS, "STPLS SELL", 1.2, colorDefault, colorRed );

//AddColumn( SP, "SELL PRICE", 1.2, colorDefault, colorGreen );

//AddColumn( SPTGT, "TGT PRICE", 1.2, colorDefault, colorBrown );





//Settings for exploration

Filter=Buy OR Short;
AddColumn( IIf( Buy, 66 , 83 ), "Signal", formatChar, colorDefault, IIf( Buy , colorGreen, colorRed ) );

//AddColumn(Close,"Entry Price",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(dtsl,"Stop Loss",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar1,"Target 1",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar2,"Target 2",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(tar3,"Target 3",1.4, colorDefault, IIf( Buy , colorGreen, colorRed ));
AddColumn(Volume,"Volume",1.0, colorDefault, IIf ((Volume > 1.25 * EMA( Volume, 34 )),colorBlue,colorYellow));
AddColumn( H1, "PRE-HIGH" );

AddColumn( L1, "PRE-LOW" );

AddColumn( D1, "PRE-DIFF" );

AddColumn( F1, "0.433" );

AddColumn( F2, "0.766" );

AddColumn( F3, "1.35" );

AddColumn( H2, "D-HIGH" );

AddColumn( L2, "D-LOW" );

AddColumn( D2, "D-DIFF" );

AddColumn( F4, "SELECT FACT" );

AlertIf( Buy , "SOUND C:\\Windows\\Media\\chimes.wav", "Audio alert", 2 ); 
AlertIf( Sell , "SOUND C:\\Windows\\Media\\alert.wav", "Audio alert", 2 );

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

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


pxHeight = Status( "pxchartheight" ) ;
xx = Status( "pxchartwidth");
Left = 1100;
width = 310;
x = 5;
x2 = 280;
 
y = pxHeight; 
dist = 2*ATR(10);
dist1 = 3*ATR(10);
 i=BarCount;
    bars = i;

if(messageboard)
{
for( i = 0; i < BarCount; i++ )
{
    if( Buy[i] )
    {
        // PlotText( "\nBuy:" + L[ i ] + "\nT= " + (L[i]*1.005) + "\nSL= " + (L[i]*0.9975), i, L[ i ]-dist[i], colorGreen, colorWhite );
        
        // Signal Display Panel //

       SellPrice=ValueWhen(Sell,C,1);
       BuyPrice=ValueWhen(Buy,L[ i ]);
       Long=Flip(Buy,Sell);
        Shrt=Flip(Sell,Buy );
        BuyStop2 = L[i]*0.9975;
        BuyTP1 = L[i]*1.070;
        BuyTP2 = L[i]*1.050;
        BuyTP3 = L[i]*1.035;
buyach1 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP3, 0);
buyach2 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP2, 0);
buyach3 = IIf((Buy OR Long AND NOT Relax AND NOT Cover AND NOT Short AND NOT Shrt), H > BuyTP1, 0);
        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorBrightGreen, 3 );
        GfxSelectSolidBrush( colorBrightGreen);
        GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
       GfxSetTextColor( colorGold );        
       GfxTextOut( ( " Trading System "),73,y-165);
        GfxTextOut( (" "),27,y-160);
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorBlue );
        GfxSetTextAlign(0);
        GfxSelectFont( "Tahoma", 13, 100 );

   GfxTextOut( WriteIf(L[ i ], "Buy Above: "+L[ i ],""), 13, y-140);
   GfxSetTextColor( colorGold );    
   GfxTextOut( WriteIf(BuyStop2, "Long SL: "+(BuyStop2),""), 13, y-120);
   GfxSetTextColor( colorWhite );    
   GfxTextOut( WriteIf(BuyTP1, "Buy TGT1: "+(BuyTP3),""), 13,y- 100);
   GfxTextOut( WriteIf(BuyTP2, "Buy TGT2: "+(BuyTP2),""), 13,y- 80); 
   GfxTextOut( WriteIf(BuyTP3, "BuyTGT3: "+(BuyTP1),""), 13,y- 60);   
   GfxSetTextColor( colorViolet );    
   GfxTextOut( ("Current P/L : " + WriteVal(IIf(Buy ,(C-BuyPrice),(C-BuyPrice)),2.2)), 88, y-22);
  GfxTextOut( ("Buy  Signal came " + (BarCount-bars +1) * Interval()/3 + " mins ago"), 13, y-40) ;   
GfxTextOut
( ("" + WriteIf (buyach1, " Done: "+BuyTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (buyach2, " Done: "+BuyTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (buyach3, " Done: "+BuyTP1,"")), 160, y-60);        
        // END of Signal Display Panel //
    }
    if( Sell[i] )
    {
        // PlotText( "Sell:" + H[ i ] + "\nT= " + (H[i]*0.995) + "\nSL= " + (H[i]*1.0025), i, H[ i ]+dist1[i], colorRed, colorWhite );
        
        // Signal Display Panel //
        SellPrice=ValueWhen(Sell,C,1);
BuyPrice=ValueWhen(Buy,H[ i ]);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
       SellStop2 = H[i]*1.0025;
        SellTP1 = H[i]*0.978;
        SellTP2 = H[i]*0.982;
        SellTP3 = H[i]*0.988;
sellach1 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP3 , 0);
sellach2 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP2, 0);
sellach3 = IIf((Short OR Shrt AND NOT Relax AND NOT Sell AND NOT Buy AND NOT Long), L < SellTP1, 0);

        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetOverlayMode( mode = 0 );
        GfxSelectPen( colorRed, 3 );
        GfxSelectSolidBrush( colorRed );
         GfxRoundRect( x, y - 163, x2, y , 7, 7 ) ;
        
        GfxTextOut( (" "),27,y-160);
        GfxSetBkMode(1);
        GfxSelectFont( "Arial", 10, 700, False );
        GfxSetTextColor( colorWhite );
        GfxSetTextAlign(0);
        GfxSelectFont( "Tahoma", 13, 100 );
        GfxSetTextColor( colorGold );      
        GfxTextOut( ( " Trading System "),73,y-165);
        GfxSetTextColor( colorWhite ); 
       GfxTextOut( WriteIf(H[ i ], "Sell Below: "+H[ i ],""), 13, y-140);
       GfxSetTextColor( colorGold );     
       GfxTextOut( WriteIf(SellStop2, "Short SL: "+(SellStop2),""), 13, y-120);     
       GfxSetTextColor( colorBlue );   
       GfxTextOut( WriteIf(SellTP1, "Short TGT1: "+(SellTP3),""), 13, y-100);
       GfxTextOut( WriteIf(SellTP2, "Short TGT2: "+(SellTP2),""), 13, y-80);
       GfxTextOut( WriteIf(SellTP3, "Short TGT3: "+(SellTP1),""), 13, y-60);
       GfxSetTextColor( colorGold );
       GfxTextOut( ("Current P/L : " + WriteVal(IIf(Sell ,(SellPrice-C),(SellPrice-C)),2.2)), 88, y-22);
        GfxTextOut( ("sell Signal came " + (BarCount-bars +1) * Interval()/1 + " mins ago"), 13, y-40) ;    
       GfxTextOut
( ("" + WriteIf (sellach1, "  Done: "+SellTP3,"")), 160, y-100);
GfxTextOut
( ("" + WriteIf (sellach2, "  Done: "+SellTP2,"")), 160, y-80);
GfxTextOut
( ("" + WriteIf (sellach3, "  Done: "+SellTP1,"")), 160, y-60);
// END of Signal Display Panel //
    }}}


for( i = 0; i < BarCount; i++ )
{
 if( Buy[i] )
 {

OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper",colorDarkGreen);
INDNcolor = ParamColor("Inner Panel Lower",colorDarkOliveGreen);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
if( Sell[i] )
{
OUTcolor = ParamColor("Outer Panel Color",colorTeal);
INUPcolor = ParamColor("Inner Panel Upper2",colorDarkRed);
INDNcolor = ParamColor("Inner Panel Lower2",colorPlum);
TitleColor = ParamColor("Title Color ",colorBlack);
SetChartBkColor(OUTcolor); // color of outer border
SetChartBkGradientFill(INUPcolor,INDNcolor,TitleColor); // color of inner panel
}
}


_SECTION_BEGIN("Pivot calc");
pd = Param("Periods",13,5,144,1); 
pds = 2*pd-1;//     (Adjustment for Wilders MA) 
aa = Close-Ref(Close,-1); 
uu = EMA(Max(0,aa),pds); 
dd=  EMA((Max(0,0-aa)),pds); 

rf = IIf(C>2,1000,10000); 

c1 = Param("Upper Level",70,50,90,1); 
qq1 =100/(100-c1)-1; 
ff1 = qq1*dd-uu; 
ff2 = ff1/qq1; 
f1 = Max(ff1,ff2); 
UL = Close + f1*(pds-1)/2; 
UL = IIf(UL>C,floor(UL*rf),ceil(UL*rf))/rf; 

c2 = Param("Equilibrium",50,50,50,0);  
qq2 =100/(100-c2)-1;// [=1] 
ff = dd-uu; 
MM = Close + ff*(pds-1)/2; 
MM = IIf(MM>C,floor(MM*rf),ceil(MM*rf))/rf; 

c3 = Param("Lower Level",30,10,50,1); 
qq3 =100/(100-c3)-1; 
ff1 = qq3*dd-uu; 
ff2 = ff1/qq3; 
f3 = Min(ff1,ff2); 
LL = Close + f3*(pds-1)/2; 
LL = IIf(LL>C,floor(LL*rf),ceil(LL*rf))/rf; 

band = Param("band width",4,0,15,0.25);
mmu = MM+band;
mmd = MM-band;


X=Cross( C,LL);
Y=Cross(UL,C);

Buy1= X ;
Sell1= Y ;

TimeFrameSet( in15Minute*2 ); 
DH=Ref(H,-1); 
DL=Ref(L,-1);
DC=Ref(C,-1);


pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL); 
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);

TimeFrameRestore();

_SECTION_END();


Title = 
EncodeColor(colorWhite)+ "Linkon's Silver" + " - " +  Name() + " - " + EncodeColor(colorRed)+ Interval(2) 
+ EncodeColor(colorWhite) +  "  - " + Date() +" - "
+"\n" 

+EncodeColor(colorYellow) +"Op-"+O+"  "+"Hi-"+H+"  "+"Lo-"+L+"  "+ "Cl-"+C+"  "+ "Vol= "+ WriteVal(V)
//+ WriteIf ((e3>e45) ,EncodeColor(colorLime)+ "      Direction : LONG",EncodeColor(colorRed)+"      Direction : SHORT")
+"\n" 
+ WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+"\n","")
+ WriteIf (Buy , " EXIT SHORT / Reverse Signal at "+C+"\n","")

+WriteIf(Sell , "Total Profit / Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+
WriteIf(Buy , "Total Profit / Loss for the Last trade Rs."+(SellPrice-C)+"","")+
WriteIf(Long AND NOT Buy,EncodeColor(colorLime)+  "Trade : Long - Entry price Rs."+(BuyPrice)+" Tgt : "+UL,"")+
WriteIf(shrt AND NOT Sell,EncodeColor(colorRed)+ "Trade : Short - Entry price Rs."+(SellPrice)+" Tgt : "+LL,"")+"\n"+ 
WriteIf(Long AND NOT Buy, "Current Profit / Loss Rs."+(C-BuyPrice)+"","")+
WriteIf(shrt AND NOT Sell, "Current Profit / Loss Rs."+(SellPrice-C)+"","")
+ EncodeColor(colorBrightGreen)+   "\n R3 : "+ EncodeColor(colorWhite)+RD3
+ EncodeColor(colorBrightGreen)+   "\n R2 : "+ EncodeColor(colorWhite)+RD2
+ EncodeColor(colorBrightGreen)+   "\n R1 : "+ EncodeColor(colorWhite)+RD1 + EncodeColor(colorBrightGreen)+  "     UP TGT   : "+ EncodeColor(colorWhite)+UL
+ EncodeColor(colorBlue)+   "\n Pivot : "+ EncodeColor(colorWhite)+pd+ EncodeColor(colorBlue)+   "     MIDPOINT : "+ EncodeColor(colorWhite)+MM
+ EncodeColor(colorRed)+   "\n S1 : "+ EncodeColor(colorWhite)+SD1   + EncodeColor(colorRed)+    "     BOT TGT  : "+ EncodeColor(colorWhite)+LL
+ EncodeColor(colorRed)+   "\n S2 : "+ EncodeColor(colorWhite)+SD2
+ EncodeColor(colorRed)+   "\n S3 : "+ EncodeColor(colorWhite)+SD3;




if (EndValue(Buy)==1) Say("strong Buy go long dear"); 
if (EndValue(Sell)==1) Say("strong Sell go short dear");
//if (EndValue(Cover)==1) Say(" go long dear"); 
//if (EndValue(Short)==1) Say(" go short dear");

15 comments

1. anandnst

Hello Jaipal,

Gem of a AFL. Gr8 Modifications done by u n thanx you for sharing it.

Query – How to stop repetation of Audio Alert in the above AFL???

Kindly help to stop it.

2. extremist

Oh Mr. Jaipal……

U just hit the chord.
i can not believe my eyes…..
such great results……

i wish i could give u all the stars i have.
for the hard work u have done in all these months.

May god bless u with all his might to propel u through all the phases of life.

thanx for the code….

3. jaipal7786

if(EndValue(Buy)1)Say("strong Buy go long dear",1); if (EndValue(Sell)1) Say(“strong Sell go short dear”,1);

for stop repeating audio only add ,1 in last code line no.
1091 and
1092
otw replace these two lines..maybe helpful thanx and enjoy urtr…

4. dineshpal

Hello, Is this to be used for 1 Hr Time Frame ? Or it is good for any time frame like 5 or 15 Minutes also ?I need help on How to trade with this afl.

5. johnnypareek

Hey,

Very long code. Truly hats off for this long coading. Btw I am confused how to use as the box shows diff buy/sell n scan or exploration shows diff. Any hint to use this??

6. Divyesh

@Jaipal7786,

excellant work…..!
Hat’s off…..!
but one little query….!
what about S/L….?
when to exit ?

if breaks pattern or prise breks the level of buy…..???
i will be oblidge when you clear the thing…..!!!

can i suggest one thing for buy criteria ?

you can add rsi level along with….! like….

Buy=bullhar & RSI<30 or 40;
Sell=bearhar & RSI >60 or 70;
what do you say ?
thnx.

7. hotaro3

why no harmonic pattern in my amibroker and How we can use it for buy or sell

8. bhartiprinters

SIRJI AAP JO BHI JO BHI HO BOHOT MUSHKIL SE KOI SAMAJTH SAKTA HAI AAPKI SOCH KITNI DOOR TAK POHONCHI HAI ENTIRE MY LIFE I HAVE SEEN LOT OF INDICATOR BUT BUT HARMONIC I NEVER THOUGHT SOMEBODY WILL USE FOR RSI.
AAPKO EK HAZAAR TOPO KI SALAMI ISME BOHOT SARI KHAAS BAATE HAI SPCEICALLY HARMONIC WITH DIVERSION WHICH HAS ENHANCED ITS BEAUTY.
HATTTTTTTTTTTTTTTTTTS OFF

9. anujchauhan

I can’t see bottom both ribbons as display in above pics.

pls. help me & give your chat id.

Thanks in Advance
Anuj

10. manojin1

To Admin of HRM INDEX RSI for Amibroker (AFL)any one can use this afl, pls share manojin1@gmail.com, I try copy paste but error. Thansk

11. administrator

manojin1 use ‘Copy & Paste friendly’ to get the formula

12. 1962vl

All those who gave, good reviews, did you ever check in the real time… i think you did not because, its repainting, whoever desgined the afl is anyhow having some brain, but he obviously is not a fool to share if the system is producing good results… please do home work and comeback, see in real time its repainting

13. vinitmagar

Gr8 Gr8 Work And thanks for sharing

14. vinvlad

Useless, but beautiful formula.

15. pradip_kumar1

Hi Jaipal/Admin of AFL

AFL is nice but against each entry, target prices are giving wrong value.
For Long entry – target prices are giving much lower than entry value.
For Sell entry – target prices are giving much higher tan entry value.
In exploration also the same anomaly. Pls correct if possible.

Leave Comment

Please login here to leave a comment.

Back