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

Close-Value is printed as Median

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

    Close-Value is printed as Median

    Hi,

    I have a really strange situation:
    I use following code inside a custom indicator to produce data-input for excel:

    double LinRegSlope5 = (LinReg(3)[1] - LinReg(3)[2])/Close[1];
    double LinRegSlope10 = (LinReg(10)[1] - LinReg(10)[2])/Close[1];
    double LinRegSlope30 = Close[0];

    Print(Time[0] + "§" + Close[0]);
    Print(Time[0] + "§" + High[0] + "§" + Low[0]+ "§" + Median[0] +
    "§" +High[1]+ "§" +Low[1]+
    "§" +BGstatus[0]+ "§" + BGstatus[1] + "§" + ATR(15)[1] +
    "§" + LinRegSlope5 + "§" + LinRegSlope30 + "§" + Open[0]);

    When I checked the data quality I realized that Close[0] is not printed correctly, instead the Median[0] value was returned by the code.

    I tried several different possibilities:
    1st: what you now see as red code "LinRegSlope30" was Close[0] before
    2nd: I changed the variable "LinRegSlope30" above the print command to Close[0], but again the Median[0] was produced
    3rd: I added the simple Print-Command (blue font) to double check, but again only Median was produced (look at attached screenshot). The DataBox in the Chart shows me the correct Close-value of the bars.

    Interestingly enough, when I create a new custom indicator with only the green Code Line, it works properly, so it has to have something to do with the rest of the code in the other indicator, which you can see at the end of that comment (I copied everything from the very top to the very bottom of the code and also exported the indicator via NT-Export-Tool -> the indicator is named "CccMaDifferenceBackColor"). The indicator is working without any error notice as it should. Only the printing seems to be a problem.

    I have the screenshot attached as pdf out of word.doc of the output window.
    image1: produced by the the code above
    image2: produced with new custom indicator -> only green print command

    Can you explain this behaviour of NT/reproduce it on your end??? To me it looks like a major bug!

    kind regards
    Attached Files

    #2
    koalboy,

    If you look at the first line of your screen shot, it says 9995. Where you are printing the LinRegSlope30 it is the same value, and you have assigned it to double LinRegSlope30 = Close[0];

    What it looks like is Median is the same as Close, not necessarily that Close IS the Median. Have you tried calculating the Median yourself to compare?

    It's just (High[0] + Low[0] )/ 2
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      thanks for fast reply,
      as I told you, I came across this error, while doing some basic data quality checks in Excel before "trusting" the data...
      please check not only the first value but also the others!!!
      thx

      Comment


        #4
        We tried to look into your attachment / code file but unfortunately it contained compiled code with no source code access to review. I would suggest reworking your print parts in the original file to see where it 'breaks' exactly, since the test indicator code itself prints ok, I would not suspect a data issue nor NinjaScript method one surfacing here. Try commenting out all prints and just add back them one by one and observer the output generated closely.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rajendrasubedi2023, Today, 09:50 AM
        0 responses
        7 views
        0 likes
        Last Post rajendrasubedi2023  
        Started by ender_wiggum, Today, 09:50 AM
        0 responses
        3 views
        0 likes
        Last Post ender_wiggum  
        Started by bmartz, Today, 09:30 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by geddyisodin, Today, 05:20 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by lorem, Today, 09:18 AM
        1 response
        5 views
        0 likes
        Last Post lorem
        by lorem
         
        Working...
        X