Simple open breakout automated strategy

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #72328 quote
    julien1978
    Participant
    Average

    Hello all,

    I have spent time looking for a breakout strategy on the website but I could not find exactly what I have in my mind.

    Could someone help me programming an “open range breakout” automated strategy? I would really appreciate any help. It would be based on a custom range indicator that I have made with the great help of Nicolas (cf. code of the indicator below). So it should not take too long to write the code I guess!

    Rules are as follows:

    Time frame 1H

    The indicator already defines the parameters for:
    – the range = the highest and lowest point of a timeperiod (for example low and high from 5 am to 8 am) +/-5 pips (for example). So the top of the range is high + 5 pips, the bottom of the range is low – 5 pips
    – the profit targets = 50% of the range size, 100% of the range and 150% of the range

    Trades are initiated at the end of the timeperiod range (start at 8 am in this example) and no trade should be taken after 10 pm. Positions are closed at midgnight.

    From 8 am, if the price moves above the top of the range, a buy order is set. If the price moves below the bottom of the range, then a sell order is set. 2 positions cannot be set at the same time. If the first position is a winner, then no further position should be initiated for the day. However, if the first position fails, then another order can be set (if the price reverses its direction for instance), with the limit of 2 orders in total per day.

    => Is there a way to make proorder trigger the buy/sell order just when the price hits the top/bottom of the range, and not after the close of the candle ? I understand that proorder must wait for the close of a candle in which the condition is met in order to set the order. Can this be bypassed? Since the timeframe is 1 hour, it would be too long to wait for a close of the candle!

    Stop loss is either at the bottom of the range (for long position) or the top of the range (for short), as described previously (high or low +/- 5 pips). If the total size of the opening range is more than 50 pips, then no position is initiated for the day.

    3 contracts per position: take profit is in 3 steps as follows:
    – when the price reaches the first target (50% of the range size), 1 contract is sold,
    – when the price reaches the second target (100% of the range size), 1 other contract is sold and stop loss is moved to breakeven
    – then the third contract is sold if the price reaches the third target (150% of the range)

    => I am not sure if it is possible to partially close a position. If not, then the take profit is equal to the range size (target 2).

    Thanks in advance to those who will answer me. The coding of this strategy will also allow me to backtest different parameters.

    once hh=undefined
    once ll=undefined
    once hh1=undefined
    once ll1=undefined
    once hh2=undefined
    once ll2=undefined
    once hh3=undefined
    once ll3=undefined
     
    starttime = 050000
    endtime = 080000
     
    if intradaybarindex=0 then
    hh = 0
    ll = 0
    alreadydrawn = 0
    endif
     
    if time=starttime then
    startbar=barindex
    endif
     
    if time=endtime then
    endbar=barindex
    endif
     
    if time>=starttime and time<=endtime then
    if high + 5*pipsize>hh then
    hh = high + 5*pipsize
    endif
    if low - 5*pipsize<ll or ll=0 then
    ll = low - 5*pipsize
    endif
     
    lerange=(hh-ll)/2
    else
    hh=hh
    ll=ll
    hh1=hh+lerange
    ll1=ll-lerange
    hh2=hh+2*lerange
    ll2=ll-2*lerange
    hh3=hh+3*lerange
    ll3=ll-3*lerange
    endif
     
    if time>endtime and alreadydrawn=0 then
    drawrectangle(startbar,hh,endbar,ll)
    alreadydrawn=1
    endif
     
    return hh as "Maxi période de cotation", ll as "Mini période de cotation", hh1 as "Maxi1" ,ll1 as "Mini1",hh2 as "Maxi2" ,ll2 as "Mini2",hh3 as "Maxi3" ,ll3 as "Mini3"
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Simple open breakout automated strategy


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
julien1978 @julien1978 Participant
Summary

This topic contains 1 voice and has 0 replies.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/05/2018
Status: Active
Attachments: No files
Logo Logo
Loading...