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

Automatic Horizontal Line that plots open and close of candle

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

    Automatic Horizontal Line that plots open and close of candle

    Hello all,

    I am a long time lurker but finally came to a problem I couldn't solve just by lurking.

    I am in need of an indicator that plots a horizontal line on both the open and close of a candle that is changing trend. So basically, if a down candle has printed after printing many up candles, then draw then plot the horizontal line at the open and close prices, same for the opposite direction. The lines should disappear if a new direction is formed. I tried to use N bars up/down but couldnt get it to work. Let me know if anyone has any code/ideas!
    Attached is a picture of how I would want the lines plotted.
    Thanks

    #2
    Hello mattmill4,

    Thanks for your post, and welcome to the NinjaTrader forum.

    The following snippet will draw a signal on down bars after N amount of up bars:

    private int NBarUp = 4;
    protected override void OnBarUpdate()
    {
    if(CurrentBar < NBarUp)
    {
    return;
    }

    if(Close[0] < Open[0])
    {
    double value = NBarsUp(3, true, false, false)[1];
    if(value == 1)
    {
    Draw.Dot(this, "LowBar"+CurrentBar, false, 0, High[0]+TickSize*2, Brushes.Red);
    }
    }
    }
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response. Is there any way to do this on the candle close direction though? I am trying to draw on the first opposite direction candle which cant really be counted.

      Originally posted by NinjaTrader_ChrisL View Post
      Hello mattmill4,

      Thanks for your post, and welcome to the NinjaTrader forum.

      The following snippet will draw a signal on down bars after N amount of up bars:

      private int NBarUp = 4;
      protected override void OnBarUpdate()
      {
      if(CurrentBar < NBarUp)
      {
      return;
      }

      if(Close[0] < Open[0])
      {
      double value = NBarsUp(3, true, false, false)[1];
      if(value == 1)
      {
      Draw.Dot(this, "LowBar"+CurrentBar, false, 0, High[0]+TickSize*2, Brushes.Red);
      }
      }
      }

      Comment


        #4
        Even just help with a single horizontal line that plots the closing price of the first opposite colored candle.

        Comment


          #5
          Hi mattmill4, thanks for your reply.

          The code I posted will only signal on reversal bars. If this is not a solution, could you please post a screenshot of your chart describing the condition?

          I look forward to hearing of your results.
          Chris L.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          435 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          3 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          18 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by frslvr, 04-11-2024, 07:26 AM
          9 responses
          126 views
          1 like
          Last Post caryc123  
          Started by selu72, Today, 02:01 PM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_Zachary  
          Working...
          X