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

I can't get this Strategy to load on any chart. Why?

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

    I can't get this Strategy to load on any chart. Why?


    #region Using declarations
    using System;
    using System.Collections.Generic;
    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;
    #endregion

    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class NR3 : Strategy
    {
    private ADL ADL1;


    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "NR3";
    Calculate = Calculate.OnEachTick;
    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;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    EsThreshold = 10000;
    }
    else if (State == State.Configure)
    {
    AddDataSeries("ES 12-18", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    ADL1 = ADL(Closes[1]);
    SetProfitTarget(@"NR3L", CalculationMode.Ticks, 11);
    SetStopLoss(@"NR3L", CalculationMode.Ticks, 32, true);
    }
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // Set 1
    if (ADL1[0] > EsThreshold)
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"NR3L");
    }

    }


    #2
    Found the issue. This line of code is the reason the strategy will not load:

    if (BarsInProgress != 0)
    return;

    This line of code ended up in the strategy because initially it was an automated strategy generated by strategy builder. The line was added because it did not start out as a muti-instrument strategy.

    Comment


      #3
      Hello hyperbolt, thanks for your post, and welcome to the NinjaTrader fourm.

      For some reason, our ticketing system did not send us a notification of your first post. I'll see if our IT department has any info on why that happened.

      If we can assist with anything else please let us know.
      Chris L.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by jclose, Today, 09:37 PM
      0 responses
      5 views
      0 likes
      Last Post jclose
      by jclose
       
      Started by WeyldFalcon, 08-07-2020, 06:13 AM
      10 responses
      1,413 views
      0 likes
      Last Post Traderontheroad  
      Started by firefoxforum12, Today, 08:53 PM
      0 responses
      11 views
      0 likes
      Last Post firefoxforum12  
      Started by stafe, Today, 08:34 PM
      0 responses
      11 views
      0 likes
      Last Post stafe
      by stafe
       
      Started by sastrades, 01-31-2024, 10:19 PM
      11 responses
      169 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X