Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Newbie question

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

    Newbie question

    Hi,
    I'm new to NinjaScript. In the following example I try to do two things: 1. mark all the swing high/low points, 2 mark the most recent swing high/low points.

    The first part is done w/o problem. The second part is the one that gives me problem. When I uncommend the last command line (which is supposed to mark the most recent peak), the markings for all the swing high/low points (i.e. first part of the program) will disappear consequently. However this command line is not different from the one used to mark the most recent trough used in the same program.

    I've spent a few days debugging this but to no avail. Please can anyone help ?

    Thanks,
    Kevin

    #2
    for (int upOcc = 1 ; upOcc <= CurrentBar; upOcc++)
    {
    upCount = Swing(Strength).SwingLowBar(
    0, upOcc, CurrentBar);
    if (upCount <= 0)
    break;
    DrawTriangleUp(
    "Up"+upOcc , true, upCount, Low[upCount] -5 * TickSize, Color.Lime);
    }

    for (int dnOcc = 1 ; dnOcc <= CurrentBar; dnOcc++)
    {
    dnCount = Swing(Strength).SwingHighBar(
    0, dnOcc, CurrentBar);
    if (dnCount <= 0)
    break;
    DrawTriangleDown(
    "Dn"+dnOcc , true, dnCount, High[dnCount] +5 * TickSize, Color.Blue);
    }

    upTrendStartBarsAgo = Swing(Strength).SwingLowBar(
    0, 1, CurrentBar);
    downTrendStartBarsAgo = Swing(Strength).SwingHighBar(
    0, 1, CurrentBar);

    if(upTrendStartBarsAgo<downTrendStartBarsAgo)
    {
    DrawTriangleUp("Upmost" , true, upTrendStartBarsAgo, Low[upTrendStartBarsAgo] -10 * TickSize, Color.Black);
    }
    else
    {
    Print(
    "dn " );
    //DrawTriangleDown("Dnmost" , true, downTrendStartBarsAgo, High[downTrendStartBarsAgo] +10 * TickSize, Color.Black);
    }

    Comment


      #3
      Welcome to our NinjaScript - to see the history of drawing objects, please use a unique tag Id for each one created such as by adding CurrentBar to your individual string value - with your code you would always modify the last drawn one and thus not see any history.

      Comment


        #4
        Bertrand,
        Thanks for the reply.

        Sorry I didn't make my problem clear. I am not just concerned about missing the markings for the most recent peak/trough, I in fact lose all the markings for ALL the peaks and troughs if I uncomment that particular command line - please see the two pictures attached. The "commented.jpg" shows all the peak/trough markings when the command line is commented out. The "uncomment.jpg" shows that all the markings disappear when the command line is put back in.

        Thanks in advance for your help.
        Attached Files

        Comment


          #5
          yawbus, any errors in the log tab as this happens?

          Is your current bar check at the OnBarUpdate() start high enough to allow plotting in this case?

          Comment


            #6
            Bertrand,
            Thanks for the pointer. The problem is indeed caused by insufficient bars.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            574 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            332 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X