Reputation: 43
I am new to amibroker , just purchased it the last month . I am trying to make a basic ORB 15min breakout . where we buy at high of 15min / short at low of 15mins (without waiting for the candle to close) and exiting the position at end of day . i.e 15:15:00 . Below is how much I could code it , but I seemed to have missed out something as its not giving me the right signals . also which ever buy.sell triggers first , is what is carried till the end of day .
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_N(Title = StrFormat("{{NAME}} | {{INTERVAL}} | {{DATE}} | {{VALUES}}" ));
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor( IIf( C>=O, colorLime, colorRed ) );
Plot( Close, "Price", IIf( C >= O, colorLime, colorRed ), styleCandle );
//plotting of 15min high and low
tn = TimeNum();
orb_st = tn == 091500;
orb_end = tn == 091500;
signalstart = tn == 093000;
signalend = tn == 151000;
signalsquareoff = tn == 151500;
myH = ValueWhen(orb_end , HighestSince(orb_st, H));
myL = ValueWhen(orb_end, LowestSince(orb_st,L));
Plot(myH,"ORBH",colorYellow,styleDots);
Plot(myL,"ORBL",colorWhite,styleDots);
// buy/sell signal on break of 15min high and low
Buy = Cross(H,myH) AND tn < 151500;
Short = Cross(myL,L) AND tn < 151500;
Sell = TimeNum() == signalsquareoff;
Cover = TimeNum() == signalsquareoff;
// removing repeated signals
Buy = ExRem(Buy,Short);
Short = ExRem(Short,Buy);
// Plot Buy and Sell Signal Arrows
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);
// backtesting param for points based results
SetPositionSize(1,spsShares);
would be awesome if someone could help me pointing out the mistake I have done in the above codes . just realized apart from the official amibroker forums , there arent any other proper resources where there are discussions happening where newbies like me can learn ..
thanks and regards. Fudge
Upvotes: 0
Views: 85
Reputation: 1
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_N(Title = StrFormat("{{NAME}} | {{INTERVAL}} | {{DATE}} | {{VALUES}}" ));
SetChartOptions(0,chartShowArrows|chartShowDates);
SetBarFillColor( IIf( C>=O, colorLime, colorRed ) );
Plot( Close, "Price", IIf( C >= O, colorLime, colorRed ), styleCandle );
newday=day()!=ref(day(),-1);///// new code
//plotting of 15min high and low
tn = TimeNum();
orb_st = tn == 091500;
orb_end = tn == 091500;
signalstart = tn == 093000;
signalend = tn == 151000;
signalsquareoff = tn == 151500;
myH = ValueWhen(orb_end , HighestSince(orb_st, H));
myL = ValueWhen(orb_end, LowestSince(orb_st,L));
Plot(myH,"ORBH",colorYellow,styleDots);
Plot(myL,"ORBL",colorWhite,styleDots);
// buy/sell signal on break of 15min high and low
Buy = Cross(H,myH) AND tn < 151500;
Short = Cross(myL,L) AND tn < 151500;
buy=buy and sum(buy,barssince(newday))+sum(short,barssince(newday))<=1; //newcode
short=short and sum(buy,barssince(newday))+sum(short,barssince(newday))<=1; //newcode
Sell = TimeNum() == signalsquareoff;
Cover = TimeNum() == signalsquareoff;
// removing repeated signals
Buy = ExRem(Buy,Short);
Short = ExRem(Short,Buy);
// Plot Buy and Sell Signal Arrows
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);
// backtesting param for points based results
SetPositionSize(1,spsShares);
try the above. I just added 3 lines of code.. where I commented new code at the end of those lines
Upvotes: 0