Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Forcing strategies to run?

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

    Forcing strategies to run?

    Hi there!

    I have a simple SMA crossover strategy that runs on whole Nasdaq 100 list.
    They are enabled, online and in sync, and I still don't get buy and sell signals on end of day market data. What am I missing?
    The only whay for me to get the strategies to run is to de-enable and re-enable them, but this should run automatically or am I wrong?

    is there something in my code? See below (partial code)
    Code:
    public class MySMAstrategy : Strategy
        {
            private SMA SMA1;
            private SMA SMA2;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"My simple SMA Strategy";
                    Name                                        = "MySMAstrategy";
                    Calculate                                    = Calculate.OnBarClose;
                    EntriesPerDirection                            = 2;
                    EntryHandling                                = EntryHandling.AllEntries;
                    IsExitOnSessionCloseStrategy                = false;
                    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)
                {
                }
                else if (State == State.DataLoaded)
                {                
                    SMA1                = SMA(Close, 21);
                    SMA1.Plots[0].Brush = Brushes.LimeGreen;
                    AddChartIndicator(SMA1);
                    SMA2                = SMA(Close, 14);
                    SMA2.Plots[0].Brush = Brushes.Red;
                    AddChartIndicator(SMA2);
                }
            }
    
            protected override void OnBarUpdate()
            {
                if (CurrentBars[0] < 1)
                return;
    
                 // Set 1
                if (CrossAbove(Close, SMA1, 1))
                {
                    Draw.ArrowUp(this, @"KÖP Arrow up_1", false, 0, 0, Brushes.Lime);
                    Log(@"Köp " + Instrument.FullName.ToString() + " til pris: " + Instrument.MarketData, Cbi.LogLevel.Information);
                    //SendMail(@"[email protected]", @"Köpsignal", @"Köp ", Instrument.FullName.ToString());
                    EnterLong(Convert.ToInt32(DefaultQuantity), "");
                }
                
                 // Set 2
                if (CrossBelow(Close, SMA2, 1))
                {
                    Draw.ArrowDown(this, @"Sälj Arrow down_1", false, 0, 0, Brushes.Red);
                    Log(@"Sälj " + Instrument.FullName.ToString() + " til pris: " + Instrument.MarketData, Cbi.LogLevel.Information);
                    //SendMail(@"[email protected]", @"Sälj", @"Sälj ", Instrument.FullName.ToString());
                    ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
                }
    Thanks in advance!
    Can I write to a textfile instead of the log?

    #2
    Hello,

    Thank you for the post.

    I wanted to check, you noted that you are running this on end of day market data, can you tell me is this specifically the Kinetick end of day connection or are you using Daily bars with another provider?

    Using the Kinetick EOD connection would not work to drive strategies as there are no updates to drive the simulation engine, this can be used for displaying historical trades. Other connections which have live data can be used with daily bars but would rely on the bar to close to execute the logic with your current script. This would mean you would likely not see any updates until the open of the next day's session when the first tick of the bar would close the prior day's bar.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse!

      I see. I am using the Google connection.
      Btw I thing I posted this in the wrong section, I am using NT8.

      Basically what I want to do is;
      by the end of each tradingday, chech each stock against the strategy.
      The strategy in turn write buy or sell or nothing to the log.

      Is that at all possible?
      Lets say I leave the computer running 24/5

      Comment


        #4
        Hello,

        Thank you for the reply.

        Yes in this case because this is a delayed connection this would not be able to drive the simulation engine meaning that orders cannot be placed.

        You would need to use a Live data feed to allow a strategy to run, you can use this connection to do historical tests but it would not place orders in real-time.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Oh I see.
          What kind of live data is out there? This is just for simulation so I want the cheapest possible.

          Comment


            #6
            Hello,

            You can locate the supported data providers/ brokers in the help guide here: http://ninjatrader.com/support/helpG...y_provider.htm

            You would need to research the providers you are interested in as they all offer different items. Once you locate one that seems to fit your needs or provides the services you need, you could inquire further with that provider to get prices or other information.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thanks.

              So to run a strategy I need a realtime quote provider.
              Just to try a thought: I can disable and enable each strategy to get them to run?

              I know the quotes are delayed but in theory?
              Is it at all possible to script this re-enabeling of the strategies?

              If you have a long term trend following strategy, exact entry timing isn't crucial.

              Comment


                #8
                Hello,

                Thank you for the reply.

                To run a strategy in real-time, you would need a real-time data feed. Delayed data would not drive the simulation engine to allow for orders and long to occur.

                By disabling and re-enabling the strategy, you have only refreshed the strategies historical backtest and allowed it to re-run over the historical bars. This would not place any real-time orders as there is no real-time data to allow for that.There is also no supported API for disabling and re-enabling a strategy through the code, this is a user interface action.

                You can use the platform to simulate historical trades over the historical data collected but would need some form of live data to push the strategies logic. You can use the Market Replay to simulate forward tests and also the Simulated data feed to generate fake market data as well.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Barry Milan, Yesterday, 10:35 PM
                5 responses
                16 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by DanielSanMartin, Yesterday, 02:37 PM
                2 responses
                13 views
                0 likes
                Last Post DanielSanMartin  
                Started by DJ888, 04-16-2024, 06:09 PM
                4 responses
                12 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by terofs, Today, 04:18 PM
                0 responses
                11 views
                0 likes
                Last Post terofs
                by terofs
                 
                Started by nandhumca, Today, 03:41 PM
                0 responses
                8 views
                0 likes
                Last Post nandhumca  
                Working...
                X