Time limit for an order

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #25620 quote
    BarneyBarney
    Participant
    Senior

    Want to have a time limit how long a position may be open.

    How does such a code look like?

     

    Barney

    #25624 quote
    WingWing
    Participant
    Veteran
    once Counter=0
    
    counter=counter+1
    
    If counter>10 then
    sell at market
    endif
    
    if buyconditions=true then
    buy 1 lot at market
    counter=0
    endif
    

    ’10’ in this case is the amount of bars that the trade will stay open.

    #25625 quote
    BarneyBarney
    Participant
    Senior

    “Error in line 9 character  18

    Please complete the syntax of the line”

    When i past your code.

    Perhaps i paste the code in wrong place?

    Here is my code!

    OMX30 15 min and 0,5p spread.

    It don’t work good in downtrend, therefore i must have something that stops algon in long term downtrend.

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    
    indicator1 = Average[80](close)
    indicator2 = Average[5](close)
    c1 = (indicator1 CROSSES UNDER indicator2)
    
    IF c1 THEN
    BUY 2 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET TARGET pPROFIT 3
    #25628 quote
    WingWing
    Participant
    Veteran

    The last four lines of my code represent your own buy conditions, so you need to put this right after you buy the contracts.

    counter=0
    #25646 quote
    BarneyBarney
    Participant
    Senior

    I have to be sluggish in the head.

    Can you post the code where it should be. 🙂

    I am new to coding…

    #25665 quote
    WingWing
    Participant
    Veteran
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    once counter=0
    counter=counter+1
    
    if counter>10 then
    sell at market
    endif
    
    // Conditions to enter long positions
    
    indicator1 = Average[80](close)
    indicator2 = Average[5](close)
    c1 = (indicator1 CROSSES UNDER indicator2)
    
    IF c1 THEN
    BUY 2 CONTRACT AT MARKET
    counter=0
    ENDIF
    
    // Stops and targets
    SET TARGET pPROFIT 3

    Does that work?

    #25784 quote
    BarneyBarney
    Participant
    Senior

    Yes, it works fine.

    But my system did not like it.

    It works well but in downtrend it don’t work so good.

    What can i do to fix my problem…….

    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    
    // Conditions to enter long positions
    
    indicator1 = Average[80](close)
    indicator2 = Average[5](close)
    c1 = (indicator1 CROSSES UNDER indicator2)
    
    IF c1 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // Stops and targets
    SET TARGET pPROFIT 3
    
    omx-30-min.jpg omx-30-min.jpg
    #25975 quote
    WingWing
    Participant
    Veteran

    A stop loss maybe? Seeing as you have a a very low take profit, on relatively high time frame, make sure your system does not trick you because of the ‘zero bar issue’ though.

Viewing 8 posts - 1 through 8 (of 8 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

Time limit for an order


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Barney @rickardktm Participant
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by WingWing
9 years, 7 months ago.

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