Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Variable profit target and stop loss

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

    Variable profit target and stop loss

    I am trying to set a variable profit target and stop loss from an indicator. Under conditions and actions I have an action to set profit target, set stop loss, enter long position (signal name Entry) and also print the values for pt an sl. Under "stops and target I have it set to these variables from signal "entry" but it keeps exiting immediately after 1 tick and not the correct value.

    #2

    Comment


      #3
      Hello, thanks for writing in.

      You can not use Indicator variables in the Stops and Target section of the builder because they are defined before the script loads any data. You would need to set up the stop and target as one of your sets. We have an example that demonstrates a dynamic stop loss here for reference:



      Kind regards,

      -ChrisL

      Comment


        #4
        Originally posted by NinjaTrader_ChrisL View Post
        Hello, thanks for writing in.

        You can not use Indicator variables in the Stops and Target section of the builder because they are defined before the script loads any data. You would need to set up the stop and target as one of your sets. We have an example that demonstrates a dynamic stop loss here for reference:



        Kind regards,

        -ChrisL
        Hey Chris, I am still having issues with setting the profit target. I made a condition to exit if my unrealized gains (ticks) is greater than the variable. It seemed to work in the strategy analyzer bit when I run in market replay it immediately exits after 1 tick. I have the variable printing the value every bar so I know the variable is correct

        Comment


          #5
          Hello, thanks for the follow up. The script needs to submit the order (assuming you are using an Exit order) on every bar to keep it alive. The example I posted is the best reference for a script that works correctly out of the box, please use this as a reference to any custom scripts that are trying to do the same thing.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, 03-13-2026, 05:17 AM
          0 responses
          86 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          151 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          79 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          53 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          61 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X