Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DrawingObjects Not Detected Reliably when Reloading NinjaScript

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

    DrawingObjects Not Detected Reliably when Reloading NinjaScript

    I am finding that NT8 is not reliably detecting multiple drawing objects (such as multiple rays) when reloading a NinjaScript Strategy. I am running version 8.0.5.1 64-bit.

    I created a simple script to demonstrate this behavior (see attached).

    The OnBarUpdate method contains the following code:
    Code:
    if ((Count - 2 == CurrentBar))
    {
    	Print(string.Format("(OnBarUpdate) DrawObjects.Count : {0}, CurrentBar: {1}", DrawObjects.Count, CurrentBar));
    	foreach (DrawingTool trendline in DrawObjects)
    	{
    		Print(string.Format("Object Tag: {0}", trendline.Tag.ToString()));
    	}
    }
    1) I added and enabled the strategy script to my chart window. The issue seems to be independent of the interval.
    2) I added two rays to my chart with tags, "Ray 2" and "Ray 3"
    3) On the chart, I reloaded the NinjaScript successively a handful of times using F5.

    The output of the script is shown in the attachment.

    The first time the script was reloaded, it found only 1 DrawObject; Ray 2
    The second time, it found 2 DrawObjects, Ray 2 and Ray 3
    The third time, it found 1 DrawObject, Ray 2.

    I have a different script where I am having trouble detecting multiple trendlines reliably, because of this issue.

    Any help would be appreciated.
    Attached Files
    Last edited by dp2002; 03-20-2017, 09:22 AM.

    #2
    Hello dp2002, and thank you for your question. The help guide has this to say about DrawObjects :

    Originally posted by http://ninjatrader.com/support/helpGuides/nt8/en-us/drawingtools_drawobjects.htm
    Note: When reloading NinjaScript, all objects (including manual drawing tools) are reloaded at the same time. There is no guarantee a manually drawn object will be added to the DrawObjects collection before an indicator starts processing data
    For this reason I would like to suggest guaranteeing everything has completely loaded by waiting until you are in the realtime state. The attached example works reliably. Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response Jessica.

      I have a couple of questions.

      1) Does the statement, "There is no guarantee a manually drawn object will be added to the DrawObjects collection before an indicator starts processing data" imply that indicators only start processing data in real-time? In that case, how are indicators displayed for historical data?

      2) If the State has to equal real-time, then am I unable to backtest strategies with hand-drawn trendlines?

      Comment


        #4
        I am happy to clarify further.

        1. Indicators and strategies have full access to their own drawn objects during the entire lifecycle of the drawing object, including during historical data processing. It is only hand-drawn objects not managed by the indicator or strategy itself that it can not be guaranteed to detect before data is being processed.
        2. To backtest strategies like ATM strategies or those with hand-drawn lines, you will need to use the Playback Connection. I recommend using Market Replay data for accuracy, since the Playback Controller doesn't have access to level 2 data when using historical data.
        Last edited by NinjaTrader_JessicaP; 03-21-2017, 01:34 PM.
        Jessica P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by fx.practic, 10-15-2013, 12:53 AM
        5 responses
        5,403 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by Shai Samuel, 07-02-2022, 02:46 PM
        4 responses
        94 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by DJ888, Yesterday, 10:57 PM
        0 responses
        6 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by MacDad, 02-25-2024, 11:48 PM
        7 responses
        158 views
        0 likes
        Last Post loganjarosz123  
        Started by Belfortbucks, Yesterday, 09:29 PM
        0 responses
        8 views
        0 likes
        Last Post Belfortbucks  
        Working...
        X