Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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
    Chris L.NinjaTrader Customer Service

    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 RDTrader16, Today, 10:19 PM
      0 responses
      1 view
      0 likes
      Last Post RDTrader16  
      Started by gemify, 03-08-2023, 08:02 AM
      9 responses
      148 views
      0 likes
      Last Post culpepper  
      Started by elirion, Today, 10:03 PM
      0 responses
      1 view
      0 likes
      Last Post elirion
      by elirion
       
      Started by RaddiFX, Today, 09:55 PM
      0 responses
      6 views
      0 likes
      Last Post RaddiFX
      by RaddiFX
       
      Started by Trader146, 03-29-2024, 01:22 PM
      4 responses
      25 views
      0 likes
      Last Post Trader146  
      Working...
      X