Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

perform action X bars into trade?

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

    perform action X bars into trade?

    Hi guys I've got an idea to have ninja trader perform an action like create a profit target X number of bars into an active trade, or maybe when a volatility threshold has been met. I already know how to label each trade with an individual name ... But would I use something like a Savedbar variable plus (another variable) = currentbar ? to accomplish that? Like for example a trade has been entered / then once the bollinger band width threshold has reached a specific number / a profit target in the correct direction is placed as a limit order at the correct price.
    Another potential variable that might be called instead of the Bollinger Band width might for example also be the 23rd percentile of something like a Fibonacci retracement ladder.

    Really asking as a "trade in progress" now how do we get ninja trader to do stuff specific to the ongoing calculations and dynamics of the current chart numbers, question. IE call that Bollinger band width indicator, or draw that fibonacci retracement accurately. and actually work with it right.

    I hope this isn't confusing. I also hope this isn't beyond the scope of NT or C#'s capacities for automation.

    #2
    Hello Daryl Haaland,

    Thanks for your post.

    I'm not certain I am following all of the variations but in general, in Ninjascript/C# you can do just about anything.

    If I understand correctly, you enter a position and have an initial stop/profit target and after X number of bars you want to adjust the profit or stop to some other level.

    If you are using the set methods (SetStopLoss or SetProfitTarget) you can certainly dynamically change them.

    for example:

    if (your conditions to enter)
    {
    SetStopLoss(CalculationMode.Ticks, 10);
    SetProfitTarget(CalculationMode.Ticks, 10);
    // entry order
    }

    if (BarsSinceEntryExecution() >= 3)
    {
    SetProfitTarget (CalculationMode.Price, Bollinger(2, 14).Upper[0]); // set new profit target
    }

    I left out signal names and you would want to tie them together that way.

    Comment


      #3
      Good you got most f the gist of what I was getting at. I'd want to add a profit target to the conditions and leave the stop conditions alone that were established at the time of entry. I kinda figured that what you outlined here was what was needed, now to just hammer out the exact details.

      Thanks!!

      Originally posted by NinjaTrader_Paul View Post
      Hello Daryl Haaland,

      Thanks for your post.

      I'm not certain I am following all of the variations but in general, in Ninjascript/C# you can do just about anything.

      If I understand correctly, you enter a position and have an initial stop/profit target and after X number of bars you want to adjust the profit or stop to some other level.

      If you are using the set methods (SetStopLoss or SetProfitTarget) you can certainly dynamically change them.

      for example:

      if (your conditions to enter)
      {
      SetStopLoss(CalculationMode.Ticks, 10);
      SetProfitTarget(CalculationMode.Ticks, 10);
      // entry order
      }

      if (BarsSinceEntryExecution() >= 3)
      {
      SetProfitTarget (CalculationMode.Price, Bollinger(2, 14).Upper[0]); // set new profit target
      }

      I left out signal names and you would want to tie them together that way.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      56 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      133 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      73 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      45 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      49 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X