Skip to main content

Camarilla Pivot as Trailing Stop Loss for Amibroker (AFL)

thangnd.1211 almost 9 years ago Amibroker (AFL)

  • Rating:
    2 / 5 (Votes 4)
  • Tags:
    stop loss, amibroker

Here is an interesting trading system i would like to share. Generally people use Camarilla as Pivot Point levels for their intraday trading. How about using Camarilla Pivot as Trailing Stop for positional trading. We build this interesting trading system (Prototype) using the concept limit order backtesting. It is a simple long/short breakout trading system with no optimization variables.

The Buy/Sell rules are shown below

1)Measure Reference High for Buy Signal – i.e High when the Candle Closes above Camarilla Pivot.
2)Buy on Intraday any time if the price crosses Reference High on Intraday basis

1)Measure Reference Low for Short Signal – i.e Low when the Candle Closes below Camarilla Pivot.
2)Short on Intraday any time if the price crosses Reference low on Intraday basis

Screenshots

Indicator / Formula

Copy & Paste Friendly
//Coded by Rajandran R
//Website - www.marketcalls.in
//Date - 15-Nov-2015


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

_SECTION_BEGIN("Camarilla Pivot as Trailing Stop");


SetPositionSize(150,spsShares);

//---- pivot points
DayH = TimeFrameGetPrice("H", inDaily, -1);		// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1);		//				low
DayC = TimeFrameGetPrice("C", inDaily, -1);		//				close
DayO = TimeFrameGetPrice("O", inDaily);			// current day open

// camarilla pivots
if ( True )
{
R = DayH - DayL;	  // range
PP = (DayH + DayL + DayO + DayO) / 4 ;
R4 = (R * 1.1/2)+DayC;
R3 = (R * 1.1/4)+DayC;
S3 = DayC-(R * 1.1/4);
S4 = DayC- (R * 1.1/2);
}

Plot(PP, "",colorYellow,styleLine);

Buysignal = Cross(C,PP);
Shortsignal = Cross(PP,C);

ibsignal = Flip(buysignal,shortsignal); // Flip can be used for holding contion true till the time the other condition true
issignal = Flip(shortsignal,buysignal);


buysignal = ExRem( buysignal, shortsignal );

Buy = Ref(buysignal,-1);
Short = Ref(Shortsignal,-1);


BuyLimitPrice = ValueWhen(BuySignal, H);
ShortLimitPrice = ValueWhen(shortsignal,L);

Buy = ibsignal and H>buylimitprice;
Short = issignal and L<shortlimitprice;


ibuy = Flip(Buy,Short);
isell = Flip(Short,Buy);

sellsignal = Cross(PP,C) AND ibuy;
coversignal = Cross(C,PP) AND isell;

Sell = Ref(sellsignal,-1);
Cover = Ref(coversignal,-1);

SellLimitPrice = ValueWhen(Cross(PP,C),L);
CoverLimitPrice = valuewhen(Cross(C,PP),H);



Sell = ibuy AND L<SellLimitPrice;
Cover = isell AND H>coverLimitPrice;



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

Sell = ExRem(Sell,Cover);
Cover = ExRem(Cover,Sell);




PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);                      
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); 
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);                      
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);



_SECTION_END();

1 comments

Leave Comment

Please login here to leave a comment.