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

Why does my plot contain the extra values and miss some?

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

    Why does my plot contain the extra values and miss some?

    I'm using Draw.Line to put targets and stop on my chart. But I'd also like them to be in a plot series so that I can find them later.

    The code I use to do this is:

    PHP Code:
        private void DrawTargets()
            {
                
    right left 1;                                

                
    Draw.Line(this"entry " Time[i].ToString(), falseleftentryrightentryBrushes.WhiteDashStyleHelper.SolidlineThickness);
                                            
                
    Draw.Line(this"target " Time[i].ToString(), falselefttargetrighttargetBrushes.GreenDashStyleHelper.SolidlineThickness);
                
    Draw.Line(this"targetvert " Time[i].ToString(), falserightentryrighttVertBrushes.GreenDashStyleHelper.Dot1);

                
    Draw.Line(this"stop " Time[i].ToString(), falseleftstoprightstopBrushes.RedDashStyleHelper.SolidlineThickness);
                
    Draw.Line(this"stopvert " Time[i].ToString(), falserightentryrightsVertBrushes.RedDashStyleHelper.Dot1);
                
                
    Draw.Text(this"40t " Time[i].ToString(), false"x"rightt400Brushes.YellowArielFont12,
                    
    TextAlignment.CenterBrushes.TransparentBrushes.Transparent100);
                
    Draw.Text(this"40s " Time[i].ToString(), false"x"rights400Brushes.YellowArielFont12,
                    
    TextAlignment.CenterBrushes.TransparentBrushes.Transparent100);
                
    Draw.Text(this"tBE " Time[i].ToString(), false"-"righttBE0Brushes.WhiteArielFont12,
                    
    TextAlignment.CenterBrushes.TransparentBrushes.Transparent100);
                
                
    Values[0][0] = target;
                
    Values[1][0] = stop;

                
            }&
    #8203; 
    But I get the results in the image below that I don't understand. The crosses are my series values. The short green and red lines use DrawLine.
    The only time I call DrawTargets() is when I need to print to the screen. It draws the lines correctly. But somehow adds extra values to the series as well as missing some of the values. Since it always draws the target and stop lines correctly, how do I get it draw the series crosses correctly?

    This would also allow me to switch to only having the series and saving a lot of resources that are drawing the lines

    Click image for larger version

Name:	image.png
Views:	30
Size:	36.8 KB
ID:	1294302

    #2
    Hello cre8able,

    Thank you for your post.

    To understand why the script is behaving as it is, such as placing or not placing drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

    In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

    The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

    Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

    Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

    I am happy to assist you with analyzing the output from the output window.

    Run the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.

    Below is a link to a forum post that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.


    Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print.​
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      I found it
      thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by lightsun47, Today, 03:51 PM
      0 responses
      4 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      8 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      44 views
      0 likes
      Last Post futtrader  
      Started by Option Whisperer, Today, 09:55 AM
      1 response
      13 views
      0 likes
      Last Post bltdavid  
      Started by port119, Today, 02:43 PM
      0 responses
      8 views
      0 likes
      Last Post port119
      by port119
       
      Working...
      X