Long until target profit

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #10346 quote
    wolf
    Participant
    Junior

    Please help, I need it so when my code goes long, it stays long until a target profit is achieved. My code at the moment will go long but then will be overridden by a short whenever the terms for going short are met but this is wrong.

    Please help, thanks

    Picture of scenario: https://gyazo.com/31e89bfce217cd811ad21430e27a9404

    defparam preloadbars = 150
    defparam CUMULATEORDERS = false
    
    
    indicator1 = ExponentialAverage[20](close)
    indicator2 = ExponentialAverage[100](close)
    
    
    //buy condition
    cBuy = (high CROSSES OVER indicator1)
    
    //sell condition
    cSell = (indicator1 CROSSES over indicator2)
    
    //stop loss and take profit
    
    set target $profit 1000
    
    
    
    If cbuy then
    sellshort 11 perpoint at market
    endif
    
    If csell then
    exitshort at market
    endif
    
    if csell then
    buy 11 perpoint at market
    endif
    
    if cbuy then
    sell at market
    endif
    
    #10367 quote
    David
    Participant
    Veteran

    You should include the following:

    If NOT LONGONMARKET/SHORTONMARKET THEN…

    eg.

    If NOT LONGONMARKET AND cbuy then
    sellshort 11 perpoint at market
    endif
    
    And vice virsa for a long entry.
    
    This way they won't cancel each other out.
    #10495 quote
    Derek
    Participant
    Veteran

    In addition to dwgfx comment you can also run two different systems: one for short positions and one for long positions.

    This “costs” you an additional slot of your maximum number of trading Systems but you can also optimize both types of trades completely separate.

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

Long until target profit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
wolf @wolf Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/09/2016
Status: Active
Attachments: No files
Logo Logo
Loading...