Adding to Open

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37879 quote
    johnmensinkjohnmensink
    Participant
    New

    I am trying to create a simple system that takes the Open price and adds 28 points to it.
    This far I can’t seem to get it working right. If I backtest it, the graph shows it always buys on the Open price + 0.5 (half the spread on DAX)
    So I think the 28 is left out of the formula.
    I have tried multiple things, with all the same result:

    c1 = open + 28
    c1 = high > (open+28)
    c1 = open + 0.028
    c1 = (open => 28)

    The complete code:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    // Conditions to enter long positions
    c1 = (open + 28)
    
    IF c1 AND not daysForbiddenEntry THEN
    BUY 1 PERPOINT AT MARKET
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 70
    SET TARGET pPROFIT 9
    #37900 quote
    NicolasNicolas
    Keymaster
    Legend

    Because the code is only read once per bar at its Close, the program will never met your c1 condition. In order to put a pending order on market (a conditional order) you’ll have to use a STOP or a LIMIT one. In your case, because you want to buy at an higher price than the actual one, you should use STOP order, like this:

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Prevents the system from placing new orders on specified days of the week
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    
    IF not daysForbiddenEntry THEN
    BUY 1 PERPOINT AT close+28*pointsize STOP
    ENDIF
    
    // Stops and targets
    SET STOP pLOSS 70
    SET TARGET pPROFIT 9

    The stop order will remain active only 1 bar. I use Close instead of Open, because it will put the order at current Close level (+28 points) of the candlestick (when the code is read) and at the next bar open. Hope it’s clear 😀

    #37901 quote
    johnmensinkjohnmensink
    Participant
    New

    Thank you Nicolas, that helps a lot!
    I can work with this.

    If I use this code, will there be a conditional order added to my ‘working orders’ on IG?
    Or will it only be visible on ProReal. (ProReal makes a market deal once the parameters are met)

    #37903 quote
    NicolasNicolas
    Keymaster
    Legend

    The pending orders will be of course visible in your broker orders list, just like any other ones 🙂

    #37905 quote
    johnmensinkjohnmensink
    Participant
    New

    I was hoping I could skip the margin withdrawal 🙂 (other brokers do not take margin for pending orders)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Adding to Open


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by johnmensinkjohnmensink
9 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/09/2017
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...