Create code for a breakout system

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #42858 quote
    DT
    Participant
    New

    Hello,

    I would need some help to create the code for a breakout system. If I would like to go long/short the cable after it have created a 2h-range between 8-10 in the morning and then exit 24 hours later.
    Stoploss and entry in the other direction should be at the same level.

    I´m learning how to code right now but are not good enough to create this yet…Would be really happy if anyone could help!

    Thanks!

    #43040 quote
    Wing
    Participant
    Veteran

    Assuming for example you use the 15m timeframe, something like this?

    defparam cumulateorders=0
    
    once RangeHigh=10000000
    once RangeLow=0
    
    If time=100000 then
    RangeHigh=Highest[8](high)
    RangeLow=Lowest[8](low)
    endif
    
    If Time=PositionTime then
    sell at market
    exitshort at market
    endif
    
    if time>100000
    if close>RangeHigh and onmarket=0 then
    buy 1 lot at market
    PositionTime=Time
    set stop loss close-rangelow
    endif
    if close<RangeLow and onmarket=0 then
    sellshort 1 lot at market
    set stop loss rangehigh-close
    PositionTime=Time
    endif
    endif
    
    
    
    Nicolas and DanInvest thanked this post
    #43169 quote
    Nicolas
    Keymaster
    Master

    Thank you Wing for your invaluable help in answering the requests of the forum members, it helps me enormously and I am very grateful to you. You deserve the blue badge of ‘best contributor’ 🙂

    Wing thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Create code for a breakout system


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DT @finlab Participant
Summary

This topic contains 2 replies,
has 3 voices, and was last updated by Nicolas
8 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/10/2017
Status: Active
Attachments: No files
Logo Logo
Loading...