Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compiled NT 8 strategy not available in strategy list

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

  • hgheith
    replied
    Thank You Sledge. Adding CurrentBar check solved the problem.
    I would like to note this was not needed when I was running the script in NT 7.

    Leave a comment:


  • sledge
    replied
    Originally posted by hgheith View Post
    Strategy 'HZMES02': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    Disabling NinjaScript strategy 'HZMES02/87522429'

    So it seems EMA series is not added?
    CurrentBar check needed.



    Leave a comment:


  • hgheith
    replied
    Thank You for you follow up.
    Yes, placing the AddDataSeries under State.Configure fixed reading the list.

    Another related question is the difference between "if" vs "else if" (State== State.Configure). Not sure it has an impact, but this is in relation to another error I am still receiving when accessing EMA(xx)[y] for any y except 0.

    Here is the code:
    if (State == State.Configure)
    {
    foreach(string x in instNameArr)
    {
    AddDataSeries(x, BarsPeriodType.Volume, instVol);
    }
    EMA(21);
    EMA(100);
    }

    protected override void OnBarUpdate()
    {
    Print("we are here 1");
    Print("Times[instID][0] = " + Times[instID][0]);
    Print("EMA(21)[0] = " + EMA(21)[0]);
    Print("EMA(100)[0] = " + EMA(100)[0]);
    Print("EMA(21)[1] = " + EMA(21)[1]);
    Print("EMA(100)[1] = " + EMA(100)[1]);

    The result is:
    we are here 1
    Times[instID][0] = 3/19/2015 2:38:09 PM
    EMA(21)[0] = 2080
    EMA(100)[0] = 2080
    Strategy 'HZMES02': Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    Disabling NinjaScript strategy 'HZMES02/87522429'

    So it seems EMA series is not added?

    Thank You
    Last edited by hgheith; 10-10-2016, 09:42 PM.

    Leave a comment:


  • NinjaTrader_PatrickH
    replied
    Hello hgheith,

    Thank you for your post.

    In the screenshot you sent us over here at Platform Support you had AddDataSeries in SetDefaults which would result in the error I sent you via email.
    Strategy 'HZMES01': Error on calling 'OnStateChange' method: 'AddDataSeries' cannot be called from this state. Please see the Help Guide article on 'AddDataSeries' for more information.
    I see you edited your post here and the AddDataSeries() is not in the SetDefaults State. Are you still seeing this issue with AddDataSeries in the Configure State?

    Leave a comment:


  • sledge
    replied
    I barely remember some issue with AddDataSeries in State.SetDefault .... or suffering bad case of Déjà vu. I spent 30 minute searching and can't find previous post.

    Leave a comment:


  • hgheith
    replied
    Thank You Sledge. I started from the strategy editor. I followed your steps and the strategy became available. I tested all additions I thought to add and now realize that the problem was related to a list definition I added under the State defaults. I moved it to under the State.Configure and the strategy is now available.

    if(State == State.SetDefaults)
    {
    ...
    }
    else if (State == State.Configure)
    {
    foreach(string x in instNameArr)
    {
    AddDataSeries(x, BarsPeriodType.Volume, instVol);
    }
    ...

    Leave a comment:


  • sledge
    replied
    Originally posted by hgheith View Post
    Thank You Sledge.
    Yes, the file name is HZMES01.cs and is placed at Documents\NinjaTrader 8\bin\Custom\Strategies\
    It worked here for me:

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.



    I did new Ninjascript - Generated code, removed all the code except for the generic OnBarUpdate, and pasted your code in, did right click -> save as, put in your file name.

    Had some issues with "MyCustomStrategy" having the same name in the space of HZMES01. So I changed that the HZMES02 and everything compiled.

    Went into the chart->strategies, and HZMES01 was available.

    Are there any other steps you are doing? Did you create this in the editor? With the strategy builder?

    Leave a comment:


  • hgheith
    replied
    Thank You Sledge.
    Yes, the file name is HZMES01.cs and is placed at Documents\NinjaTrader 8\bin\Custom\Strategies\

    Leave a comment:


  • sledge
    replied
    Originally posted by hgheith View Post
    ,

    Code:
    public class [B]HZMES01[/B] : Strategy
    {
     
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "[B]HZMES01[/B]";
    }
    Is the filename also: HZMES01 ?

    Leave a comment:


  • Compiled NT 8 strategy not available in strategy list

    Hi,
    I put together a NT 8 strategy and compiled it with no errors (some warnings). When trying to add the strategy to simulate it is not listed as available. Only the default NT 8 system strategies are available (the @ ones). I restarted NT 8 and recompiled the strategy with no luck. Any help will be appreciated.

    Here are few lines at the start of the strategy:

    #region Using declarations
    using System;
    using System.Collections.Generic;// this allows using List
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    using System.Collections; // this allows using ArrayList
    #endregion
    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class HZMES01 : Strategy
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "HZMES01";
    Calculate = Calculate.OnPriceChange;
    EntriesPerDirection = 3;
    EntryHandling = EntryHandling.UniqueEntries;
    IsExitOnSessionCloseStrategy = true;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.WaitUntilFlat;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    }
    else if (State == State.Configure)
    {
    AddDataSeries("ES 12-16", Data.BarsPeriodType.Volume, 10000, Data.MarketDataType.Last);
    }
    }
    Last edited by hgheith; 10-09-2016, 06:03 PM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by CarlTrading, 05-11-2026, 05:56 AM
0 responses
31 views
0 likes
Last Post CarlTrading  
Started by CarlTrading, 05-10-2026, 08:12 PM
0 responses
21 views
0 likes
Last Post CarlTrading  
Started by Hwop38, 05-04-2026, 07:02 PM
0 responses
184 views
0 likes
Last Post Hwop38
by Hwop38
 
Started by CaptainJack, 04-24-2026, 11:07 PM
0 responses
341 views
0 likes
Last Post CaptainJack  
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
264 views
0 likes
Last Post Mindset
by Mindset
 
Working...
X