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

Help with Gap bar indicator

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

    Help with Gap bar indicator

    Hello,

    I am a recent NT customer. I am looking for some help creating a simple indicator in NT8.

    I was able to make the below into an alert, but I would like it as an indicator on the chart. I would appreciate if someone can throw a code snippet.

    BullGapBar:

    Place a dot on the candlestick 2 bars ago if all the 4 conditions below are true:

    Close (3 bars ago) >= Open (3 bars ago)
    Close (2 bars ago) >= Open (2 bars ago)
    Close (1 bar ago) >= Open (1 bars ago)
    Low (1 bar ago) > High (3 bars ago)

    And similarly for the bear case:

    BearGapBar:

    Place a dot on the candlestick 2 bars ago if all the 4 conditions below are true:

    Close (3 bars ago) <= Open (3 bars ago)
    Close (2 bars ago) <= Open (2 bars ago)
    Close (1 bar ago) <= Open (1 bars ago)
    High(1 bar ago) < Low (3 bars ago)

    Thanks.

    #2
    Hello hchandrashe,

    Thanks for your post.

    So a code snippet for the bull case:

    if (Close[3] >= Open[3] &&
    Close[2] >= Open[2] &&
    Close[1] >= Open[1] &&
    Low[1] >= High[3]
    {
    Draw.Dot (this, "tag"+CurrentBar, true, 0, Low[2], Brushes.Orange);
    }

    From that you should be able to build the bear code.

    Here is the helpguide link for the Draw.Dot: http://ninjatrader.com/support/helpG.../?draw_dot.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks. I tried it and it doesn't do anything.

      Even having the statement without the condition doesn't do anything to the chart. I have a simple 5 min candlestick chart.

      Draw.Dot (this, "tag"+CurrentBar, true, 0, Low[2], Brushes.Orange);

      I have a feeling I am missing some display related setting.

      Comment


        #4
        You'll need to make sure that your chart has at least 3 bars, since your lookback requires that many:
        Code:
        if (CurrentBar > 2)
        { 
            // your code here
        }

        Comment


          #5
          Hello hchandrashe,

          tradesmart is correct here. You can find more details at the following link: http://ninjatrader.com/support/forum...ead.php?t=3170

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          4 responses
          21 views
          0 likes
          Last Post alifarahani  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by PhillT, Today, 02:16 PM
          2 responses
          7 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by Kaledus, Today, 01:29 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frankthearm, Yesterday, 09:08 AM
          14 responses
          47 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Working...
          X