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

HARMONIC INDEX for Amibroker (AFL)

Rating:
2 / 5 (Votes 3)
Tags:
amibroker, oscillator, pattern

simple harmonic index

Screenshots

Similar Indicators / Formulas

MACD Waleedis
Submitted by waleedis over 12 years ago
Waves in Price
Submitted by has001u over 13 years ago
Cumulative TICK Moving Average
Submitted by buchacek almost 13 years ago
DTOscillator
Submitted by hemsvg almost 14 years ago
TD Pressure Ratio
Submitted by javgeek almost 14 years ago
OBV - with Buy and Sell Signals
Submitted by prasadbrao almost 14 years ago

Indicator / Formula

Copy & Paste Friendly
//HARMONIC index me AND credibility High, especially when the models in the Tops AND Bottoms was developed by the Forum AND repeat for the benefit of 
//AND interested in the models on the RSI () 
_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, "", colorBlack);
 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);
 ax=  Param ("Swing B Min.", 0.55,0.3,1,0.01); 


GBmax  = Param ("Swing b max.", 0.72,0.3,1.27,0.01); 
GBmin  = Param ("Swing b min.", 0.72,0.3,1.27,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) 
{ r = Top = 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) 
AND LowestSince (BullButterfly4, W1) 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-b) / (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, 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 (Xbar), LastValue (X), LastValue (Dbar), LastValue (D)), "", C = (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); 
BearHar4 = BearGartley4 OR BearButterfly4 OR BearBat4 OR BearCrab4; 
//BullHar4 = BullGartley4 OR BullButterfly4 OR BullBat4 OR BullCrab4; 

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); 
BearHar = 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 (Abar), LastValue (A), LastValue (C1bar), LastValue (C1)), "" , 
(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"))))))));


 PlotShapes (IIf (BearHar, shapeSmallDownTriangle, shapeNone), colorBlack, 0, r, -13);

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


PlotFractals =ParamToggle("PlotFractals","Show|Hide",1);

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



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

1 comments

1. anandnst

Kindly add exploration to the formula.

Leave Comment

Please login here to leave a comment.

Back