• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - Starategy runing with real time data feed get feels outside of market

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

    NT8 - Starategy runing with real time data feed get feels outside of market

    I am running a strategy in my window on live data feed.
    Somehow multiple fills as drown on the chart are at levels where market never traded; chart is attached, 3 fills in question are highlighted. in the highlighted bars the fills are above the bars; when checking in data windows I see that the instrument never traded at the level where strategy orders were filled
    Attached Files
    Last edited by astef; 02-08-2016, 06:59 PM.

    #2
    Hello,
    Are you able to reproduce this with the SampleMACrossover strategy?
    Would you be able to provide a copy of the strategy that we would be able to test on our end?
    Cody B.NinjaTrader Customer Service

    Comment


      #3
      Yes

      That was run with sample strategy cross over which follows.


      I think that CrossAbove and CrossBelow functions do not work correctly.
      When I use them on 1 min charts with tick replay all goes wrong.
      I had to replace those functions with:

      if (SMA(Fast)[0] > SMA(Slow)[0] && SMA(Fast)[1] <= SMA(Slow)[1])


      and then when I print the last tick to identify when crossover occurs for the first time and printout the tick with triggered the condition, I see that ninja actualy did not traded at that level, but at some other level which is different; with crossover functions I get fills outside of market;
      with checking of SMAs as above the fills in back testing with tick replay are also incorrect
      ,

      ...

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = "MAStrategyCrossAbove";
      Name = "MAStrategyCrossAbove";
      Fast = 6;
      Slow = 15;

      Calculate = Calculate.OnEachTick;

      RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
      StopTargetHandling = StopTargetHandling.ByStrategyPosition;
      EntriesPerDirection = 1;
      EntryHandling = EntryHandling.AllEntries;

      IsExitOnSessionCloseStrategy = true;
      ExitOnSessionCloseSeconds = 30;
      IsFillLimitOnTouch = false;
      MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
      Slippage = 0;
      StartBehavior = StartBehavior.AdoptAccountPosition;
      TimeInForce = TimeInForce.Gtc;
      TraceOrders = true;

      IsInstantiatedOnEachOptimizationIteration = true;

      }
      else if (State == State.Configure)
      {

      BarsRequiredToTrade = Slow;

      smaFast = SMA(Fast);
      smaSlow = SMA(Slow);
      smaFast.Plots[0].Brush = Brushes.Orange;
      smaSlow.Plots[0].Brush = Brushes.Green;
      AddChartIndicator(smaFast);
      AddChartIndicator(smaSlow);

      SetProfitTarget(CalculationMode.Ticks, Target);
      SetStopLoss(CalculationMode.Ticks, Stop);

      }
      }
      protected override void OnBarUpdate()
      {
      if (CurrentBar < BarsRequiredToTrade)
      return;
      if (CrossAbove(smaFast, smaSlow, 1))
      EnterLong();

      else if (CrossBelow(smaFast, smaSlow, 1))
      EnterShort();
      }
      #region Properties
      [Range(1, int.MaxValue), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "Fast", GroupName = "MA", Order = 0)]
      public int Fast
      { get; set; }
      [Range(1, int.MaxValue), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "Slow", GroupName = "MA", Order = 1)]
      public int Slow
      { get; set; }

      [Range(0, int.MaxValue), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "Target", GroupName = "Limits", Order = 1)]
      public int Target
      { get; set; }

      [Range(0, int.MaxValue), NinjaScriptProperty]
      [Display(ResourceType = typeof(Custom.Resource), Name = "Stop", GroupName = "Limits", Order = 1)]
      public int Stop
      { get; set; }


      #endregion
      }
      }

      Comment


        #4
        installed 8 beta 10

        this is far worse then previous version
        tick replay simply does not work

        note the following code which will print all bars and all ticks
        when running in tick reply mode i only get one tick for each 1 minute bar
        previously it did work correctly and i could observe multiple ticks in tick replay mode

        your charts and fills were incorrect, but i was able to capture entry criteria and was able to calculate p/l for each trade; now i can not do anything as i just get one tick regardless

        //
        // Copyright (C) 2015, NinjaTrader LLC <www.ninjatrader.com>.
        // NinjaTrader reserves the right to modify or overwrite this NinjaScript component with each release.
        //
        #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.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 MACrossOverTick : Strategy
        {
        private SMA smaFast;
        private SMA smaSlow;

        protected override void OnStateChange()
        {
        if (State == State.SetDefaults)
        {
        Description = "MACrossOverTick";
        Name = "MACrossOverTick";
        Fast = 10;
        Slow = 25;


        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;




        }
        else if (State == State.Configure)
        {
        smaFast = SMA(Fast);
        smaSlow = SMA(Slow);

        smaFast.Plots[0].Brush = Brushes.Orange;
        smaSlow.Plots[0].Brush = Brushes.Green;

        AddChartIndicator(smaFast);
        AddChartIndicator(smaSlow);
        }
        }

        protected override void OnBarUpdate()
        {

        if (CurrentBar < BarsRequiredToTrade)
        return;

        if (IsFirstTickOfBar)
        {
        Print(" BAR "
        + (State == State.Historical ? " H " : "R ")
        + " " + Time[0].ToString()

        + " Close[0]:" + Close[0].ToString()
        + " High[0]:" + High[0].ToString("N2")
        + " Low[0]:" + Low[0].ToString("N2")

        );
        }
        Print(" TICK "
        + (State == State.Historical ? " H " : "R ")
        + " " + Time[0].ToString()

        + " Close[0]:" + Close[0].ToString()
        + " High[0]:" + High[0].ToString("N2")
        + " Low[0]:" + Low[0].ToString("N2")

        );


        /* CROSSOVER DOES NOT WORK
        if (CrossAbove(smaFast, smaSlow, 1))
        EnterLong();
        else if (CrossBelow(smaFast, smaSlow, 1))
        EnterShort();
        */

        if (SMA(Fast)[0] > SMA(Slow)[0] && SMA(Fast)[1] <= SMA(Slow)[1])
        {

        Print(">>>>> GOLONG "
        + (State == State.Historical ? " H " : "R ")
        + " " + Time[0].ToString()
        + " Close[0]:" + Close[0].ToString()

        );
        EnterLong();

        }

        if (SMA(Fast)[0] < SMA(Slow)[0] && SMA(Fast)[1] >= SMA(Slow)[1])
        {
        Print(">>>>> GOSHORT "
        + (State == State.Historical ? " H " : "R ")
        + " " + Time[0].ToString()
        + " Close[0]:" + Close[0].ToString()

        );
        EnterShort();

        }



        }

        #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
        }
        }

        Comment


          #5
          I also see this too!!! NT8B10 with your script.

          This was on a 5 minutes chart. If you go here and do a full tick replay on current day only, you can get multiple prints but only displays the 5 minute bar time?

          http://screencast.com/t/5AqQKSe4nw6F
          Last edited by sledge; 04-09-2016, 12:35 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sgordet, Today, 10:44 AM
          1 response
          6 views
          0 likes
          Last Post bltdavid  
          Started by Parmenides48, Today, 08:37 AM
          1 response
          13 views
          0 likes
          Last Post Emma1
          by Emma1
           
          Started by EnveousColnago, 08-06-2020, 08:31 AM
          8 responses
          45 views
          0 likes
          Last Post Emma1
          by Emma1
           
          Started by dieci, Today, 08:50 AM
          0 responses
          5 views
          0 likes
          Last Post dieci
          by dieci
           
          Started by sabankaradeniz, 05-05-2020, 03:49 AM
          4 responses
          547 views
          1 like
          Last Post tornadoatc  
          Working...
          X