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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            71 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            143 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            76 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            47 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            51 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X