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!
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
NinjaTrader
Compiled NT 8 strategy not available in strategy list
Collapse
X
-
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.
-
Originally posted by hgheith View PostStrategy '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?
Leave a comment:
-
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 YouLast edited by hgheith; 10-10-2016, 09:42 PM.
Leave a comment:
-
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.
Leave a comment:
-
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:
-
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:
-
Originally posted by hgheith View PostThank You Sledge.
Yes, the file name is HZMES01.cs and is placed at Documents\NinjaTrader 8\bin\Custom\Strategies\
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:
-
Thank You Sledge.
Yes, the file name is HZMES01.cs and is placed at Documents\NinjaTrader 8\bin\Custom\Strategies\
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.Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
8 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM | ||
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,613 views
0 likes
|
Last Post
by aligator
Yesterday, 07:22 PM
|
||
Started by jaybedreamin, Yesterday, 05:56 PM
|
0 responses
10 views
0 likes
|
Last Post
by jaybedreamin
Yesterday, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
20 views
0 likes
|
Last Post
by DJ888
Yesterday, 05:12 PM
|
Leave a comment: