Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

      BertrandNinjaTrader Customer Service

      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?

          BertrandNinjaTrader Customer Service

          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 yertle, Yesterday, 08:38 AM
            7 responses
            28 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by bmartz, 03-12-2024, 06:12 AM
            2 responses
            21 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by funk10101, Today, 12:02 AM
            0 responses
            4 views
            0 likes
            Last Post funk10101  
            Started by gravdigaz6, Yesterday, 11:40 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by MarianApalaghiei, Yesterday, 10:49 PM
            3 responses
            10 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Working...
            X