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

problem with output window

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

    #16
    The offending statement is .......

    Chelsea & Koganam,

    The offending statement is of the form:

    x=(y + joeHAOindicatorDAY(1)[1]);

    It is in the code for indicator joeHAOindicatorDay.

    Therefore referencing yesterday's value for the indicator while in the code for the indicator is apparently maybe confusing the interface to the Output Window?

    In spite of the Output Window problem, the x calculation appears to be correct [ie] results displayed in the Strategy Analyzer Chart are correct.

    Your thoughts and suggestions for a fix will be greatly appreciated.

    Comment


      #17
      Hi joemiller,

      Does the joeHAOindicatorDAY indicator have print statements as well?

      These may be confusing the prints from your strategy.

      If you would like me to test this for you, I will need an export of your strategy.

      You may send this privately if you are not comfortable releasing your code publicly.

      If this is the case, please send the exported strategy (so any referenced indicators are included), to support[at]ninjatrader[dot]com.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Hello Chelsea,
        Thanks for the complement, but “not comfortable releasing my code publicly” is a big LOL. I merely picked haiken ashi because I wanted more than just a moving average as a tool with which to become familiar with NT [and It was an indicator about which I knew nothing so I might learn something new].

        Yes, the joeHAOindicatorDAY indicator has print statements.
        I have stripped the code down to a bare minimum.
        The exported file is attached [I think/I hope]. Thanks a whole lot for your help.
        Attached Files

        Comment


          #19
          Hello joemiller,

          Thank for your patience as I tested this script.

          The code for the joeHAOindicatorDay has a call to itself with no check to prevent an endless loop.

          Code:
          xOpen=((xCloseyest+joeHAOindicatorDAY(1)[1])*0.5+0.00333);
          This recursive call is actually crashing NinjaTrader for me.

          From the code, it seems that you would like the previous plot value in your calculation.
          To do this try:

          xOpen=((xCloseyest+PlotxODay[1])*0.5+0.00333);

          After changing this and running the script, the prints do appear to happen in a logical order.

          If you are still getting prints out of order, please send me the text in your output window so that I may compare.
          Last edited by NinjaTrader_ChelseaB; 07-08-2013, 01:04 PM.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #20
            Chelsea,
            Your fixes make it run correctly on this end also. Many many thanks.
            Would you now please do the following:
            Make a one hour bar run rather than a day bar run … then note on the chart that the red line is not a straight line for each 24 hour period. Instead the red line for each 24 hour period has a curve at the beginning?

            Also the strategy has a print statement which is not displayed in the output window?

            In case it is of any significance, I am working with Forex, EURUSD, price data.

            Comment


              #21
              Hi joemiller,

              I can confirm that behavior of the plot line.

              However, I am not entirely sure what you are trying to accomplish.

              Are the values that you are printing the values that you would expect?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #22

                Print statements are in both the indicator and the strategy.
                All of the lines displayed in the output window are generated from the indicator code. The strategy has one print statement [ie] “Print(spaces12+"close today "+Close[0].ToString("0.0000"));” but the text from that statement does not appear in the output window?

                The redline is set equal to the plot line in the strategy. I was expecting it to be only straight line segments because it is built using a GetDayBar function. I did strip down the code before sending it to you so I will
                take a closer look at the code I sent because I may have messed it up.

                Comment


                  #23
                  Hello joemiller,

                  I just wanted to let you know, that the strategy file, as you have provided in this forum thread, does make a print for me that reads:

                  close today 1637.0000


                  Regarding the curve of the plot, I recommend that you print all values in the script and double check that these are correct values.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #24
                    My strategy script is displayed below:
                    I just noticed that sometimes the output from the strategy appears in the output window and sometimes not. On successive repeat runs of the Analyzer, one immediately after the other, sometimes I get what looks like 2 sets of the January to July results and sometimes not.
                    I will print to the output window redline plot values, check them, and then get back to you.
                    protectedoverridevoid OnBarUpdate()
                    {
                    redline=joeHAOindicatorDAY(
                    1)[0];
                    if (Position.MarketPosition == MarketPosition.Flat)
                    EnterShort();
                    Print(spaces12+
                    "close today "+Close[0].ToString("0.0000"));
                    if(Open[0]>redline)
                    {
                    if (Position.MarketPosition == MarketPosition.Short)
                    {
                    EnterLong();
                    }
                    }
                    elseif(Open[0]<redline)
                    {
                    if (Position.MarketPosition == MarketPosition.Long)
                    {
                    EnterShort();
                    }
                    }
                    }

                    Comment


                      #25
                      Hi Chelsea,
                      You fixed the problem of the Indicator code infinite loop. Two remaining issues are redline curved segments instead of straight segments and inconsistent output window results?
                      I have modified and exported the exported code previously sent to you. The export is attached.
                      The redline is set equal to the plot line in the strategy. I was expecting the redline to be only straight line segments because it is built using a GetDayBar function. Note on the resulting chart, however, that that the red line is not a straight line for each 24 hour period. Instead for each 24 hour period it has a curve at the beginning? Those values are displayed by print statements in the output window. The Analyzer is set for 60 minute bars with start date = 1/1/13. Output usually starts at 1/1/13 at first, but then starts in April when the Analyzer is immediately rerun multiple times?

                      Comment


                        #26
                        Attachment for previous reply

                        I must have forgotten to click on the attachment upload button?
                        Attached Files

                        Comment


                          #27
                          Hello joemiller,

                          Bars.GetDayBar does return the open low high close of the previous day correctly.

                          With the modified line:
                          xOpen=((xCloseyest+PlotxODay[1])*0.5+0.00333);

                          You may want to change this to:
                          xOpen=((xCloseyest+PlotxODay[0])*0.5+0.00333);

                          The idea here was to return the value of the plot line 1 bar ago correct?

                          Because the plot is set at the end of the script and hasn't been updated before its use PlotxODay[0] will still reference the previous bar value.


                          I recommend that you make lots of prints and try adjusting the math you are using.

                          Also, again using your updated script, the strategy is printing the close today consistently.
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #28
                            xOpen=((xCloseyest+PlotxODay[0])*0.5+0.00333); does not yet make the redline display as straight line segments [see the chart generated by the Analyzer]. The redline is now a jagged line rather than a straight line segment with a curvature at the beginning of the segment.

                            Yes, the idea is to return the value of the plot line 1 DAILY bar ago [as exemplified in code in the built-in heiken ashi indicator].

                            Yes, the print statements are behaving nicely. However, I do not understand the behavior of the output window [eg] Analyzer reruns start with output in April rather than Jan1?

                            Comment


                              #29
                              Hi joemiller,

                              Are you running this on a daily chart and not an hourly chart?

                              You are setting the plot on every bar. That means the plot is updated once an hour if this is an hourly chart.

                              The new calculation for the plot uses the previous calculation for the plot made 1 bar (1 hour) ago and not the previous day, to make a new calculation with some math.

                              PlotxODay[0] represents the previous value of PlotxODay 1 bar ago (1 hour ago).

                              Are your trying to get the plot value of the previous day and not the previous hour?

                              Is there a reason that you are recalculating these values on every bar?

                              I suggested using PlotxODay[0] instead of recursively calling the same script again endlessly because I had assumed you were attempting to return the value of this indicators plot 1 bar ago.
                              Chelsea B.NinjaTrader Customer Service

                              Comment


                                #30
                                Q. Are you running this on a daily chart and not an hourly chart?
                                A. it is an hourly chart. The indicator is to always be the value of the previous day's heiken ashi daily bar open. For each set of 24 hours it should be a constant value for that 24 hours and so should be a straight horizontal line for 24 bars. For one minute bars it should be a straight horizontal line for 1440 bars. For daily bars there is no horizontal aspect to be expected of the line representing the indicator.

                                Q.You are setting the plot on every bar. That means the plot is updated once an hour if this is an hourly chart. The new calculation for the plot uses the previous calculation for the plot made 1 bar (1 hour) ago and not the previous day, to make a new calculation with some math.
                                PlotxODay[0] represents the previous value of PlotxODay 1 bar ago (1 hour ago).
                                A.Yes, but I intend it to be updated every time with the previous day's heiken ashi daily bar open which is constant for the 24 hours

                                Q. Are your trying to get the plot value of the previous day and not the previous hour?
                                A. I'm trying to get the heiken ashi open for the previous day, no matter what the current bar time size is.

                                Q. Is there a reason that you are recalculating these values on every bar?
                                A. No explicitly conscious reason. Now that I think about it, don't I have to have a value for every bar so that it plots on the chart no matter the time frame for the bar?

                                STATEMENT. I suggested using PlotxODay[0] instead of recursively calling the same script again endlessly because I had assumed you were attempting to return the value of this indicators plot 1 bar ago
                                REPLY. Believe me, I feel your pain. I realize this has been very confusing [compounded by my ignorance of the workings of NinjaScript] ... and I appreciate your hanging in there with me.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by geddyisodin, 04-25-2024, 05:20 AM
                                8 responses
                                58 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by halgo_boulder, 04-20-2024, 08:44 AM
                                2 responses
                                21 views
                                0 likes
                                Last Post halgo_boulder  
                                Started by mishhh, 05-25-2010, 08:54 AM
                                19 responses
                                6,189 views
                                0 likes
                                Last Post rene69851  
                                Started by gwenael, Today, 09:29 AM
                                0 responses
                                5 views
                                0 likes
                                Last Post gwenael
                                by gwenael
                                 
                                Started by Karado58, 11-26-2012, 02:57 PM
                                8 responses
                                14,830 views
                                0 likes
                                Last Post Option Whisperer  
                                Working...
                                X