Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Pointing at the wrong Bar

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

    Indicator Pointing at the wrong Bar

    Hi,
    I'm working on an indicator which should work in following way:
    When Low of the current bar break below Low of the previous bar. Indicator should point at the high of the previous bar.
    Unfortunatelly what happens it doesn't seem to work this way and an indicator is pointing above the high of the current bar instead of previous one.
    Could you explain why is that?
    Here is the code:

    Code:
    double high1 = High[1];
    double low1 = Low[1];
    
    if (low1 > Low[0])
    Values[0][0] = high1;
    I'm attaching screenshot of what I mean
    Attached Files

    #2
    Hello Ludwik,

    From the description that sounds like its correct.

    The logic you made checks if the low is greater than the current low and if so it plots on the current bar. If you are trying to plot on the high of the previous bar you need to use Values[0][1] to plot 1 bars ago.

    Keep in mind that plotting 1 BarsAgo like this will prevent any other script that uses this indicator as a signal from working, you would have to also plot on the current bar for it to be used as a signal. You could do
    Code:
    if (low1 > Low[0])
    {
    Values[0][1] = high1;
    Values[0][0] = high1;
    }
    That would point to the previous bar high but still plot on the current bar for a signal.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post

      Keep in mind that plotting 1 BarsAgo like this will prevent any other script that uses this indicator as a signal from working, you would have to also plot on the current bar for it to be used as a signal. You could do


      That would point to the previous bar high but still plot on the current bar for a signal.
      I'm not sure what you mean here?: Keep in mind that plotting 1 BarsAgo like this will prevent any other script that uses this indicator as a signal from working, you would have to also plot on the current bar for it to be used as a signal. You could do

      Comment


        #4
        Hello Ludwik,

        If you used this indicator as a signal for a strategy then you need to plot on the current bar. If the indicator is being used strictly for applying to the chart to look at then you can ignore that comment.

        JesseNinjaTrader Customer Service

        Comment


          #5
          I actually use it purely in the strategy. So could you please explain if possible
          Last edited by Ludwik; 03-14-2022, 11:01 AM.

          Comment


            #6
            Hello Ludwik,

            If you use a strategy then the signal would just be your overall condition, that comment only applies to indicators being used as a signal.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by algospoke, Yesterday, 06:40 PM
            2 responses
            19 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            45 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            20 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            180 views
            0 likes
            Last Post jeronymite  
            Working...
            X