Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy not opening in strategy analyzer?

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

    Strategy not opening in strategy analyzer?

    Very simple strategy as I'm still learning the coding. However, no matter what I do, I cannot get this strategy to appear in the analyzer. I've tried saving, making a new strat, compiling over and over, and just about everything I can think of. Is there an issue with the code that Ninjascript won't tell me about?

    Code:
    #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 test : Strategy
        {
            private SMA fast;
            private SMA slow;
              private int stopLoss = 30;
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"test";
                    Name                                        = "test";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 1;
                    EntryHandling                                = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy                = false;
                    ExitOnSessionCloseSeconds                    = 30;
                    IsFillLimitOnTouch                            = false;
                    MaximumBarsLookBack                            = MaximumBarsLookBack.TwoHundredFiftySix;
                    OrderFillResolution                            = OrderFillResolution.Standard;
                    Slippage                                    = 1;
                    StartBehavior                                = StartBehavior.WaitUntilFlat;
                    TimeInForce                                    = TimeInForce.Day;
                    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;
                    AddDataSeries(Data.BarsPeriodType.Minute, 1);
                }
                else if (State == State.Configure)
                {
                    Description = "An example of a MA crossover strategy.";
                    Name = "MovingAverageCrossover";
                    fast = SMA(11);
                    slow = SMA(130);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (CurrentBar < slow.Period)
                return;
    
            // For Long Position
            if (CrossAbove(fast, slow, 1))
            {
                if (Position.MarketPosition == MarketPosition.Short)
                    ExitShort(stopLoss, "ExitShort", "Short");
    
                EnterLong(stopLoss, "Long");
            }
    
            // For Short Position
            if (CrossBelow(fast, slow, 1))
            {
                if (Position.MarketPosition == MarketPosition.Long)
                    ExitLong(stopLoss, "ExitLong", "Long");
    
                EnterShort(stopLoss, "Short");
            }//Add your custom strategy logic here.
            }
            #region Properties
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "NinjaScriptStrategyParameters", Order = 0)]
            public int Fast
            { get; set; }
    
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "NinjaScriptStrategyParameters", Order = 1)]
            public int Slow
            { get; set; }
            #endregion
        }
    }
    ​

    #2
    Hello RehmaZ,

    Thank you for your post.

    Do you receive any errors on the Log tab of the Control Center? Are there any errors in the NinjaScript Editor?
    Please right-click on your strategy in the Strategies folder from the right-hand side of the NinjaScript Editor - do you have "Exclude From Compilation" checked? If so, please select this option to uncheck it and include the strategy in compilation, and then close and reopen the Strategy Analyzer to test if it is in the list.

    I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Jonker, Today, 01:19 PM
    0 responses
    1 view
    0 likes
    Last Post Jonker
    by Jonker
     
    Started by futtrader, Today, 01:16 PM
    0 responses
    5 views
    0 likes
    Last Post futtrader  
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,791 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    844 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,296 views
    1 like
    Last Post jgualdronc  
    Working...
    X