• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

      http://screencast.com/t/Jp6xvZ88W

      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 danitralla, Yesterday, 03:33 AM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_ShawnB  
          Started by ninjo, Yesterday, 11:54 AM
          0 responses
          6 views
          0 likes
          Last Post ninjo
          by ninjo
           
          Started by deblanka, Yesterday, 08:56 AM
          0 responses
          13 views
          0 likes
          Last Post deblanka  
          Started by Boonfly8, 03-22-2019, 12:30 PM
          7 responses
          24 views
          0 likes
          Last Post sledge
          by sledge
           
          Started by Sohal, Yesterday, 05:02 AM
          2 responses
          23 views
          0 likes
          Last Post techmint  
          Working...
          X