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

Calculation OHLC NT8

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

    Calculation OHLC NT8

    Hello,

    I have an issue and I´m working round now for 2 days (!!!) and dont get a solution for this "problem", that might sound ridiculous.
    I simply want to have the distance from Close to Open or Open to Close. I dont know whats goin on that I get strange values printed.

    I have COBC==true and if(BarsInProgress==0){
    range0=(Opens[0][0]-Closes[0][0]);
    range1=(Closes[0][1]-Opens[0][1]);


    Opens and Closes are plotted correctly, but I get as results:
    Opens[0][0] with 2482 and Closes[0][0] with 2482.75 it plots a range0 with -0.5
    Closes[0][1] with 2481.75 and Opens[0][1] with 2481.25 it plots a range with 1.25

    I tried it already with Math.Round and with "*TickSize" but always wrong values for distance open and close.
    What is necessary in there to get the correct values please for open-close or close-open?


    Thank you!
    Tony



    #2
    Hello Tony,

    Can we have the output of a print to fully understand?

    Print this after range0 is assigned its value.
    Code:
    Print(string.Format("{0} | BIP: {1} | (Opens[0][0]: {2} - Closes[0][0]: {3}) = {4} | range0: {5}", Time[0], BarsInProgress, Opens[0][0], Closes[0][0], (Opens[0][0] - Closes[0][0]), range0));
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      thank you for your reply. Please find attached the output as txt from a playback and a screenshot of the lines where I tried to get the result.

      Thank you for your support!

      Tony
      Attached Files

      Comment


        #4
        Hello Tony,

        Unfortunately, you have not placed the print after range0 is assigned its value.

        You have placed this print before range0 is assigned its value.

        This means the print will not be printing the current bars value of range0.

        Try placing the print after range0 is assigned its value.


        We can see in the output that the subtraction is correct. The only incorrect value is your value. Likely because this is the value for the previous bar.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by funk10101, Today, 12:02 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by GLFX005, Today, 03:23 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by nandhumca, Yesterday, 03:41 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by The_Sec, Yesterday, 03:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by vecnopus, Today, 06:15 AM
        0 responses
        1 view
        0 likes
        Last Post vecnopus  
        Working...
        X