I have just unlocked one of my saved strategies and made some manual changes to it. It is compiling fine, but it doesn't show on the graph as one of the available strategies for use. What could be causing that? Thank you.
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
Unlocked strategy not showing
Collapse
X
-
Unlocked strategy not showing
Hi.
I have just unlocked one of my saved strategies and made some manual changes to it. It is compiling fine, but it doesn't show on the graph as one of the available strategies for use. What could be causing that? Thank you.Tags: None
-
Indeed there is. It is saying Error on calling 'OnStateChange' method: 'AddDataSeries' cannot be called from this state. However, I simply copied the instructions from the tutorial, as follows:
protected override void OnStateChange()
{
if (State == State.Configure)
{
// Add a 5 minute Bars object - BarsInProgress index = 1
AddDataSeries(BarsPeriodType.Minute, 5);
Comment
-
Sure. The code is for a strategy using the 1-minute candle, but I also want to add a condition that uses the 15-minute candle.
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "DMICrossUnlocked";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
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;
// Add a 15 minute Bars object - BarsInProgress index = 1
AddDataSeries(BarsPeriodType.Minute, 15);
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
StopLoss = 1;
TakeProfit = 1;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
EMA1 = EMA(Close, 200);
DM1 = DM(Close, 14);
SetProfitTarget("", CalculationMode.Price, TakeProfit);
SetStopLoss("", CalculationMode.Price, StopLoss, false);
}
}
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Net Change
by Segwin
Started by Segwin, 05-07-2018, 02:15 PM
|
14 responses
1,789 views
0 likes
|
Last Post
by aligator
Today, 11:47 AM
|
||
Started by Jimmyk, 01-26-2018, 05:19 AM
|
6 responses
837 views
0 likes
|
Last Post
by emuns
Today, 11:27 AM
|
||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
6 responses
3,294 views
1 like
|
Last Post
by jgualdronc
Today, 10:56 AM
|
||
Started by Touch-Ups, Today, 10:36 AM
|
0 responses
13 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
11 responses
63 views
0 likes
|
Last Post Today, 10:08 AM |
Comment