Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Dynamic stop loss and target profit

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

    Dynamic stop loss and target profit

    Hello!
    I am building a strategy from a custom indicator. The indicator works fine. The strategy also, when:
    I have the target profit as well as the stop loss predefined like 10 ticks for example in “Inputs and variables”. In “Stops and targets”, I set the target and stop loss using inputs declared in “Inputs and variables”. The back test here is a success.

    Now I want to have my stop loss and target profit set dynamically, placing:
    the target profit for each entry X ticks above the signal bar for longs and X ticks below the signal bar for shorts and
    the stop loss one tick below the signal bar for longs and one tick above the signal bar for shorts.

    In “Do the following”, I have:

    HTML Code:
    EnterLong();
    ProfitTarget = (High[0] + (X*TickSize));
    StopLoss = (Low[0] - (1*TickSize));
    In “Stops and Targets” I have nothing.
    When I am backtesting, the analyser show the chart where I can realized that a trade terminates when another trade takes place. I am not able to see @Target Profit” like when it is static.
    I would really appreciate if anyone could advises how to fix this problem.

    Thanks!

    #2
    Hi Stan, thanks for posting. The stops and target section can not accept dynamic values from OnBarUdpate you will need to set up your stop and target using Exit orders within one of your sets. There is an example here:


    Kind regards,
    ​​​​​​​-ChrisL

    Comment


      #3
      Many thanks Chris L for your reply.

      I will dig deeper in and revert to you if I have another problem.

      Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      47 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      23 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      33 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X