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 kujista, Today, 06:23 AM
    4 responses
    14 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by traderqz, Yesterday, 09:06 AM
    2 responses
    16 views
    0 likes
    Last Post traderqz  
    Started by traderqz, Today, 12:06 AM
    3 responses
    6 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by RideMe, 04-07-2024, 04:54 PM
    5 responses
    28 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by f.saeidi, Today, 08:13 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X