Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Variables for take profit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using Variables for take profit

    Hi traders,
    I am running an automated strategy and I can't set the take profit as a variable.
    I need to set the profit target as the Pivot S2 for shorts or Pivot R2 for longs. In order to do so, I use two variables as Image1 shows.

    Then I define Profit Targets as the variables (price). image2


    The following error shows up and no Profit Target is placed. image3

    I thought that variables were bad defined, but as proof of the variable value I am able to plot them. so I think what I am doing wrong is in the definition of the Profit Target

    Please Help!! thanks a lot!
    Attached Files

    #2
    Hello jordavila,

    SetStopLoss and SetProfitTarget are only set once in the script in Initialize(). The Initialize() is run before any conditions (and actions) are checked.

    It is not possible to calculate values in the conditions to be used for the SetStopLoss or SetProfitTarget using the Strategy Wizard due to this.

    You can, however, unlock the script, calculate these values, and then call SetStopLoss and SetProfitTarget again using the calculated values within OnBarUpdate.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by selu72, Today, 02:01 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Started by WHICKED, Today, 02:02 PM
    2 responses
    11 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by f.saeidi, Today, 12:14 PM
    8 responses
    21 views
    0 likes
    Last Post f.saeidi  
    Started by Mikey_, 03-23-2024, 05:59 PM
    3 responses
    51 views
    0 likes
    Last Post Sam2515
    by Sam2515
     
    Started by Russ Moreland, Today, 12:54 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Erick  
    Working...
    X