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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    85 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    48 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    67 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X