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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          88 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          134 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          119 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          69 views
          0 likes
          Last Post PaulMohn  
          Working...
          X