Opening only opposite direction after taking profit

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #139445 quote
    FrancescoFrancesco
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    FrancescoFrancesco
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    FrancescoFrancesco
    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.
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

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 FrancescoFrancesco
6 years, 2 months ago.

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