Opening only opposite direction after taking profit

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #139445 quote
    Francesco
    Participant
    Veteran

    Hi guys, i would like to know how it’s possible to open positions only in the opposite direction after a profit target.

    For example, i am long on market and the position close after hitting an x profit target. I want that the next position opened is only a short one excluding every long signal.

    How can i do this? Thanks.

    #139446 quote
    robertogozzi
    Moderator
    Master

    Try this one:

    Defparam CumulateOrders = false
    Once TradeLong  = 1
    Once TradeShort = 1
    If StrategyProfit > StrategyProfit[1] Then
       If LongOnMarket[1] Then
          TradeLong  = 0
          TradeShort = 1
       Else
          TradeLong  = 1
          TradeShort = 0
       Endif
    Endif
    If MyLongConditions and Not OnMarket and TradeLong Then
       BUY ....
    Endif
    If MyShortConditions and Not OnMarket and TradeShort Then
       SELLSHORT ....
    Endif
    Francesco thanked this post
    #139461 quote
    Francesco
    Participant
    Veteran

    It works but refers to the strategyprofit, so it doesn’t open more then 1 position per day.

    I want it to react to the reaching of the target profit level.

    Is that possible?

    #139462 quote
    robertogozzi
    Moderator
    Master

    STRATEGYPROFIT has nothing to do with days, it is updated as soon as any trade closes, if 10 trades a day close, then 10 times a day it is updated.

    #139464 quote
    Francesco
    Participant
    Veteran

    I managed to fix by editing these lines

    If LongOnMarket Then
    set target %profit 0.3
    TradeLong  = 0
    TradeShort = 1
    Endif
    
    If ShortOnMarket Then
    set target %profit 0.3
    TradeLong  = 1
    TradeShort = 0
    Endif

    in order to have it also for both directions

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

Opening only opposite direction after taking profit


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Francesco
5 years, 7 months ago.

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