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

Anchor Bar and detect short term momentum

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

    Anchor Bar and detect short term momentum

    Hi, I am new to Ninjatrader and also to C# programming. I have been trying to setup a concept and it requires some scripting to be done on Ninjatrader.

    I am looking to identify the anchor bar that has at least 2 lower lows or lower closes and similarly, 2 higher highs or higher closes.

    I need to store these details and then use them to identify whether there is a breakout. The bars need not be consecutive.

    Also, I need to add labels to these anchor bars as well.

    Is there a way to identify these and also to attach the labels. Thanks in advance.
    Last edited by prodigaltrader; 01-27-2021, 01:24 AM.

    #2
    Hello prodigaltrader,

    Thanks for your post and welcome to the NinjaTrader forums!

    Are you using the Strategy Builder or coding directly in Ninjascript?

    I'm not quite sure I understand your statement about the anchor bar relative to lower lows or higher highs. Are you asking about swing type patterns? Can you post a screenshot that illustrates what you are looking to do?

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi, Thanks for the quick response.
      As I said, I am new to Ninjatrader and I am trying to use Strategy Builder itself to essentially build my strategy.

      Basically, I am trying to implement the Dow Theory (https://www.investopedia.com/terms/d/dowtheory.asp) but with modifications.

      I am trying to identify the anchor bars (please see the pic - sph and spl) for implementing this and also trying to see if it can help me identify the breakouts.

      Thanks.
      Attached Files

      Comment


        #4
        Hello prodigaltrader,

        Thanks for your reply.

        There is a "Dow Theory" indicator in the NT user apps that you may be interested in. Unfortunately, it would not help you in a strategy as it does not present plots that could be read by the strategy.

        This indicator is publicly available on our NinjaTrader Ecosystem website:Here is a basic guideline of how to import NinjaScript add-ons in NinjaTrader 8:

        Note — To import NinjaScripts you will need the original .zip file.

        To Import:
        1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
        2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
        3. Select the downloaded .zip file
        4. NinjaTrader will then confirm if the import has been successful.
        Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

        Once installed, you may add the indicator to a chart by:
        • Right-click your chart > Indicators... > Select the Indicator from the 'Available' list on the left > Add > OK
        Here is a short video demonstration of the import process:The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.


        I would suggest looking at the "Swing" indicator in your platform as it will determine the swing points that seem to match up with what you want. The swing indicator will however not register a change in the swing high until the "strength" number of bars has passed (their highs must be less than the swing point!) the high point (which is what validates the swing high (or swing low). In the strategy builder, you can access the swing high value or the swing low value and check to see if the current price has exceeded one or the other. You may just want tto put the swing indicator on your chart and adjust the strength settings to see if that will work for you.

        Another approach, like the Dow Theory indicator does, would be to check to see if the current High is greater than the High of the last x period bars (or Low is less than the low that last x period bars) where x is the period you can define. You would use the MIN and MAX methods which are in the Strategy Builder under the Indicators folder.

        To label the bars of interest, through the strategy builder, under the do the following section in the drawing folder is the "text" function and you will need to supply the text to display along with the Y location (Price) at which to display as well as what 'bar ago" to display it on.

        Here are the educational resource available on the strategy builder:
        Free live webinar every other Thursday at 4:00 PM EST, through this link to all webinars: https://ninjatrader.com/PlatformTraining
        Previous recording of the Strategy Builder 301 webinar: https://youtu.be/HCyt90GAs9k?list=PL...auWXkWe0Nf&t=2
        Help guide for the strategy builder: https://ninjatrader.com/support/help...gy_builder.htm


        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi,
          Thanks for the response, I followed based on the advise mentioned in the discussion (https://ninjatrader.com/support/foru...swing-strategy)

          i followed the steps and tried to add the Down Arrow, but this arrow doesnt appear for the charts that i am looking at. Can you please help? Does it require 1 min data itself for showing the details, I have used the daily chart. code snippet as below:

          }
          else if (State == State.Configure)
          {
          }
          else if (State == State.DataLoaded)
          {
          Swing1 = Swing(Close, 5);
          }
          }

          protected override void OnBarUpdate()
          {
          if (BarsInProgress != 0)
          return;

          if (CurrentBars[0] < 2)
          return;

          // Set 1
          if ((Close[0] + (10 * TickSize)) < Swing1.SwingHigh[0])
          {
          Draw.ArrowDown(this, @"CheckStrategy Arrow down_2", true, 0, (High[0] + (5 * TickSize)) , Brushes.Red);
          Draw.Text(this, @"CheckStrategy Text_1", @"SPH", 0, (High[0] + (10 * TickSize)) );
          }
          Attached Files

          Comment


            #6
            Hello prodigaltrader,

            Thanks for your reply.

            The down arrow appears just above the 2nd candle from the right edge.

            If you would like to see all of the arrows, you will need to modify the "tag name" to make the tag name "unique" for each arrow. When the same tag name is used, the previous arrow with the same tag name would be removed first and the new one drawn. You can only have one draw object per tag name.

            Also, if you are using Daily bars, you will want to offset the candle more than 5 or 10 ticks, in order to keep it off the candle.

            Here is a short video that will help with creating unique tag names: https://paul-ninjatrader.tinytake.co...MF8xMTMwNTc0MA
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Waxavi, Today, 02:10 AM
            0 responses
            6 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by TradeForge, Today, 02:09 AM
            0 responses
            11 views
            0 likes
            Last Post TradeForge  
            Started by Waxavi, Today, 02:00 AM
            0 responses
            2 views
            0 likes
            Last Post Waxavi
            by Waxavi
             
            Started by elirion, Today, 01:36 AM
            0 responses
            4 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by gentlebenthebear, Today, 01:30 AM
            0 responses
            5 views
            0 likes
            Last Post gentlebenthebear  
            Working...
            X