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

Simple Inside Bar Plotting Problem

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

    Simple Inside Bar Plotting Problem

    Okay, I've Attached the Indicator. It's a Super Simple Inside Bar. and I want to be able to

    1. Plot Lines at the High and Low of Inside

    2. Keep Plotting the Lines until A Bar Closes Outside of any of the Lines.


    I just don't know how to do this. I tried everything, but I don't even get a Plot of lines.

    Help with some Code Please!!!
    Attached Files

    #2
    Hello ginx10k,

    Thanks for your post.

    Can you mark up a chart with what your expected indicator output would look like? This will help us to determine the best resources to help you accomplish your goals. For example deciding to use a drawline verse a plot, etc.

    I look forward to your reply.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Picture

      Okay this is what the Output should look like.

      Comment


        #4
        Hello ginx10k,

        Thanks for your post and picture.

        In review of your code there are a few changes to make that will help you get the desired results.

        What is needed is a way to extend the lines for each bar as the bars progress until a bar closes above the line. To do that you need to save the bar number of the prior bar to the inside bar (where the lines are drawn from). First we need to create an integer variable to use. In the variable declaration section, under #region Variables, add:
        Code:
         private int iBar = 0 ;
        iBar will be the integer variable that we will put the prior to inside bar number.


        In your code section that detects the inside bar condition: if(High[0] < High[1] && Low[0] > Low[1]) Below that, within the "{ }" add:
        Code:
        iBar = CurrentBar - 1 ;  // Save the prior bar number
        Now that we have the bar number we can always use that to get the high and low of that particular bar.


        In this line of your existing code:
        Code:
         insideHigh = DrawLine("Resistance", false, 1, High[1], 0, High[0], Color.Red, DashStyle.Solid, 3 );
        It currently draws a short line from the High of the previous bar to the high of the current bar which would usually be smaller given that it would be an inside bar.

        If you change the line to this:
        Code:
         insideHigh = DrawLine("Resistance", false, CurrentBar-iBar, High[CurrentBar-iBar], -1, High[CurrentBar-iBar], Color.Red, DashStyle.Solid, 3 );
        It will draw a horizontal line from the high of the previous bar to the current bar. We use the "CurrentBar-ibar" to get the reference bar. We use the "-1" to draw in advance to the current forming bar. We use the High(CurrentBar-iBar) to retrieve the high of the reference bar.


        Your code for line detection:
        Code:
         if(inside && Close[0] > insideHigh.StartY)
        works great, no changes needed.


        To complete your code, you need only duplicate these efforts for the Low. You will use the very same iBar.


        Please let me know if I can be of further assistance.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Just what I was looking for

          Hello Paul, your reply to this question back in 2014 was just what I was looking for. I had to put the brain into low range/4 wheel drive to get through the forest of my mind, to get it to work in my particular case, but the outcome was SUCCESS.
          Thank you from oldhiker.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by kmunroe478, Yesterday, 05:39 PM
          2 responses
          14 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by kevinenergy, 02-17-2023, 12:42 PM
          115 responses
          2,699 views
          1 like
          Last Post kevinenergy  
          Started by prdecast, Today, 06:07 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Christopher_R, Today, 12:29 AM
          1 response
          14 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by chartchart, 05-19-2021, 04:14 PM
          3 responses
          577 views
          1 like
          Last Post NinjaTrader_Gaby  
          Working...
          X