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

Strategy Will Not Draw Object

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

    Strategy Will Not Draw Object

    Hello,

    I have been learning C# and am now learning NinjaScript.

    I created a Parabolic SAR Strategy with an audio alert, and the audio alert does work, but the Strategy will not draw the line that I wanted it to draw. So I created a second Parabolic SAR Strategy, but that doesn't draw a line either.

    I added the following code as shown in the screenshots.

    Draw.Line(this, "tag1", false, 10, 1000, 0, 1001, Brushes.Coral, DashStyleHelper.Dot, 2);

    I also tried to add that line to an indicator I am playing around with, but it also does not draw a line.

    One more thing I cannot figure out, is how to have it rearm the audio alert after x seconds or minutes. The audio alert goes off about a hundred times a minute as it is now.

    What code would I add for the rearm period?

    Screenshots attached.

    Thanks,
    Attached Files

    #2
    Hello i2w8am9ii2,
    Thanks for your post.

    Is there an error on the 'Logs' tab of your Control Center? If so, what does it report?

    What version of NT8 are you on? Control Center>Help>About
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      Thanks for your reply.

      I am using Ninjatrader version 8.0.15.1 64-bit

      The only errors I see in the 'Logs' tab of my Control Center are:

      Unhandled exception. Index was outside the bounds of the array.

      Strategy /139968648: An order placed at 8/20/2018 has been ignored since the order was submitted before the strategy property BarsRequiredToTrade had been met

      relies on volume updates expecting Calculate 'On each tick' or 'On bar close'


      But the last error regarding volume is only because I had the Volume Up/Down indicator set to Calculate on Price Change. But that indicator is not used in my Strategy or indicator.

      Comment


        #4
        If you right-click inside your chart>>Drawing Tools>>Drawing Objects... do you see that the line is being added to the chart?

        In regards to your alert and limiting how often it sounds. Are you using Calculate.OnBarClose or Calculate.OnEachTick?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,

          Thanks for your reply.

          When I right-clicked on the chart, it showed a Drawing Object with the name 'tag1'.

          But it had a color of DeepPink, which should be when the RSI is below 45. But as you can see in the screenshots, the RSI was at 54.7 and the price bars were blue. So the color of 'tag1' should've been blue, if I understand how this works.

          And in either case, there was no blue line or deep pink line drawn on the chart.

          As for the Calculate.OnBarClose or Calculate.OnEachTick, I did a 'Find' search for Calculate., for Calculate.OnBarClose, Calculate.OnEachTick and Calculate.OnPriceChange and no results were found in the code each time.

          I did not code any of those in; I am assuming that this code would come from the Strategy Builder, but that is the case, I didn't use the Strategy Builder for this indicator.
          Attached Files
          Last edited by i2w8am9ii2; 08-23-2018, 03:10 PM.

          Comment


            #6
            Hello again,

            When I said, "I did not code any of those in; I am assuming that this code would come from the Strategy Builder, but that is the case, I didn't use the Strategy Builder for this indicator."

            That is because I am on the road now and don't have access to the files on my PC computer. I'm using a laptop while on the road and forgot that I'm in the Strategy section of this forum, so I recreated the RSI indicator that I was working on, instead of the Strategy that I was working on.

            Comment


              #7
              Looks like the coordinates you are using for your lines would not be able to appear on your CL chart. Look at the following snippet as a better example.
              Code:
              protected override void OnBarUpdate()
              {
              	if(CurrentBar<10) return;
              	Draw.Line(this, "tag1", false, 10, High[10], 0, High[0], Brushes.Coral, DashStyleHelper.Dot, 2);
              }
              This would draw a dotted line from the high of 10 bars ago to the high of the current bar. You should change the barsAgo values and Y values to fit your needs.

              In regards to the color not being what you expected, that tells me that your conditions to change the color are likely not becoming true as often as you think they are.
              Josh G.NinjaTrader Customer Service

              Comment


                #8
                Hi Josh,

                Thanks for your reply and for the code.

                I updated the indicator with the new code, just for the long side, as I could not figure out if the short side code should be different or not.

                In either case, the line still was not drawn. Not sure if that is because I was using Playback mode, or not. Would that make a difference?

                Screenshots attached regarding how I input the code and the chart view.
                Attached Files

                Comment


                  #9
                  I'd like to take a look at your log and trace files and this script if you do not mind. You can export your indicator by going to Tools > Export > NinjaScript Add On > Add > select your indicator > OK > Export > name the file 'NTsupport' > Save. The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript. Please attach the file to your response.

                  Once you have done that you can send your log and trace files by going to the Control Center-> Help-> Email Support

                  Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

                  You may add the exported indicator as an attachment. Please reference this forum post and put RE:JOSH in the subject line.
                  Josh G.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Josh,

                    Not necessary to look at my log and trace files. The code is working now. Paul helped me to get it working in another forum thread for indicators.

                    The problem was that it was set to draw the line at a price of 1000, but that price is way out near the moon for the CL instrument.

                    Screenshot attached.
                    Attached Files

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by helpwanted, Today, 03:06 AM
                    1 response
                    7 views
                    0 likes
                    Last Post sarafuenonly123  
                    Started by Brevo, Today, 01:45 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Brevo
                    by Brevo
                     
                    Started by aussugardefender, Today, 01:07 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    242 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    385 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Working...
                    X