Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Feedback on PVP indicator...

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

    Feedback on PVP indicator...

    Hi,

    I tried both of the scripts below. Neither of them worked unfortunately. The scripts produced a blank screen. Any suggestions... I want the indicator to give me the closing price for the bar that is 20 bars before / ahead of the Maximum volume bar for that session. Thanks...

    if (CurrentBar < 20)return;
    double MaxVolume = 0;
    double MaxPrice = 0.0;
    for (int x = 0; x <= Bars.BarsSinceSession; x++)
    {
    if (Volume[x] > MaxVolume)
    {
    MaxVolume = Volume[x];
    MaxPrice = Close[x + 20];
    }}
    Plot0.Set(MaxPrice);


    double MaxVolume = 0;
    double MaxPrice = 0.0;
    for (int x = 0; x <= Bars.BarsSinceSession; x++)
    {
    if (Volume[x] > MaxVolume)
    {
    MaxVolume = Volume[x];
    MaxPrice = Close[x + 20];
    }}
    Plot0.Set(MaxPrice);

    #2
    Shawn, any errors in the log tab as you apply those indicators? The CurrentBar check may not be high enough as your x can easily be higher later in the session...

    Comment


      #3
      Thanks Bertrand...

      THanks Bertrand,

      I do have an error report... It says the following:
      Error on calling "onbarupdate" for indicator on bar 0 (and 20). Index was out of range.. Must be non-negative and less than the size of the collection. Parameter Name index.
      Exactly what should I do about this?

      Comment


        #4
        Shawn, this is likely the too low CurrentBar check I mentioned, as your BarsSinceSession count can easily be higher than 20...

        Comment


          #5
          Reply

          Bertrand,

          Thanks for your feedback..

          Is it possible to fix this problem? I looked at the link that you sent me.. I'm not sure how to proceed.

          From what I understand, the later bars in the session after the volume count are interfering with the results.. Maybe it's not possible to accomplish what I want then based on your feedback?

          Comment


            #6
            More feedback...

            I changed the following code as follows:

            if (CurrentBar < 480) return;

            So far the indicator appears to be working now for (x +20) ... OK.. Thanks...

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            67 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            36 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            61 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            62 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            53 views
            0 likes
            Last Post CarlTrading  
            Working...
            X