Fractal charts

MANISH_DAMANI

Well-Known Member
#2
_SECTION_BEGIN("Price");
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 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
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 )));
}
_SECTION_END();

_SECTION_BEGIN("EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 200, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Mid EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 50, 2, 300, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("Long EMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 200, 2, 400, 1 );
Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
_SECTION_END();

_SECTION_BEGIN("BBands");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 300, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorBrown );
Style = ParamStyle("Style") | styleNoRescale | styleNoRescale;
Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
_SECTION_END();

_SECTION_BEGIN("Volume");
Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram ), 2 );
_SECTION_END();

_SECTION_BEGIN("Price Interpretation");
movshort = ParamField("Short Time EMA", 8 );
movmed = ParamField("Mid Time EMA", 9 );
movlong = ParamField("Long Time EMA", 10 );
btop = ParamField("BBTop", 11 );
bbot = ParamField("BBBottom", 12 );
if( Status("action") == actionCommentary )
{
width = btop - bbot;
lslop = LinRegSlope( C, 30 ) + 100;
lslo = LLV( lslop, 90 );
lshi = HHV( lslop, 90 );
lswidth = lshi - lslo;
trend = 100*( lslop - lslo )/lswidth;

mawidth = MA( width, 100 );
relwidth = 100*(width - mawidth)/mawidth;

_N( tname = Name()+"("+FullName()+")" );

printf("Price and exponential moving averages:\n");
printf( tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) + " its Short time exponential moving average. ");

printf("\nShort time exponential moving average is currently " + WriteIf( movshort > movmed, "above", "below") + " mid-time, AND " + WriteIf( movshort > movlong, "above", "below" ) + " long time exponential moving averages.");

printf("\nThe relationship between price and exponential moving averages is: "+
WriteIf( C > movshort AND movshort > movmed, "bullish",
WriteIf( C < movshort AND movshort < movmed, "bearish", "neutral" ) ) + " in short-term, and "+
WriteIf( movshort > movmed AND movmed > movlong , "bullish",
WriteIf( movshort < movmed AND movmed < movlong, "bearish", "neutral" ) ) + " in mid-long term. ");

printf("\n\nBollinger Bands:\n");
printf(tname+ " has closed " +
WriteIf( C < bbot, "below the lower band by " +
WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%%. " +
WriteIf( trend < 30, " This combined with the steep downtrend can suggest that the downward trend in prices has a good chance of continuing. However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the lower band and a downside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C > btop, "above the upper band by " +
WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%%. " +
WriteIf( trend > 70, " This combined with the steep uptrend suggests that the upward trend in prices has a good chance of continuing. However, a short-term pull-back inside the bands is likely.",
WriteIf( trend > 30 AND trend < 70, "Although prices have broken the upper band and a upside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +

WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5,
"below upper band by " +
WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%%. ",
WriteIf( C < btop AND C > bbot , "above bottom band by " +
WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%%. ", "" ) ));

printf("\n"+
WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) AND abs(relwidth) > 40,
"This picture becomes somewhat unclear due to the fact that Bollinger Bands are currently",
"Bollinger Bands are " )+
WriteVal( abs( relwidth ), 1.1 ) + "%% " +
WriteIf( relwidth > 0, "wider" , "narrower" ) +
" than normal.");

printf("\n");

printf(
WriteIf( abs( relwidth ) < 40, "The current width of the bands (alone) does not suggest anything conclusive about the future volatility or movement of prices.","")+
WriteIf( relwidth < -40, "The narrow width of the bands suggests low volatility as compared to " + tname + "'s normal range. Therefore, the probability of volatility increasing with a sharp price move has increased for the near-term. "+
"The bands have been in this narrow range for " + WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The probability of a significant price move increases the longer the bands remain in this narrow range." ,"")+
WriteIf( relwidth > 40, "The large width of the bands suggest high volatility as compared to " + tname + "'s normal range. Therefore, the probability of volatility decreasing and prices entering (or remaining in) a trading range has increased for the near-term. "+
"The bands have been in this wide range for " + WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The probability of prices consolidating into a less volatile trading range increases the longer the bands remain in this wide range." ,""));

printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
}
_SECTION_END();

//ELLIOT Fractals

_SECTION_BEGIN("LEMA");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 200, 1, 10 );
lema = EMA (Close,Periods)+ EMA((Close-EMA(Close,Periods)),Periods);
Plot( lEMA, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ),
ParamStyle("Style") );
_SECTION_END();

_SECTION_BEGIN("ELLIOTT Fractals");
/*
The basic definition of an 'up' fractal is a bar high that is both higher than the two bars immediately preceding it
and higher than the two bars immediately following it.
The lows of the bars are NOT considered in determining the up fractal progression.

If two bars in the progression have equal highs followed by two consecutive bars with lower highs,
then a total of six bars rather than the usual five bars will make up the progression.
The first High becomes the counting fractal. Reverse for 'down' fractals.

The 5 bar formation works best on Daily or longer time frame charts.For intraday data charts we often use 9 bar, 13 bar and 21 bar formations for fractal counting
*/
Up5BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND Ref(H,1) < H AND Ref(H,2) < H;
Up6BarFractal = Ref(H,-2) < H AND Ref(H,-1) < H AND (H == Ref(H,1)) AND Ref(H,2) < H AND Ref(H,3) < H;
Down5BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND Ref(L,1) > L AND Ref(L,2) > L;
Down6BarFractal = Ref(L,-2) > L AND Ref(L,-1) > L AND (L == Ref(L,1)) AND Ref(L,2) > L AND Ref(L,3) > L;

//TODO: More filtering: Show only troughs that are around atrough in trix(9).

PlotShapes( IIf(Down5BarFractal ,shapeSmallUpTriangle,0) ,colorBlack, 0, L,-12);
PlotShapes( IIf(Down6BarFractal ,shapeSmallUpTriangle,0) ,colorBlack, 0, L,-12);

PlotShapes( IIf(Up5BarFractal ,shapeSmallDownTriangle,0) ,colorBlack, 0, H,-12);
PlotShapes( IIf(Up6BarFractal ,shapeSmallDownTriangle,0) ,colorBlack, 0, H,-12);

Up = (Up5BarFractal OR Up6BarFractal);
Down = (Down5BarFractal OR Down6BarFractal);
//Removing false fractals:
DownSignal = Flip(Ref(Up,-1), Ref(Down,-1));
UpSignal = Flip(Ref(Down,-1), Ref(Up,-1));

LastHigh[0] = H[0];
LastLow[0] = L[0];

LastLowIndex = 0;
LastHighIndex = 0;
Valid = 0;
for (i=1; i < BarCount; i++)
{

LastHigh = LastHigh[i-1];
LastLow = LastLow[i-1];
if (Up)
{
Valid = True;
if (DownSignal)
{
//Sequence of 2 Up Fractals. Validate only the higher one.
Valid = H >= H[LastHighIndex];
Valid[LastHighIndex] = H[LastHighIndex] > H;
}
LastHigh = Max(H, H[LastHighIndex ]);
LastHighIndex = i;
}

if (Down)
{
Valid = True;
if (UpSignal)
{
//Sequence of 2 Down Fractals. Validate only the lower one.
Valid = L <= L[LastLowIndex];
Valid[LastLowIndex] = L[LastLowIndex] < L;
}

LastLow = Min(L, L[LastLowIndex]);
LastLowIndex = i;
}
}

TrixN = Trix(9);
TroughLow = Ref(TrixN, -3) > TrixN AND Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN AND Ref(TrixN, 3) > TrixN;
TroughHigh = Ref(TrixN, -3) < TrixN AND Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN AND Ref(TrixN, 3) < TrixN;
//TroughLow = Ref(TrixN, -2) > TrixN AND Ref(TrixN, -1) > TrixN AND Ref(TrixN, 1) > TrixN AND Ref(TrixN, 2) > TrixN;
//TroughHigh = Ref(TrixN, -2) < TrixN AND Ref(TrixN, -1) < TrixN AND Ref(TrixN, 1) < TrixN AND Ref(TrixN, 2) < TrixN;
ZeroValid = Cross(TrixN, 0) OR Cross(0, TrixN) OR Ref(Cross(TrixN, 0),1) OR Ref(Cross(0, TrixN),1);
ValidLow = TroughLow OR Ref(TroughLow, 1) OR Ref(TroughLow, 2) OR Ref(TroughLow, 3) OR Ref(TroughLow, 4);// OR Ref(TroughLow, 5));
ValidHigh = TroughHigh OR Ref(TroughHigh, 1) OR Ref(TroughHigh, 2) OR Ref(TroughHigh, 3) OR Ref(TroughHigh, 4);// OR Ref(TroughHigh, 5));

//Plot(LastHigh-10 ,"LastHigh", colorBlue, styleLine);
//Plot(LastLow-10 ,"LastLow ", colorRed, styleLine);
//Plot(Valid*5 + 10 ,"LastLow ", colorGreen, styleLine | styleThick);

//PlotShapes( IIf(Down AND Valid,shapeSmallUpTriangle,0) ,colorGreen, 0, L,-12);
//PlotShapes( IIf(Up AND Valid,shapeSmallDownTriangle,0) ,colorRed, 0, H,-12);
Maxi = Up AND (ValidHigh OR ZeroValid);
Mini = Down AND (ValidLow OR ZeroValid);
PlotShapes( IIf(Down AND (ValidLow OR ZeroValid),shapeSmallUpTriangle,0) ,colorBlue, 0, L,-12);
PlotShapes( IIf(Up AND (ValidHigh OR ZeroValid),shapeSmallDownTriangle,0) ,colorOrange, 0, H,-12);
//Plot(UpSignal*3+5,"UpSignal", colorBlue, styleLine| styleThick);
//Plot(DownSignal*3 ,"DownSignal", colorRed, styleLine| styleThick);

/*
LastMaxi = 0;
LastMini = 0;
ElliotLines = 0;
State = 0;
for (i=1; i < BarCount; i++)
{
State = State[i-1];
if (Maxi)
{
State = 1;//down
}

if (Mini)
{
State = 2;
}

}

PlotShapes(IIf(State > 0, shapeSmallCircle, 0), IIf(State == 1, colorRed, colorBlue), 0, IIf(State == 1, H, L), -5);
*/
//Line = LineArray( x0, y0, x1, y1, 1 );
//Plot( Line, "Trend line", colorBlue );

/*
Wave B
Usually 50% of Wave A
Should not exceed 75% of Wave A
Wave C
either 1 x Wave A
or 1.62 x Wave A
or 2.62 x Wave A
*/
function CorrectiveRatios(StartPrice, A, B, C, RatioDelta, Delta)
{

ALength = abs(startPrice - A); BLength = abs(A-B);
CLength = abs(B-C);

Ratio1 = BLength / CLength ;
Cond1 = Ration1 >= 0.5 - RatioDelta AND ratio1 <= 0.75 + RatioDelta;
Cond2 = abs(Clength - ALength) < Delta OR abs(Clength - 1.62 * ALength) < Delta OR abs(CLength - 2.62 * ALength) < Delta;

return Cond1 AND Cond2;
}

function ImpulseRules(StartPrice, One, Two, Three, Four, Five)
{
//Wave 2 should be beneath wave 1 start:
Cond1 = Two > StartPrice AND Two < One;
//Wave 4 - the same:
Cond2 = Four > Two AND Four < Three;
//Wave 5 should be <= wave 3
Cond3 = abs(Three-Two) >= abs(Five - Four);
//Wave 1 should be smaller than wave five, making wave 3 the biggest:
Cond4 = abs(StartPrice - One) < abs(Five - Four);
return Cond1 AND Cond2 AND Cond3 AND Cond4;
}
_SECTION_END();

_SECTION_BEGIN("SAR");
acc = Param("Acceleration", 0.02, 0, 1, 0.001 );
accm = Param("Max. acceleration", 0.2, 0, 1, 0.001 );
Plot( SAR( acc, accm ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style", styleDots | styleNoLine, maskDefault | styleDots | styleNoLine ) );
_SECTION_END();

_SECTION_END();

_SECTION_END();

_SECTION_BEGIN("Bollinger Bands1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 20, 2, 100, 1 );
Width = Param("Width", 2, 0, 10, 0.05 );
Color = ParamColor("Color", colorBrown );
Style = ParamStyle("Style") | styleNoRescale;;
Plot( bbt = BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
Plot( bbb = BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
PlotOHLC( bbt, bbt, bbb, bbb, "", ColorBlend( Color, colorWhite, 0.9 ), styleCloud | styleNoRescale, Null, Null, Null, -1 );
_SECTION_END();

_SECTION_BEGIN("Candlestick Commentary Modified");
/*******************************************************
Modified by Abdulkareem Alghamdi
Candlestick Commentary
Load this file into the Commentary Option of the Analysis tab. Green arrows indicate bullish candles.
Red arrows indicate bearish candles. Scroll down the commentary for comments.
This is a work in progress. Thanks to all on this forum whose code I may have incorporated into this file. Comments are from Steve Nison "Japanese Candlestick Charting Techniques" and the LitWick web site.
**********************************************************/

/*Body Colors*/
whiteBody=C>=O;
blackBody=O>C;

/*Body Size*/
smallBodyMaximum=0.0025;//less than 0.25%
LargeBodyMinimum=0.01;//greater than 1.0%
smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody)
OR (C>=O*(1-smallBodyMaximum) AND blackBody);
largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody)
OR C<=O*(1-largeBodyMinimum) AND blackBody;
mediumBody=NOT LargeBody AND NOT smallBody;
identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) <
abs(O-C)*smallBodyMaximum;
realBodySize=abs(O-C);


/*Shadows*/
smallUpperShadow=(whiteBody AND H<=C*(1+smallBodyMaximum))
OR (blackBody AND H<=O*(1+smallBodyMaximum));
smallLowerShadow=(whiteBody AND L>=O*(1-smallBodyMaximum))
OR (blackBody AND L>=C*(1-smallBodyMaximum));
largeUpperShadow=(whiteBody AND H>=C*(1+largeBodyMinimum))
OR (blackBody AND H>=O*(1+largeBodyMinimum));
largeLowerShadow=(whiteBody AND L<=O*(1-largeBodyMinimum))
OR (blackBody AND L<=C*(1-largeBodyMinimum));

/*Gaps*/
upGap= IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0))));

downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C<Ref(C,-1),1,
IIf(Ref(blackbody,-1) AND blackBody AND O<Ref(C,-1),1,
IIf(Ref(whiteBody,-1) AND whiteBody AND C<Ref(O,-1),1,
IIf(Ref(whiteBody,-1) AND blackBody AND O<Ref(O,-1),1,0))));


/*Candle Definitions*/
spinningTop=mediumBody;
doji=CdDoji(threshold=0.05);/*abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));*/
dojiStar=doji AND (upgap OR downgap)AND Ref(LargeBody,-1);
marabuzu=LargeBody AND smallUpperShadow AND smallLowerShadow;

shootingStar=/*(NOT largeBody AND smallLowerShadow AND LargeUpperShadow) OR*/
smallLowerShadow AND NOT doji AND
((blackBody AND abs(O-H)>2*realBodySize) OR
(whiteBody AND abs(H-C)>2*realBodySize));

Hammer=smallUpperShadow AND NOT doji AND
((blackBody AND abs(C-L)>2*realBodySize) OR
(whiteBody AND abs(L-O)>2*realBodySize));

tweezerTop=abs(H-Ref(H,-1))<=H*0.0025;
tweezerBottom=abs(L-Ref(L,-1))<=L*0.0025;
engulfing=
IIf(blackBody AND Ref(blackbody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
IIf(blackBody AND Ref(whiteBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,
IIf(whitebody AND Ref(whitebody,-1) AND C>Ref(C,-1) AND O<Ref(O,-1),1,
IIf(whiteBody AND Ref(blackBody,-1) AND C>Ref(O,-1)AND O<Ref(C,-1),1,0))));
Harami=
IIf(blackbody AND Ref(blackBody,-1) AND O<Ref(O,-1) AND C>Ref(C,-1),1,
IIf(blackBody AND Ref(whiteBody,-1) AND C>Ref(O,-1) AND O<Ref(C,-1),1,
IIf(whiteBody AND Ref(whiteBody,-1) AND C<Ref(C,-1) AND O>Ref(O,-1),1,
IIf(whiteBody AND Ref(blackBody,-1) AND O>Ref(C,-1) AND C<Ref(O,-1),1,0))));


/*Maximum High Today - (MHT)
Today is the maximum High in the last 5 days*/
MHT= HHV(H,5)==H;

/*Maximum High Yesterday - (MHY)
Yesterday is the maximum High in the last 5 days*/
MHY= HHV(H,5)==Ref ( H, -1);

/*Minimum Low Today - (MLT)
Today is the minimum Low in the last 5 days*/
MLT= LLV(L,5)==L;

/*Minimum Low Yesterday - (MLY)
Yesterday is the minimum Low in the last 5 days*/
MLY= LLV(L,5)==Ref(L,-1);

/*DOJI definitions*/

/*Doji Today - (DT)*/
DT = abs(C-O) <= (C*smallBodyMaximum) OR
(abs(O-C)<=((H-L)*0.1));

/* Doji Yesterday - (DY)*/
DY = abs(Ref ( C, -1)-Ref(O,-1)) <= Ref ( C, -1) *smallBodyMaximum OR
abs (Ref ( O, -1)-Ref(C,-1)) <= (Ref ( H, -1 ) - Ref ( L, -1 ) )*0.1;

/**************************************************
BULLISH CANDLESTICKS
*************************************************** */

/* Abandoned Baby Bullish*/
abandonedBabybullish =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
AND Ref(GapDown(),-1)
AND whiteBody AND LargeBody AND GapUp();//Large white candle

/* Belt Hold*///Bad formula
beltHoldBullish = largeBody AND smallLowerShadow AND whiteBody AND MLT;


/*BreakAway Bullish*/
breakAwayBullish=Ref(Largebody,-4) AND Ref(blackBody,-4)
AND Ref(blackBody,-3) AND Ref(O,-3)<Ref(C,-4)
AND Ref(smallbody,-2) AND Ref(C,-2)<Ref(C,-3)
AND Ref(C,-1)<Ref(C,-2)
AND LargeBody AND whiteBody AND C>Ref(O, -3)
AND C<Ref(C,-4);

/*Concealing Baby Swallow only one trade */
ConcealingBabySwallow=Ref(marabuzu,-3) AND Ref(blackbody,-3) AND
Ref(MArabuzu,-2) AND Ref(blackBody,-2) AND
Ref(blackBody,-1) AND Ref(downGap,-1) AND
Ref(H,-1)>Ref(C,-2)AND Ref(blackbody,-1)AND
blackBody AND engulfing;

/*Doji Star Bullish*/
dojiStarBullish=(dojiStar AND (MLT OR MLY))OR
(doji AND (C<Ref(C,-1) OR O<Ref(C,-1))AND Ref(blackBody,-1)
AND Ref(LargeBody,-1));

/*Engulfing Bullish*/
engulfingBullish =
engulfing AND largeBody AND whiteBody AND
(Ref(blackbody,-1) OR Ref(Doji,-1)) AND MLT;

/*Hammer Bullish*/
hammerBullish=Hammer AND (MLT OR MLY);

/*Dragonfly Doji Bullish*/
dragonflyDoji=smallBody AND LargeLowerShadow AND smallUpperShadow AND MLT;

/* Harami Bullish*/
haramiBullish = harami AND Ref (LargeBody,-1) AND Ref(blackBody,-1) AND
NOT LargeBody AND whiteBody;

/*Harami Cross*/
HaramiCross=harami AND Ref(LargeBody,-1) AND Ref(blackBody,-1) AND doji;

/* Homing Pigeon*/
homingPigeon = Ref(largeBody,-1) AND Ref(blackBody,-1) AND
H<= Ref ( O, -1 ) AND L>=Ref( C, -1) AND C<O AND MLY;

/*Inverted Hammer*/
invertedHammer=shootingStar AND (MLT OR MLY);

/* Meeting LinesBullish*/
meetingLinesbullish= Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
LargeBody AND whiteBody AND
C>Ref(C,-1)*0.9975 AND C< Ref(C,-1)*1.0025;

/*Morning Doji Star*/
morningDojiStar= Ref(LargeBody,-2) AND Ref(blackBody,-2) AND
Ref(doji,-1) AND Ref(O,-1)<Ref(C,-2) AND
whiteBody AND C>Ref(C,-2) AND MLY;

/* Morning Star*/
morningStar =Ref(largeBody,-2) AND Ref(blackBody,-2)//Large black candle
AND Ref(downGap,-1)//Gap down yesterday
AND whiteBody AND LargeBody AND C>Ref(C,-2)//Large white candle today
AND MLY; //Yesterday was the low

/* Piercing Line*/
piercingLine= Ref(largeBody,-1) AND Ref(blackBody,-1)AND
O<Ref(L,-1) AND C>=(Ref(O,-1)+Ref(C,-1))/2 AND C<Ref(O,-1) AND MLT;

/* Stick Sandwich*/
stickSandwich=Ref(largeBody,-2) AND Ref(blackbody,-2) AND
Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
Ref(O,-1)>=Ref(C,-2) AND O>=Ref(C,-1) AND
abs(C-Ref(C,-2))<=C*0.0025;

/*Three Inside Up harami confirming*/
threeInsideUp =Ref(Haramibullish,-1) AND whiteBody AND
largeBody AND C>Ref(C,-1);


/* Three Outside Up Engulfing confirmation*/
threeOutsideUp =Ref(engulfingBullish,-1) AND whiteBody AND C>Ref(C,-1);

/* Three Stars in the South*///Rewrite???
threeStarsInTheSouth=
Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(largelowerShadow,-2)
AND Ref(blackBody,-1) AND Ref(largeLowerShadow,-1) AND
Ref(L,-1)>Ref(L,-2) AND blackBody AND smallUpperShadow AND
smallLowerShadow AND L>Ref(L,-1) AND H<Ref(H,-1);

/* Tri-Star Bullish*/
triStarBullish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MLY AND
Ref(downgap,-1) AND upGap;

/* Three River Bottom Bad formula*/
threeriverBottom=Ref(largeBody,-2) AND Ref(blackBody,-2) AND
Ref(blackbody,-1) AND Ref(Largelowershadow,-1) AND
Ref(O,-1)<Ref(O,-2) AND Ref(C,-1)>Ref(C,-2) AND
whiteBody AND C<Ref(C,-1) AND MLY;

/* Mat Hold Bullish*/
MAtHoldBullish=Ref(LargeBody,-4) AND Ref(whiteBody,-4)//1st day
AND Ref(blackBody,-3) AND Ref(upGap,-3) AND NOT Ref(LargeBody,-3)
AND NOT Ref(LargeBody,-2) AND Ref(C,-2)<Ref(C,-3) AND Ref (O,-2)<Ref(O,-3) AND
Ref(C,-2)>Ref(O,-4) AND NOT Ref(LargeBody,-1) AND Ref(C,-1)<Ref(C,-2)
AND LargeBody AND whiteBody AND C>Ref(C,-4);

/*RisingThreeMethods*/
risingThreeMethods=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND NOT
Ref(LargeBody,-3) AND NOT Ref(LargeBody,-2)AND NOT Ref(LargeBody,-1) AND
Ref(C,-3)<Ref(C,-4) AND Ref(C,-2)<Ref(C,-3) AND Ref(C,-1)<Ref(C,-2) AND
LargeBody AND whitebody AND C>Ref(C,-4);

/* Seperating Lines Bullish*/
separatingLinesBullish=Ref(blackBody,-1) AND whiteBody AND LargeBody AND
smallLowerShadow AND MHT AND abs(O-Ref(O,-1))<=O*0.0025;

/*Side by Side White Lines*/
sideBySideWhiteLines=NOT Ref(smallBody,-2) AND Ref(whiteBody,-2)
AND Ref(upGap,-1) AND Ref(whitebody,-1)AND whiteBody AND
identicalBodies AND abs(O-Ref(O,-1))<O*0.0025;


/*Three White Soldiers*/
threeWhiteSoldiers=NOT Ref(smallbody,-2) AND Ref(whiteBody,-2) AND NOT
Ref(smallBody,-1) AND Ref(whiteBody,-1) AND NOT
smallBody AND whiteBody AND C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2) AND
Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND O<Ref(C,-1) AND
O>Ref(O,-1) AND Ref(smallUpperShadow,-2) AND
Ref(smallUpperShadow,-1) AND smallUppershadow AND LLV(L,12)==Ref(L,-2);

/*Upside Gap Three Methods not very good*/
upsideGapThreeMethods=Ref(Largebody,-2) AND Ref(whiteBody,-2) AND
Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
blackBody AND O>Ref(O,-1) AND C<Ref(C,-2)AND C>Ref(O,-2) AND
MHY;

/*Three Line Strike not good signals*/
threeLineStrike=NOT Ref(smallBody,-3) AND NOT Ref(smallBody,-2) AND
NOT Ref(smallBody,-1) AND Ref(whiteBody,-3) AND Ref(whiteBody,-2) AND
Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND Ref(C,-2)>Ref(C,-3) AND
blackBody AND O>Ref(C,-1) AND C<Ref(O,-3);

/*Tweezer Bottom*/
tweezerBottom= (abs(L-Ref(L,-1))/L<0.0025 OR
abs(L-Ref(L,-2))/L<0.0025)
AND (MLT OR MLY);

/*Upside Tasuki Gap*/
upsideTasukiGap=Ref(largeBody,-2) AND Ref(largeBody,1) AND
Ref(whiteBody,-2) AND Ref(whiteBody,-1) AND Ref(upGap,-1) AND
blackBody AND O>Ref(O,-1) AND C<Ref(O,-1) AND C>Ref(C,-2) AND
identicalBodies AND O<Ref(C,-1);
//AND HHV(H,5)==Ref(H,-1); Do not use this line


/*****************************************
BEARISH CANDLESTICKS
******************************************/

/*Abandoned Baby Bearish*/
AbandonedBabyBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
Ref(smallBody,-1) AND Ref(GapUp(),-1) AND GapDown() AND
NOT smallBody AND blackBody AND MHY;

/*Advance Block Bearish*/
AdvanceBlockBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2)
AND Ref(whiteBody,-1) AND
whiteBody AND Ref(O,-1)>Ref(O,-2) AND Ref(O,-1)<Ref(C,-2) AND
Ref(C,-1)>Ref(C,-2) AND C>Ref(C,-1) AND
O<Ref(C,-1) AND O>Ref(O,-1) AND Ref(LargeUpperShadow,-1) AND LargeUpperShadow
AND C-O<Ref(C,-1)-Ref(O,-1) AND Ref(C,-1)-Ref(O,-1) < Ref(C,-2)-Ref(O,-2);

/*Belt Hold Bearish*/
beltHoldBearish=LargeBody AND BlackBody AND smalluppershadow AND MHT;

/*Breakaway Bearish*/
breakAwayBearish=Ref(LargeBody,-4) AND Ref(whiteBody,-4) AND
Ref(GapUp(),-3) AND Ref(whiteBody,-3) AND
Ref(smallbody,-2) AND Ref(smallBody,-1) AND
blackBody AND O>Ref(O,-3) AND C<Ref(C,-4);

/*Dark Cloud Cover*/
darkCloudCover=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
blackBody AND O>Ref(H,-1) AND C>Ref(O,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2
AND MHT;

/*Deliberation Bearish: needs confirmation*/
deliberationBearish=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND Ref(C,-1)>Ref(C,-2) AND
smallbody AND upGap;

/*CounterAttackBearish*/
CounterAttackBearish=MHT AND LargeBody AND blackbody AND
Ref(largeBody,-1) AND Ref(whiteBody,-1) AND
C<Ref(C,-1)*1.0025 AND C>Ref(C,-1)*0.9975;;

/*Doji Star Bearish*/
dojiStarBearish=(dojiStar AND (MHT OR MHY))OR
(doji AND (C>Ref(C,-1) OR O>Ref(C,-1))AND Ref(whiteBody,-1)
AND Ref(LargeBody,-1));

/*Engulfing Bearish*/
engulfingBearish=engulfing AND largeBody AND blackBody AND
(Ref(whitebody,-1) OR Ref(Doji,-1))AND (MHT OR MHY);

/*Evening Doji Star check formula???*/
eveningDojiStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
Ref(dojiStar,-1) AND Ref(GapUp(),-1) AND (MHY OR MHT);

/*Evening Star*/
eveningStar=Ref(LargeBody,-2) AND Ref(whiteBody,-2) AND
Ref(upGap,-1) AND NOT Ref(largeBody,-1) AND blackBody AND NOT smallBody AND
(MHT OR MHY);

/*Hammer Bearish*/
HammerBearish=Hammer AND HHV(H,8)==H;

/*hangingMan*/
HangingMan=NOT largeBody AND smallUpperShadow AND LargeLowerShadow AND MHT;

/*dragonfly Doji Bearish*/
dragonflyDojiBearish=doji AND smallUpperShadow AND LargeLowerShadow AND MHT;

/*Harami Bearish-*/
HaramiBearish=harami AND Ref(Largebody,-1) AND Ref(whiteBody,-1)AND blackBody
AND (MHY OR MHT);

/*HaramiCross Bearish*/
HaramiCrossBearish=harami AND doji AND Ref(whiteBody,-1) AND Ref(Largebody,-1);

/*Identical three black crows*/
idendicalThreeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody AND
abs(Ref(C,-2)-Ref(O,-1))<Ref(C,-1)*0.0025 AND abs(Ref(C,-1)-O)<O*0.0025 AND
HHV(H,20)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji AND
Ref(smallLowerShadow,-2) AND Ref(smallLowerShadow,-1) AND smallLowerShadow;

/*Kicking Bearish No trades*/
kickingBearish=Ref(whiteBody,-1) AND Ref(MArabuzu,-1) AND blackBody AND MArabuzu AND GapDown();

/*Meeting Lines Bearish*/
MeetingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
HHV(C,8)==Ref(C,-1) AND LargeBody AND blackBody AND
abs(C-Ref(C,-1))<C*0.0025;

/*ShootingStar*/
shootingStarGap=shootingStar AND GapUp() AND MHT;

/*Gravestone Doji*/
gravestoneDoji=doji AND largeUpperShadow AND smallLowerShadow AND GapUp()AND MHT;

/*Three Inside Down Bearish*/
threeInsideDownBearish=Ref(HaramiBearish,-1) AND blackBody AND C<Ref(C,-1)AND smallUpperShadow;

/*Three Outside Down Bearish*/
threeoutsideDownBearish=Ref(engulfingBearish,-1) AND blackBody AND C<Ref(C,-1)AND
NOT LargeUpperShadow;

/*Tri Star Bearish*/
triStarBearish=Ref(doji,-2) AND Ref(doji,-1) AND doji AND MHY AND Ref(upGap,-1)AND downGap;

/*Two Crows Bearish*/
twoCrows=Ref(whiteBody,-2) AND Ref(LargeBody,-2) //first day
AND Ref(blackBody,-1) AND Ref(upGap,-1)//Second Day
AND blackBody AND O<Ref(O,-1) AND O>Ref(C,-1)AND C<Ref(C,-2) AND
C>Ref(O,-2) AND MHY;//Third day

/*Upside Gap Two Crows*/
upsideGapTwoCrows= Ref(whiteBody,-2) AND Ref(LargeBody,-2)// first day
AND Ref(upGap,-1) AND Ref(blackBody,-1) // 2nd day
AND blackbody AND O>Ref(O,-1) AND C<Ref(C,-1) AND C>Ref(C,-2);

/*Doji Star Bearish needs confirmation
dojiStarBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) // first day
AND doji AND upGap AND MHT;*/

/* Downside Gap Three Methods*/
downsideGapThreeMethods=
Ref(LargeBody,-2) AND Ref(blackBody,-2) AND Ref(downGap,-2) //first day
AND Ref(LargeBody,-1) AND Ref(blackBody,-1)//2nd day
AND whitebody AND O<Ref(O,-1) AND C>Ref(C,-2)
AND LLV(L,8)==Ref(L,-1);

/*Downside Tasuki Gap*/
downsideTasukiGap=
Ref(blackBody,-2)//first day
AND Ref(blackbody,-1) AND Ref(downgap,-1) //2nd day
AND whiteBody AND O<Ref(O,-1) AND O>Ref(C,-1) AND C>Ref(O,-1) AND C<Ref(C,-2)
AND Ref(identicalBodies,-1)
AND LLV(L,15)==Ref(L,-1);


/*Falling Three Meothods*/
fallingThreeMethods=Ref(LargeBody,-4) AND Ref(blackBody,-4) AND
/*Ref(doji,-3) AND Ref(doji,-2) AND Ref(doji,-1) AND*/ Ref(C,-1)>Ref(C,-2)
AND Ref(C,-2)>Ref(C,-3) AND LargeBody AND blackBody AND O>Ref(C,-4) AND
O<Ref(O,-4) AND C<Ref(O,-4)AND C<Ref(C,-4);

/*In Neck Bearish not good*/
inNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
whiteBody AND O<Ref(L,-1) AND C<Ref(C,-1)*1.0005 AND C>=Ref(C,-1);

/*On Neck Bearish not good*/
OnNeckBearish=Ref(LargeBody,-1) AND Ref(blackBody,-1) AND
whiteBody AND O<Ref(L,-1) AND C<Ref(L,-1)*1.0025 AND C>=Ref(L,-1)*0.9975;

/*separating Lines Bearish*/
separatingLinesBearish=Ref(LargeBody,-1) AND Ref(whiteBody,-1) AND
blackBody AND O>Ref(O,-1)*0.9975 AND O<=Ref(O,-1)*1.0025;

/*Side By Side White Lines Bearish*/
sideBySideWhiteLinesBearish=NOT Ref(smallBody,-2) AND Ref(blackBody,-2) AND
Ref(whiteBody,-1) AND whiteBody AND Ref(downGap,-1) AND identicalBodies
AND abs(C-Ref(C,-1)<C*0.0025);

/*Three Black Crows*/
threeBlackCrows=Ref(blackBody,-2) AND Ref(blackBody,-1) AND blackBody AND Ref(C,-1)<Ref(C,-2) AND C<Ref(C,-1) AND HHV(H,8)==Ref(H,-2) AND NOT Ref(doji,-2) AND NOT Ref(doji,-1) AND NOT doji;;

/*Three Line Strike no trades*/
threeLineStrike=threeBlackCrows AND whiteBody AND O<Ref(C,-1) AND C>Ref(O,-3);

/*Thrusting Bearish*/
thrustingBearish=Ref(blackBody,-1) AND Ref(LargeBody,-1) AND LargeBody AND
whitebody AND O<Ref(L,-1) AND C<(Ref(O,-1)+Ref(C,-1))/2 AND C>Ref(C,-1);

/*Tweezer Top*/
tweezerTop= (abs(H-Ref(H,-1))/H<0.0025 OR
abs(H-Ref(H,-2))/H<0.0025)
AND (MHT OR MHY);



/* ***********************************************
Buy Rules
**************************************************/
Buy=
abandonedBabybullish OR
beltHoldBullish OR
breakAwayBullish OR
ConcealingBabySwallow OR
engulfingBullish OR
hammerBullish OR
dragonflyDoji OR
dojiStarBullish OR
haramiBullish OR
HaramiCross OR
homingPigeon OR
invertedHammer OR
meetingLinesbullish OR
morningDojiStar OR
morningStar OR
piercingLine OR
stickSandwich OR
threeInsideUp OR
threeOutsideUp OR
threeStarsInTheSouth OR
triStarBullish OR
threeriverBottom OR
MAtHoldBullish OR
risingThreeMethods OR
separatingLinesBullish OR
sideBySideWhiteLines OR
threeWhiteSoldiers OR
upsideGapThreeMethods OR
threeLineStrike OR
tweezerBottom OR
upsideTasukiGap;

/************************************
Sell Rules
*************************************/
Sell=
AbandonedBabyBearish OR
advanceBlockBearish OR
beltHoldBearish OR
breakAwayBearish OR
darkCloudCover OR
deliberationBearish OR
CounterAttackBearish OR
engulfingBearish OR
eveningDojiStar OR
eveningStar OR
HangingMan OR
dragonflyDojiBearish OR
HammerBearish OR
HaramiBearish OR
HaramiCrossBearish OR
idendicalThreeBlackCrows OR
kickingBearish OR
MeetingLinesBearish OR
shootingStarGap OR
gravestoneDoji OR
threeInsideDownBearish OR
threeoutsideDownBearish OR
triStarBearish OR
twoCrows OR
upsideGapTwoCrows OR
dojiStarBearish OR
downsideGapThreeMethods OR
downsideTasukiGap OR
fallingThreeMethods OR
inNeckBearish OR
OnNeckBearish OR
separatingLinesBearish OR
sideBySideWhiteLinesBearish OR
threeBlackCrows OR
threeLineStrike OR
thrustingBearish OR
tweezerTop;


/***************************************
Commentary
***************************************
Bullish Candles
****************************************/
WriteIf(Buy,"Bullish\n=======\n","")+
WriteIf(abandonedBabybullish,"Abandoned Baby Bullish. \nA reversal pattern.\n\\c16LiWick reliability : High.","")+
WriteIf(beltHoldBullish,"Belt Hold Bullish. \nA reversal pattern.\nNison:The larger the candlestick, the more significant it is.\nLitWick Reliability: Low.","")+
WriteIf(breakAwayBullish,"Break Away Bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(ConcealingBabySwallow,"Concealing Baby Swallow. \nA reversal pattern.\n LitWick reliability: high.","")+
WriteIf(dojiStarBullish,"Bullish doji Star. A reversal pattern.\nNison: Needs confirmation. Better at calling tops.\nLitWick reliability: moderate.","")+
WriteIf(engulfingBullish,"Bullish Engulfing. \nA reversal pattern.\nNison: Factors increasing the pattern's effectiveness are\n1) The first day has a small real body and the second day has a large real body.\n2) Pattern appears after protracted or very fast move.\n3) Heavy volume on second real body.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate","")+
WriteIf(hammerBullish,"Bullish Hammer. \nA reversal pattern.\nNison: The longer the lower shadow, the smaller the upper shadow, and the smaller the real body, the more significant the pattern.White real body more bullish than black body.\nLitWick reliability: low.","")+
WriteIf(dragonflyDoji,"Dragonfly Doji. \nLitWick reliability: moderate.","")+
WriteIf(haramiBullish, "Harami Bullish. \nA reversal pattern.\nNison: Less significant. Pattern needs confirmation.\nLitWick reliability: low.","")+
WriteIf(HaramiCross,"Harami Cross. \nA reversal pattern.\nNison: Better indicator than Harami. Better at calling tops than bottoms.\nLitWick reliability: low.","")+
WriteIf(homingPigeon,"Homing Pigeon. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(invertedHammer,"Inverted Hammer. \nA reversal pattern.\nNison:Needs bullish verification.\nLitWick reliability: low.","")+
WriteIf(meetingLinesbullish,"Meeting Lines bullish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(morningDojiStar,"Morning Doji Star. \nA reversal pattern.\nImportant reversal signal.\nLitWick reliability: high.","")+
WriteIf(morningStar,"Morning Star. \nA reversal pattern.\nNison: The stronger the white third body the better.\nLitWick reliability: high.","")+
WriteIf(piercingLine,"Piercing Line. \nA reversal pattern.\nNison: A stron reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(stickSandwich,"Stick Sandwich. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideUp,"3 Inside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeOutsideUp,"3 Outside Up. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(threeStarsInTheSouth,"3 Stars in the South. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(triStarBullish,"Tri-Star Bullish. \nA reversal pattern.\nNison: Significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeriverBottom,"3 River Bottom. \nA reversal pattern.\nNison: Selling pressure drying up.\nLit Wick reliability: moderate.","")+
WriteIf(MAtHoldBullish,"Mat Hold Bullish. \nA continuation pattern.\nNison: May have 2-4 black candles.\nLitWick reliability: high. ","")+
WriteIf(risingThreeMethods,"Rising Three Methods. \nA continuation pattern>\nNison: Has more significance if volume of white candle sticks is greater than on black candlesticks.\nLitWick reliability: high.","")+
WriteIf(separatingLinesBullish,"Separating Lines Bullish. \nA continuation pattern.\nNison: \nLitWick reliability: low.","")+
WriteIf(sideBySideWhiteLines,"Side by Side White Lines. \nA continuation pattern.\nNison: If occurring during a downtrend may only be short covering.\nLitWick reliability: high.","")+
WriteIf(threeWhiteSoldiers,"3 White Soldiers. \nA continuation pattern.\nNison: Positive, but be aware of negative similar stalled pattern and advance block pattern.\nLitWick reliability: high.","")+
WriteIf(upsideGapThreeMethods,"Upside Gap 3 Methods. \nA continuation pattern.\nLitWick reliability: moderate.","")+
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(tweezerBottom,"Tweezer Bottom.\nA reversal pattern. With other reversal candles it could indicate a support level.\nNison: Needs confirmation.","")+
WriteIf(upsideTasukiGap,"Upside Tasuki Gap. \nA continuation pattern.\nNison: the real bodies of the two candlesticks in the gap should be about the same size.\nLitWick reliability: moderate.","")+
WriteIf(Buy,"\n-------------------------------------------","");; /***************************************
Bearish Candles
********************************************/
WriteIf(Sell,"Bearish\n=======\n","")+
WriteIf(AbandonedBabyBearish,"Abandoned Baby Bearish. \nA reversal pattern.\nNison: Extremely rare.\nLitWick reliability: high.","")+
WriteIf(advanceBlockBearish,"Advancing Block Bearish. \nA reversal pattern.\nNison: Rally is in trouble. Signs of weakening could be progressively smaller white read bodies or relatibvely long upper shadows on the last two white candlesticks.Not necessarily a reversal pattern.\nLitWick Reliability: moderate.","")+
WriteIf(beltHoldBearish,"Belt Hold Bearish. \nA reversal pattern.\nNison: The longer the height of the belt-hold candle the more significant the pattern.\nLitWick reliability: low.","")+
WriteIf(breakAwayBearish,"Break Away Bearish. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(darkCloudCover,"Dark Cloud Cover. \nA reversal pattern.\nNison: Factors indicating the importance of this signal are/n1)The greater the penetration of the first candle by the second.\n2)Both candles are marabozus.\n3)The second body opens above a major resistance level.\n4)High volume on the second day.\nLitWick Reliability: high.","")+
WriteIf(deliberationBearish,"Deliberation Bearish. \nA reversal pattern.\nNison: Not a reversal pattern, but a sign the rally is weakening.\nLitWick reliability: moderate.","")+
WriteIf(CounterAttackBearish,"Counter Attack Bearish.\nNison: A potential stalling of the rally.","")+
WriteIf(engulfingBearish,"Engulfing Bearish. \nA reversal pattern.\nNison: Major reversal signal. Factors increasing patterns importance are\n1) The first day has a very small real body and the second day a very large real body.\n2) The pattern apears after a protracted or very fast move.\n3) Heavy volume on the second day.\n4) The second day engulfs more than one real body.\nLitWick reliability: moderate.","")+
WriteIf(eveningDojiStar,"Evening Doji Star \nA reversal pattern.\nNison: Must be confirmed by long black candle.\nLit Wick reliability: high","")+
WriteIf(eveningStar,"Evening Star. \nA reversal pattern.\nNison: Gap between Second AND third bodies does NOT always occur.\nLitWick reliability: High.","")+
WriteIf(HammerBearish,"Bearish Hammer. \nA reversal pattern.\nNison: More bearish if hammer is black. Needs bearish confirmation. A large gap down on the following day would be a good confirmation.","")+
WriteIf(HangingMan,"Hanging Man. \nA reversal pattern.\nNison: Same as bearish hammer with a large gap down the following day.\nLitWick reliability: low.","")+
WriteIf(dragonflyDojiBearish,"Dragonfly Bearish. \nA reversal pattern.\nNison: Same as Hanging Man.\nLitWick reliability: moderate.","")+
WriteIf(HaramiBearish,"Harami Bearish. \nA reversal pattern.\nNison: Not as significant a reversal pattern as hanging man or engulfing.\nLitWick reliability: low.","")+
WriteIf(HaramiCrossBearish,"Harami Cross Bearish. \nA reversal pattern.\nNison: More significant reversal pattern than Harami. Second day can be white or black.\nLitWick reliability: moderate.","")+
WriteIf(idendicalThreeBlackCrows,"Identical 3 Black Crows. \nA reversal pattern in an uptrend.\nNison:Very bearish.\nLitWick reliability: high. ","")+
WriteIf(kickingBearish,"Kicking Bearish. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(MeetingLinesBearish,"Meeting Lines Bearish. \nA reversal pattern.\nNison: \nLitWick reliability: moderate, but not as strong as Dark cloud Cover.","")+
WriteIf(shootingStarGap,"Shooting Star. \nA reversal pattern.\nNison:Not major reversal signal as evening star. Ideally real body would gap away from previous body. Needs to appear after an uptrend.\nLitWick reliability: low.","")+
WriteIf(gravestoneDoji,"Gravestone Doji. \nA reversal pattern.\nNison: more significant if it hits new high.\nLitWick reliability: moderate.","")+
WriteIf(threeInsideDownBearish,"3 Inside Down. \nA reversal pattern.\nNison: \nLitWick reliability: high.","")+
WriteIf(threeoutsideDownBearish,"3 Outside Down. \nA reversal pattern.\nLitWick reliability: high.","")+
WriteIf(triStarBearish,"Tri-Star Bearish. \nA reversal pattern.\nNison: Very significant reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(twoCrows,"2 Crows. \nA reversal pattern.\nLitWick reliability: moderate.","")+
WriteIf(upsideGapTwoCrows,"Upside Gap 2 Crows. \nA reversal pattern.\nNison:Needs confirmation of a continued reversal on third day.\nLitWick reliability: high.","")+
WriteIf(dojiStarBearish,"Doji Star Bearish. \nA reversal pattern.\nNison: needs confirmation.\nLitWick reliability: moderate.","")+
WriteIf(downsideGapThreeMethods,"Downside Gap 3 Methods. A continuation pattern.\nNison: \nLitWick reliability: moderate.","")+
WriteIf(downsideTasukiGap,"Downside Tasuki Gap. \nA continuation method.\NNison: If last day closes window, continuation pattern is negated.\nLitWick reliability: moderate.","")+
WriteIf(fallingThreeMethods,"Falling 3 Methods. \nA continuation pattern.\nNison: \nLitWick reliability: high.","")+
WriteIf(inNeckBearish,"In Neck Bearish. A continuatin pattern.\nNison: Similar to piercing pattern but bearish because there is no penetration of second day.\nLitWick reliability: moderate.","")+
WriteIf(OnNeckBearish,"On Neck Bearish. \nA continuation pattern. Similar to piercing pattern but bearish beccause there is no penetration of the second day.\nLitWick reliability: moderate.","")+
WriteIf(separatingLinesBearish,"Separating Lines Bearish","");
WriteIf(sideBySideWhiteLinesBearish,"Side by Side White Lines Bearish. \nA continuation pattern.\nNison: very rare.\nLitWick reliability: moderate.","")+
WriteIf(threeBlackCrows,"3 Black Crows. \nA reversal pattern.\nNison: Need to appear after a mature advance.\nLitWick reliability: high.","")+
WriteIf(threeLineStrike,"3 Line Strike. \nA continuation pattern.\nLitWick reliability: low.","")+
WriteIf(thrustingBearish,"Thrusting. \nA continuation pattern.\nNison: Not a reversal day because second day does not pierce midpoint of first day.\nLitWick reliability: low.","")+
WriteIf(tweezerTop,"Tweezer Top. \nA reversal pattern.\nNison: Needs confirmation.","")+
WriteIf(Sell,"\n---------------------------------------------------","");

/***********************************************
End Commentary
************************************************/

_SECTION_END();


Kindly delete studies which you dont want after saving so work become more easy
 
#3
hello Manish ,

These are not fractal chart Signals. I have checked the signals where ur afl is giving Buy signal..the fractal chart is giving Sell ..its like Pivotal high /Low..but bit different from pivot high /Low.

Seniors please help..
 

trash

Well-Known Member
#5
Code:
// Ed Pottasch

period = Param( "Period", 5, 2, 50, 1 );

// define fractals
HHV_ = HHV( H, period );
LLV_ = LLV( L, period );
PHigh = H > Ref( HHV_, -1 ) AND Ref( HHV_, period ) <= H;
PHighPrice = ValueWhen( PHigh, H );
PLow = L < Ref( LLV_, -1 ) AND Ref( LLV_, period ) >= L;
PLowPrice = ValueWhen( PLow, L );

// chart
GraphXSpace = 5;
SetChartOptions( 0, chartShowDates );

Plot( C, "Price", colorWhite, styleCandle );

PlotShapes( shapeSmallCircle * PLow, colorGreen, 0, L, -10 );
PlotShapes( shapeSmallCircle * PHigh, colorRed, 0, H, 10 );
Plot(PLowPrice, "Fractal Low", colorGreen, styleDots | styleNoLine);
Plot(PHighPrice, "Fractal High", colorRed, styleDots | styleNoLine);
 

MANISH_DAMANI

Well-Known Member
#7
In pattern explorer also fractals are their check it
 

trash

Well-Known Member
#10
Hello Trash,

Thanx you for ur efforts to post the afl. But dear its not helping my cause as shown in the Picture.

Waiting for seniors to help
Then provide the formula!! I don't play kind of wheel of fortune by looking at pictures that don't provide any useful info.
 
Last edited:

Similar threads