• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 timcjpfx, Today, 06:22 AM
    2 responses
    16 views
    0 likes
    Last Post timcjpfx  
    Started by welson, Today, 08:26 AM
    2 responses
    12 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by brucerobinson, Today, 08:27 AM
    3 responses
    9 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by Leeroy_Jenkins, Today, 07:45 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by 1001111, 02-22-2020, 09:10 AM
    5 responses
    38 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X