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

My Indicator wont print anything,,,,

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

    My Indicator wont print anything,,,,

    Hi,
    I am quite new to ninja script and am building an indicator that will need to use the last 5 zig zag high and low points.

    I have written the code below with a loop to find the last 5 Zig Zag lows and highs and store them in an array for each.....

    I want to check to make sure the loop is correct so i have put a drawtext function on to see the values printed on the chart... but nothing happens.... the indicator compiles successfully and when i load it onto the chart i cant see the text.... can anyone tell me why please?

    Any help greatly appreciated.

    protected override void OnBarUpdate()
    {

    //------------------ If Zig Zag changed, update Zig Zag array --------------

    zzL = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagLow[0];
    zzH = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagHigh[0];

    if (zzH != zzHigh[0] || zzL != zzLow[0])
    {

    double zzLastLowFound =0;
    int LFound = 0;

    double zzLastHighFound =0;
    int HFound = 0;

    for (int x = 0; x < 500; x++)
    {
    zzL = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagLow[x];

    if (zzL != zzLastLowFound && LFound < 5)
    {
    zzLastLowFound = zzL;
    zzLow[LFound] = zzL;
    LFound = LFound + 1;

    }

    zzH = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagHigh[x];

    if (zzH != zzLastHighFound && HFound < 5)
    {
    zzLastHighFound = zzH;
    zzHigh[HFound] = zzL;
    HFound = HFound + 1;

    }

    if (HFound >= 5 && LFound >= 5)break;

    }
    }
    DrawText("DownCxnText" , "ZZH0 = "+zzHigh[0]+"ZZH1 = "+zzHigh[1]+"ZZH2 = "+zzHigh[2]+"ZZH3 = "+zzHigh[3]+"ZZH4 = "+zzHigh[4]+"", 1,zzHigh[1], Color.Black);
    //Print ("ZZH0 = "+zzHigh[0]+"ZZH1 = "+zzHigh[1]+"ZZH2 = "+zzHigh[2]+"ZZH3 = "+zzHigh[3]+"ZZH4 = "+zzHigh[4]+"");

    //---------------- If Zig Zag changed, update Zig Zag array END --------------
    }
    Attached Files

    #2
    protected override void OnBarUpdate()
    {


    if(CurrentBar <= 5)return;


    //------------------ If Zig Zag changed, update Zig Zag array --------------

    zzL = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagLow[0];
    zzH = ZigZag(DeviationType.Points, zZDeviation, true).ZigZagHigh[0];

    if (zzH != zzHigh[0] || zzL != zzLow[0])
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Still not working :-(

      Hi Rjay
      Thanks for posting.
      I have added the line of code and still get nothing printed on the chart....
      Am I missing something? Even if my zig zag loop isn't working, it should still print the text shouldn't it?

      Comment


        #4
        Originally posted by marty087 View Post
        Hi Rjay
        Thanks for posting.
        I have added the line of code and still get nothing printed on the chart....
        Am I missing something? Even if my zig zag loop isn't working, it should still print the text shouldn't it?
        add more print statements to see where the code is hanging up.

        Print("Check1");

        Print("Check2");

        You get the idea.
        RJay
        NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

        Comment


          #5
          Hi,

          Thanks for the tip. I have added the print functions now......

          Here is the error i am getting in the output window.

          Error on calling 'OnBarUpdate' method for indicator 'GeoKing' on bar 7: Object reference not set to an instance of an object.

          Anyopne sure how to deal with it? Am i not initializing something ?

          Comment


            #6
            Hello again.
            I have been using the print function and have identified this line of code as to where it stops

            if (zzH != zzHigh[1] || zzL != zzLow[1])

            This is the first time I am using an array..... the program goes no further after this statement....

            I have tried defining zzHigh[1] as 0 or 1 in the hope that the only problem may have been that there was no value assigned... but still not working..... any ideas.

            Thanks alot..

            Comment


              #7
              All fixed.....
              I had my array declared wrong in variable.
              Thanks for your help!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by andrewtrades, Today, 04:57 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              5 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              436 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              7 views
              0 likes
              Last Post FAQtrader  
              Started by rocketman7, Today, 09:41 AM
              5 responses
              19 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X