Opening Range Breakout (ORB) - Intraday Trading System

Discussion in 'Day Trading' started by Cubt, Sep 23, 2013.

  1. Cubt

    Cubt Well-Known Member

    Joined:
    Mar 22, 2013
    Messages:
    1,002
    Likes Received:
    1,967
    Trophy Points:
    113
    Location:
    Chennai
    Yes, that's because of very small target of 10 Points in Nifty which is highly possible. 10 points a day would be fair enough if traded with more of no lots.

    Once i get the corrected afl from happy, will backtest it with 6 years of data and need to check max draw down. ifs its reasonable, will make this as my adds to my current system.
     
    adg123 and augubhai like this.
  2. jamit_05

    jamit_05 Well-Known Member

    Joined:
    Nov 11, 2005
    Messages:
    6,177
    Likes Received:
    7,746
    Trophy Points:
    113
    I suppose the success rate is 80% because profit is quickly taken. Say the profit is taken at 10 points... then around 3 points will go in expenses... this leaves us with 7 points in hand.

    This get further reduced because real time execution will be less efficient due to errors and slippages.
     
    anup, augubhai and Cubt like this.
  3. Cubt

    Cubt Well-Known Member

    Joined:
    Mar 22, 2013
    Messages:
    1,002
    Likes Received:
    1,967
    Trophy Points:
    113
    Location:
    Chennai
    Yeah, right. Just experimenting with 10 points, after the breakout there is a higher probability to make 10 to 15 points, if we have a target of 15 points, with slippage and commission we could reduce 5 points per trade which would result in 10 points profit.
     
    adg123 and augubhai like this.
  4. jamit_05

    jamit_05 Well-Known Member

    Joined:
    Nov 11, 2005
    Messages:
    6,177
    Likes Received:
    7,746
    Trophy Points:
    113
    I am sure you will leave no stone unturned in your research.

    Just a suggestion. Do not aim for a high Strike Rate. That approach mostly leads to dead ends. A SR of 50% or little higher is usually a sign of a very good system in the making.
     
    adg123 and Cubt like this.
  5. augubhai

    augubhai Well-Known Member

    Joined:
    Jan 10, 2006
    Messages:
    8,666
    Likes Received:
    8,636
    Trophy Points:
    113
    If the target is small, then is there a need to restrict the system to ORB? You could trade any breakout for that target.

    My aim while trading ORB was to capture the big move, without having to watch quotes all the time.

    But please do go ahead with your tests. You are sure to find something better :)
     
    jamit_05 and Happy_Singh like this.
  6. Cubt

    Cubt Well-Known Member

    Joined:
    Mar 22, 2013
    Messages:
    1,002
    Likes Received:
    1,967
    Trophy Points:
    113
    Location:
    Chennai
    Sure Amit. As am much comfortable with Super Trend system which has a SR of only 42% .

    am looking for another intraday based system to diversify my position, instead of adding few more lots to existing system i wanna try out with ORB intraday system for the following reasons.

    1.To avoid gap up/down
    2. No carry over/ No over night news impact.
    3. After all, I have the knowledge of ORB system, where without afl i can trade it with just charts.

    Just wanna experiment with 2 systems.

    One with Super Trend where irrespective of any news events/whatever, everything will be already factored in the charts. So i will be in the trade all the time.

    Anther one with ORB intraday system, where in case of false signals with Super Trend, i can compensate it by trading ORB system.(If 10 points target is achievable) with less draw down.
     
    adg123, whisky and augubhai like this.

  7. Happy_Singh

    Happy_Singh Well-Known Member

    Joined:
    May 27, 2013
    Messages:
    1,476
    Likes Received:
    3,773
    Trophy Points:
    113
    Location:
    Here & Now :)
    maybe just too good to be true :)


    Use the code i posted on Amibroker help thread i.e. 10 points target and 10 points stop

    Now we can see the 80% come down to 50-55% . . .


    but we will still test the SL of close on the other side of ORB . . .


    :) Happy
     
    kiran_thiru and augubhai like this.
  8. Happy_Singh

    Happy_Singh Well-Known Member

    Joined:
    May 27, 2013
    Messages:
    1,476
    Likes Received:
    3,773
    Trophy Points:
    113
    Location:
    Here & Now :)
    Looks like Augubhai has already coded for reversal/stop on first bar's breach

    check the following code . .

    ORBHSL = ORBH * (1-(SLPct/100));
    //ORBHSL = ORBL;
    ORBLSL = ORBL * (1+(SLPct/100));
    //ORBLSL = ORBH;

    just reversing the commented lines should change the SL . . .

    //ORBHSL = ORBH * (1-(SLPct/100));
    ORBHSL = ORBL;
    //ORBLSL = ORBL * (1+(SLPct/100));
    ORBLSL = ORBH;


    for profit target he is using % so for 15 points it will be 0,25%



    Code:
    function ParamOptimize( pname, defaultval, minv, maxv, step )
    {
    return Optimize( pname,
    Param( pname, defaultval, minv, maxv, step ),
    minv, maxv, step );
    }
    
    
    
    
    _SECTION_BEGIN("Augubhai's ORB System v1.1"); 
    
    //--Intraday time frame 
    TimeFrameSet(in5Minute); //If reseting, check formula for TimeFrameInMinutes 
    TimeFrameInMinutes = 5;
    
    //--Define all params 
    EntryBufferPct = ParamOptimize("Entry Buffer %", 0, 0, 2, 0.1);
    SLPct = ParamOptimize("SL %", 1.4, 0.1, 10, 0.1);
    TargetPct = ParamOptimize("Target %", 0, 0, 20, 0.5);
    MaxTarget = 100;
    TargetPct = IIf(TargetPct == 0, MaxTarget, TargetPct); 
    EntryTimeStart = ParamOptimize("Entry Time Start (Minutes)", 5, 5, 120, 5);
    EntryBarStart = floor(EntryTimeStart/TimeFrameInMinutes) - 1;
    EntryTimeEnd = ParamOptimize("Entry Time End (Minutes)", 25, 10, 180, 5);
    EntryBarEnd = floor(EntryTimeEnd/TimeFrameInMinutes) - 1;
    EntryBarEnd = IIf(EntryBarEnd < EntryBarStart, EntryBarStart, EntryBarEnd);  
    
    //--Plot Price Candle Chart
    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", colorBlack, styleNoTitle | GetPriceStyle() ); 
    
    //--New Day & Time. End Day & Time . End Day & Time is null till end of day 1  
    NewDay = (Day()!= Ref(Day(), -1)) OR BarIndex() == 0; 
    printf("\n NewDay  : " + NewDay ); 
    EndDay = (Day()!= Ref(Day(), 1)); 
    printf("\n EndDay  : " + EndDay );
    FirstBarTime = ValueWhen(NewDay,TimeNum(),1); 
    EndTime = ValueWhen(EndDay,TimeNum(),1);
    SquareOffTime = EndTime;
    
    //--Calculate ORB, and SL
    HighestOfDay = HighestSince(NewDay,H,1); 
    LowestOfDay = LowestSince(NewDay,L,1); 
    BarsSinceNewDay = BarsSince(NewDay);
    ORBH = ValueWhen(BarsSinceNewDay<=EntryBarStart,HighestOfDay ,1) * (1 + (EntryBufferPct/100)); 
    ORBL = ValueWhen(BarsSinceNewDay<=EntryBarStart,LowestOfDay ,1) * (1 - (EntryBufferPct/100)); 
    //ORBHSL = ORBH * (1-(SLPct/100)); 
    ORBHSL = ORBL; 
    //ORBLSL = ORBL * (1+(SLPct/100));
    ORBLSL = ORBH; 
    ORBHTarget = ORBH * (1+(TargetPct/100));
    ORBLTarget = ORBL * (1-(TargetPct/100));
    
    //--Find Buy, Sell, Short & Cover Signals
    BuySignal = (H >= ORBH) AND (BarsSinceNewDay  > EntryBarStart); 
    printf("\nBuySignal : " + BuySignal ); 
    ShortSignal = (L <= ORBL) AND (BarsSinceNewDay  > EntryBarStart) ; 
    printf("\nShortSignal  : " + ShortSignal ); 
    BarsSinceLastBuySignal = (BarsSince(Ref(BuySignal,-1)) + 1);
    BarsSinceLastShortSignal = (BarsSince(Ref(ShortSignal,-1)) + 1);
    BarsSinceLastEntrySignal = Min(BarsSinceLastBuySignal, BarsSinceLastShortSignal);
    BothEntrySignalsNull = IsNull(BarsSinceLastBuySignal) AND IsNull(BarsSinceLastShortSignal); //true for start of Day 1
    printf("\n\nBarsSinceNewDay : " + BarsSinceNewDay ); 
    printf("\n BarsSinceLastEntrySignal : " + BarsSinceLastEntrySignal); 
    Buy = (H >= ORBH) AND (BarsSinceNewDay  > EntryBarStart) AND (BarsSinceNewDay <= EntryBarEnd) AND ((BarsSinceNewDay < BarsSinceLastEntrySignal) OR BothEntrySignalsNull ); 
    Sell = (L <= ORBHSL) OR (H >= ORBHTarget) OR (TimeNum() > SquareOffTime-1) AND (BarsSinceNewDay > BarsSinceLastBuySignal); 
    Short = (L <= ORBL) AND (BarsSinceNewDay  > EntryBarStart) AND (BarsSinceNewDay <= EntryBarEnd) AND ((BarsSinceNewDay < BarsSinceLastEntrySignal) OR BothEntrySignalsNull ); 
    Cover = (H >= ORBLSL) OR (L <= ORBLTarget) OR (TimeNum() > SquareOffTime-1) AND (BarsSinceNewDay > BarsSinceLastShortSignal); 
    printf("\nBuy : " + Buy ); 
    printf("\nSell : " + Sell ); 
    printf("\nShort : " + Short ); 
    printf("\nCover : " + Cover ); 
    
    //--Handle if ORB broken both sides on same bar
    //--And remove duplicate Sell & Cover signals, since ExRem did not work as needed when Buy & Sell on same bar
    orbBothSides = IIf(Buy AND Short, 1, 0); 
    Buy = IIf(orbBothSides AND C <= O, 0, Buy); 
    Short = IIf(orbBothSides AND C > O, 0, Short); 
    Sell = IIf(orbBothSides AND C > O AND (L <= ORBHSL), 1, Sell); 
    Sell = IIf((BarsSince(Buy) < (BarsSince(Ref(Sell,-1))+1)) OR (BarsSince(Buy) AND IsNull(BarsSince(Ref(Sell,-1)))),Sell,0);
    Cover = IIf(orbBothSides AND C <= O AND (H >= ORBLSL), 1, Cover); 
    Cover = IIf((BarsSince(Short) < (BarsSince(Ref(Cover,-1))+1)) OR (BarsSince(Short) AND IsNull(BarsSince(Ref(Cover,-1)))),Cover,0);
    printf("\n\norbBothSides : " + orbBothSides); 
    printf("\nBuy : " + Buy ); 
    printf("\nSell : " + Sell ); 
    printf("\nShort : " + Short ); 
    printf("\nCover : " + Cover ); 
    
    //--Special Condition for 18 & 19 May 2009 for the Indian Market
    Buy =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Buy );
    Sell =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Sell );
    Short =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Short );
    Cover =IIf(DateNum()==1090518 OR (DateNum()==1090519 AND NewDay),0,Cover );
    
    //--Set prices
    BuyPrice = IIf(Buy, ORBH, Null); 
    SellPrice = IIf(Sell, IIf(H >= ORBHTarget, ORBHTarget, Max(ORBHSL, L)), Null); 
    ShortPrice = IIf(Short, ORBL, Null); 
    CoverPrice = IIf(Cover, IIf(L <= ORBLTarget, ORBLTarget, Min(ORBLSL, H)), Null); 
    
    //--Plot ORB, and SL 
    Plot(ORBHSL,"",colorRed,styleDashed); 
    Plot(ORBLSL,"",colorRed,styleDashed); 
    Plot(IIf(TargetPct == MaxTarget, Null, ORBHTarget),"",colorGreen,styleDashed);
    Plot(IIf(TargetPct == MaxTarget, Null, ORBLTarget),"",colorGreen,styleDashed);
    PlotOHLC( ORBL, ORBH, ORBL, ORBH, "", colorYellow, styleCloud); 
     
    //--Plot Signals
    shape1 = Buy * shapeUpArrow + Sell * shapeDownArrow; 
    PlotShapes( shape1, IIf( Buy, colorGreen, colorGreen), 0, IIf( Buy, Low, High ) ); 
    shape2 = Cover * shapeUpArrow + Short * shapeDownArrow; 
    PlotShapes( shape2, IIf( Cover, colorRed, colorRed), 0, IIf( Cover, Low, High ) ); 
    GraphXSpace = 5; 
    
    //--Restore time frame 
    TimeFrameRestore(); 
    _SECTION_END(); 
    [/QUOTE]


    Cheers


    :) Happy
     
    augubhai likes this.
  9. augubhai

    augubhai Well-Known Member

    Joined:
    Jan 10, 2006
    Messages:
    8,666
    Likes Received:
    8,636
    Trophy Points:
    113
    Sorry guys... it's a long time since i had written that code, and do not remember the scenarios that i had covered. Else, i would have let u know about it earlier.

    Just one warning - that afl is not perfect. It's buggy, and there are scenarios where it misbehaves. I remember that i had tried to add TSL to the code, but it did not work correctly. It might make sense to visually sample the results after u run the code.

    My original backtest of the ORB system was in perlscript, but I do not have that code now.... it might in some of my old computer backups, though. In those test, I had covered an extensive number of scenarios, including the one being discussed. The results for Nifty (as far as I remember) were:
    Best settings: Enter on ORB at the earliest (i had only 5 min data... so 5 min). No SL. Close at EOD (these were the most profitable parameters)
    Second Best: Enter ORB at the earliest. On entry update the other order with SL 0.6% from entry. Close EOD if SL not hit.
    Third Prize: Enter ORB at the earliest. On entry update the other order with SL 1.4% from entry. Close EOD if SL not hit.

    Data for the test was of 2007-08.
     
  10. Happy_Singh

    Happy_Singh Well-Known Member

    Joined:
    May 27, 2013
    Messages:
    1,476
    Likes Received:
    3,773
    Trophy Points:
    113
    Location:
    Here & Now :)
    Agree with most of your findings . . . .

    My conclusions after testing ORB thoroughly on a previous occasion were ..

    Fully Accept the uncertainty of the intraday moves and enjoy the fruits :D

    Case in Study: Last 2 days . . .

    Will just convert your code to accept points instead of % for profit and post it again . . .

    So that those who want to run the tests can do it :thumb:



    ;) Happy
     
    augubhai likes this.
Loading...

Share This Page