CODING REQUEST -- coding price action "nial fuller's "setup

#11
this is fakey without pin on the fourth bar
Code:
_SECTION_BEGIN("Fakey Inside Bar 1");
SetChartOptions(0,chartShowArrows|chartShowDates); 
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); 
_N( Title = Title +"\n" + _DEFAULT_NAME() ); 

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 


 Buy = (Ref(L,-2) >= Ref(L,-3)) AND (Ref(H,-2) <= Ref(H,-3)) AND Low < Ref(Low,-2) AND Low < Ref(Low,-3) AND Close > Ref(Low,-3) AND Close > Ref(Low,-2);

Sell = (Ref(L,-2) >= Ref(L,-3)) AND (Ref(H,-2) <= Ref(H,-3)) AND High > Ref(H,-2) AND High > Ref(H,-3) AND Close < Ref(H,-3) AND Close < Ref(H,-2);


PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,Low,Offset=-15);

PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorBlack,0,Low,Offset=-15);
_SECTION_END();
 
#12
Please check visually as i am not that cnfident being an amateur. Let me know any errors there and ill try to correct. I cant do the first two Pinbar Fakeys as i dont know how to code a Pin.

Note - Just read the code you'll understand how easy it is to code simple afls. Furthermore, there's inbuilt Codewizard for simple coding needs in Ami.
 
Last edited:
#13
dear manju

the fakey setup seems ok . and the pin bar + inside bar doesnot seem ok .


for the pin bar i have two diff afl . one is http://www.marketcalls.in/amibroker/pin-bar-detector-amibroker-afl-code.html

and the other is

PHP:
_SECTION_BEGIN("asnavale candlePatterns");
/******************************************************/
/*                                                    */
/*                    PATTERNS.AFL                    */
/*                    ============                    */
/*                  By A. S. Navale)                  */
/*                                                    */
/*  This AFL marks different patterns on the chart.   */
/*  The Patterns to mark can be selected from the     */
/*  'Parameters' Drop-down list which appears when    */
/*  right-click in the chart. By Fefault all patterns */
/*  are marked.                                       */
/*                                                    */
/*  The Title of the chart displays the name of the   */
/*  pattern made by the candle which is selected.     */
/*                                                    */
/*  The patterns are: Pin Bar, Inside Bar (IB), Doji, */
/*  Double Doji, 3IB(Double Inside Bar), PopGun and   */
/*  Master Candle.                                    */
/*                                                    */
/*  You can also run Exploration to list the stocks   */
/*  which have the selected pattern.                  */
/*                                                    */
/******************************************************/


SetChartOptions(0, chartShowDates | chartWrapTitle);
SetChartBkColor(colorBlack);

Body = abs(O - C);
InsideBody = IIf(Ref(O, -1) > Ref(C, -1), (O < Ref(O, -1) AND O > Ref(C, -1)) AND (C < Ref(O, -1) AND C > Ref(C, -1)), (O > Ref(O, -1) AND O < Ref(C, -1)) AND (C > Ref(O, -1) AND C < Ref(C, -1)));

Wick = IIf(O > C, H - O, H - C);
Tail = IIf(O > C, C - L, O - L);
PB = (Wick >= 3 * Body) OR (Tail >= 3 * Body) AND InsideBody;

DJ = CdDoji();
DblDJ = DJ AND Ref(DJ, -1);

OB = Outside();
IB = Inside();
IIB = IB AND Ref(IB, -1);

PopGun = OB AND Ref(IB, -1);

M = H < Ref(H, -4) AND Ref(H, -1) < Ref(H, -4) AND Ref(H, -2) < Ref(H, -4) AND Ref(H, -3) < Ref(H, -4) AND L > Ref(L, -4) AND Ref(L, -1) > Ref(L, -4) AND Ref(L, -2) > Ref(L, -4) AND Ref(L, -3) > Ref(L, -4);
MC = Null;

for(i = 4; i< BarCount; i++)
	{
		MC[i - 4] = M[i];
	}

Fltr = ParamList("Filter on", "All,PinBar,Doji,DoubleDoji,InsideBar,3IB,PopGun,MasterCandle");
 
PBTxt = WriteIf(PB, "Pin Bar, ", "");
IBTxt = WriteIf(IB, "Inside Bar, ", "");
IIBTxt = WriteIf(IIB, "3IB, ", "");
DblDJTxt = WriteIf(DblDJ, "Double ", "");
DJTxt = WriteIf(DJ, "Doji, ", "");
PGTxt = WriteIf(PopGun, "Pop Gun, ", "");
MCTxt = WriteIf(MC, "Master Candle, ", "");

CdlTxt = MCTxt + IBTxt + IIBTxt + DblDJTxt + DJTxt + PGTxt + PBTxt;

if(Status("action") == actionIndicator)
	{
		_N(Title = StrFormat("{{NAME}}({{INTERVAL}}), {{DATE}} : {{OHLCX}}, V=%1.0f, ", V) + CdlTxt);

		Plot(C, "", colorLightGrey, styleCandle);

		if(Fltr == "Doji")
			{
				PlotShapes(IIf(DJ, shapeSmallCircle, shapeNone), colorSkyblue, 0, L);
			}
		if	(Fltr == "DoubleDoji")
			{
				PlotShapes(IIf(DblDJ, shapeHollowCircle, shapeNone), colorSkyblue, 0, L);
			}
		if(Fltr == "PopGun")
			{
				PlotShapes(IIf(PopGun, shapeSmallSquare, shapeNone), colorYellow, 0, H, 12);
			}
		if(Fltr == "InsideBar")
			{
				PlotShapes(IIf(IB, shapeHollowSmallCircle, shapeNone), colorGold, 0, H, 12);
			}
		if(Fltr == "3IB")
			{
				PlotShapes(IIf(IIB, shapeDigit3, shapeNone), colorPink, 0, H, 12);
			}
		if(Fltr == "MasterCandle")
			{
				PlotShapes(IIf(MC, shapeCircle, shapeNone), colorYellow, 0, H, 12);
			} 
		if(Fltr == "PinBar")
			{
				PlotShapes(IIf(PB, shapeHollowDownArrow, shapeNone), colorWhite, 0, H, -20);
			}
		if(Fltr == "All")
			{
				PlotShapes(IIf(PB, shapeHollowDownArrow, shapeNone), colorWhite, 0, H, -20);
				PlotShapes(IIf(DJ, shapeSmallCircle, shapeNone), colorSkyblue, 0, L);
				PlotShapes(IIf(DblDJ, shapeHollowCircle, shapeNone), colorSkyblue, 0, L);
				PlotShapes(IIf(PopGun, shapeSmallSquare, shapeNone), colorYellow, 0, H, 12);
				PlotShapes(IIf(IB, shapeHollowSmallCircle, shapeNone), colorGold, 0, H, 12);
				PlotShapes(IIf(IIB, shapeDigit3, shapeNone), colorPink, 0, H, 12);
				PlotShapes(IIf(MC, shapeCircle, shapeNone), colorYellow, 0, H, 12);
			}
	
}

if(Status("action") == actionExplore)
	{
		SetOption("NoDefaultColumns", True);
		
	switch (Fltr)	
	{

	case "PinBar":
			Filter = PB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(PBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			break;

	case "InsideB":
			Filter = IB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(IBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "3IB":
			Filter = IIB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(IIBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "DoubleDoji":
			Filter = DblDJ;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(DblDJTxt + "Doji", "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "Doji":
			Filter = DJ;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(DJTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "PopGun":
			Filter = PopGun;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(PGTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "MasterCandle":
			Filter = MC;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn("Master Candle", "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "All":
			Filter = PB OR IB OR IIB OR DblDJ OR DJ OR PopGun OR MC;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(CdlTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;
	}
	}
_SECTION_END();

the issue is both of them plots diff .

also inside bar is a defined function in amibroker.

the second fuller's setup is met when the either of the two conditions are met

1) pin bar followed by inside bar

2) a pin bar which in itself is an inside bar


Many thanks to manju for putting in efforts


rgds


sumit
 
#15
Code:
n     = Param("Wick_Body_Ratio",3,1,5,0.1);
Body = abs(O - C);
Wick = IIf(O > C, H - O, H - C);
Tail  = IIf(O > C, C - L, O - L);
PB  = (Wick >= n * Body) OR (Tail >= n * Body);
IB  = H < ref(H,-1) AND L > ref(L,-1);
Adjust the ratio for getting the right kind of pin bars you need
then can use the PB & IB to get your combinations for e.g.

Code:
F1 = IB AND (ref(PB,-1) OR PB);
Thanks
 
#16
dear manju

the fakey setup seems ok . and the pin bar + inside bar doesnot seem ok .


for the pin bar i have two diff afl . one is http://www.marketcalls.in/amibroker/pin-bar-detector-amibroker-afl-code.html

and the other is

PHP:
_SECTION_BEGIN("asnavale candlePatterns");
/******************************************************/
/*                                                    */
/*                    PATTERNS.AFL                    */
/*                    ============                    */
/*                  By A. S. Navale)                  */
/*                                                    */
/*  This AFL marks different patterns on the chart.   */
/*  The Patterns to mark can be selected from the     */
/*  'Parameters' Drop-down list which appears when    */
/*  right-click in the chart. By Fefault all patterns */
/*  are marked.                                       */
/*                                                    */
/*  The Title of the chart displays the name of the   */
/*  pattern made by the candle which is selected.     */
/*                                                    */
/*  The patterns are: Pin Bar, Inside Bar (IB), Doji, */
/*  Double Doji, 3IB(Double Inside Bar), PopGun and   */
/*  Master Candle.                                    */
/*                                                    */
/*  You can also run Exploration to list the stocks   */
/*  which have the selected pattern.                  */
/*                                                    */
/******************************************************/


SetChartOptions(0, chartShowDates | chartWrapTitle);
SetChartBkColor(colorBlack);

Body = abs(O - C);
InsideBody = IIf(Ref(O, -1) > Ref(C, -1), (O < Ref(O, -1) AND O > Ref(C, -1)) AND (C < Ref(O, -1) AND C > Ref(C, -1)), (O > Ref(O, -1) AND O < Ref(C, -1)) AND (C > Ref(O, -1) AND C < Ref(C, -1)));

Wick = IIf(O > C, H - O, H - C);
Tail = IIf(O > C, C - L, O - L);
PB = (Wick >= 3 * Body) OR (Tail >= 3 * Body) AND InsideBody;

DJ = CdDoji();
DblDJ = DJ AND Ref(DJ, -1);

OB = Outside();
IB = Inside();
IIB = IB AND Ref(IB, -1);

PopGun = OB AND Ref(IB, -1);

M = H < Ref(H, -4) AND Ref(H, -1) < Ref(H, -4) AND Ref(H, -2) < Ref(H, -4) AND Ref(H, -3) < Ref(H, -4) AND L > Ref(L, -4) AND Ref(L, -1) > Ref(L, -4) AND Ref(L, -2) > Ref(L, -4) AND Ref(L, -3) > Ref(L, -4);
MC = Null;

for(i = 4; i< BarCount; i++)
	{
		MC[i - 4] = M[i];
	}

Fltr = ParamList("Filter on", "All,PinBar,Doji,DoubleDoji,InsideBar,3IB,PopGun,MasterCandle");
 
PBTxt = WriteIf(PB, "Pin Bar, ", "");
IBTxt = WriteIf(IB, "Inside Bar, ", "");
IIBTxt = WriteIf(IIB, "3IB, ", "");
DblDJTxt = WriteIf(DblDJ, "Double ", "");
DJTxt = WriteIf(DJ, "Doji, ", "");
PGTxt = WriteIf(PopGun, "Pop Gun, ", "");
MCTxt = WriteIf(MC, "Master Candle, ", "");

CdlTxt = MCTxt + IBTxt + IIBTxt + DblDJTxt + DJTxt + PGTxt + PBTxt;

if(Status("action") == actionIndicator)
	{
		_N(Title = StrFormat("{{NAME}}({{INTERVAL}}), {{DATE}} : {{OHLCX}}, V=%1.0f, ", V) + CdlTxt);

		Plot(C, "", colorLightGrey, styleCandle);

		if(Fltr == "Doji")
			{
				PlotShapes(IIf(DJ, shapeSmallCircle, shapeNone), colorSkyblue, 0, L);
			}
		if	(Fltr == "DoubleDoji")
			{
				PlotShapes(IIf(DblDJ, shapeHollowCircle, shapeNone), colorSkyblue, 0, L);
			}
		if(Fltr == "PopGun")
			{
				PlotShapes(IIf(PopGun, shapeSmallSquare, shapeNone), colorYellow, 0, H, 12);
			}
		if(Fltr == "InsideBar")
			{
				PlotShapes(IIf(IB, shapeHollowSmallCircle, shapeNone), colorGold, 0, H, 12);
			}
		if(Fltr == "3IB")
			{
				PlotShapes(IIf(IIB, shapeDigit3, shapeNone), colorPink, 0, H, 12);
			}
		if(Fltr == "MasterCandle")
			{
				PlotShapes(IIf(MC, shapeCircle, shapeNone), colorYellow, 0, H, 12);
			} 
		if(Fltr == "PinBar")
			{
				PlotShapes(IIf(PB, shapeHollowDownArrow, shapeNone), colorWhite, 0, H, -20);
			}
		if(Fltr == "All")
			{
				PlotShapes(IIf(PB, shapeHollowDownArrow, shapeNone), colorWhite, 0, H, -20);
				PlotShapes(IIf(DJ, shapeSmallCircle, shapeNone), colorSkyblue, 0, L);
				PlotShapes(IIf(DblDJ, shapeHollowCircle, shapeNone), colorSkyblue, 0, L);
				PlotShapes(IIf(PopGun, shapeSmallSquare, shapeNone), colorYellow, 0, H, 12);
				PlotShapes(IIf(IB, shapeHollowSmallCircle, shapeNone), colorGold, 0, H, 12);
				PlotShapes(IIf(IIB, shapeDigit3, shapeNone), colorPink, 0, H, 12);
				PlotShapes(IIf(MC, shapeCircle, shapeNone), colorYellow, 0, H, 12);
			}
	
}

if(Status("action") == actionExplore)
	{
		SetOption("NoDefaultColumns", True);
		
	switch (Fltr)	
	{

	case "PinBar":
			Filter = PB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(PBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			break;

	case "InsideB":
			Filter = IB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(IBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "3IB":
			Filter = IIB;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(IIBTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "DoubleDoji":
			Filter = DblDJ;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(DblDJTxt + "Doji", "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "Doji":
			Filter = DJ;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(DJTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "PopGun":
			Filter = PopGun;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(PGTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "MasterCandle":
			Filter = MC;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn("Master Candle", "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;

	case "All":
			Filter = PB OR IB OR IIB OR DblDJ OR DJ OR PopGun OR MC;
			AddTextColumn(Name(), "SYMBOL", 77, colorDefault, colorDefault, 150);
			AddColumn(DateTime(), "DATE & TIME", formatDateTime, colorDefault, colorDefault, 200);
			AddColumn(C, "LAST CLOSE", 1.2);
			AddTextColumn(CdlTxt, "PATTERN", 77, colorDefault, colorDefault, 600);
			
			break;
	}
	}
_SECTION_END();

the issue is both of them plots diff .

also inside bar is a defined function in amibroker.

the second fuller's setup is met when the either of the two conditions are met

1) pin bar followed by inside bar

2) a pin bar which in itself is an inside bar


Many thanks to manju for putting in efforts


rgds


sumit

please help for above
 

Similar threads