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

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.
    Paul H.NinjaTrader Customer Service

    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 elderan, Today, 08:03 PM
      0 responses
      2 views
      0 likes
      Last Post elderan
      by elderan
       
      Started by algospoke, Today, 06:40 PM
      0 responses
      10 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      9 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      7 views
      0 likes
      Last Post quantismo  
      Started by AttiM, 02-14-2024, 05:20 PM
      8 responses
      169 views
      0 likes
      Last Post jeronymite  
      Working...
      X