• 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

Crossover Strategy Error

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

    Crossover Strategy Error

    Hi I created a simple Crossover Strategy to Understand how strategies work in NT8. I get the following error:

    "''High' Order Fill Resolution is only available for single-series strategies. For multi-series strategies, please program directly into your strategy the more granular resolution you would like to simulate order fills with."

    The strategy uses a fast and slow MA. Can someone tell me what this error means and how to fix it.

    TIA

    #2
    Hello dmking,

    Thank you for the post.

    The error indicates that your script is using a second series in its code, have you used AddDataSeries in your code? If so, the error would be accurate, you already have a secondary series to add fill resolution that can be used.


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

    Comment


      #3
      Thanks for the response Jesse. I get it. I have another couple of questions:

      1. How do I change the color of the arrows from Blue for entry and Magenta for exit?

      2. How do I have the signal for entry or exit occur at the instant a cross occurs or the very next bar at the most (Looks like the signal is given 2 bars later)?

      Hope this is clear.

      D

      Comment


        #4
        Hello dmking,

        Thank you for your reply.

        The chart markers can be changed in the charts Data Series window, when you configure the data series you can choose both the color of the markers and if they should be shown.

        The cross signal would already work as you want, but this depends on the Calculate setting being used and your condition. If you are using OnBarClose, the calculation is checked at the end of the bar, if true it would be submitted at that point. Otherwise, if you use OnEachTick, the condition could become true intrabar or right after the tick that caused it to become true. If the signal is happening 2 bars past when you think it should have, that may just be a confusion between what you are looking at versus what the strategy is actually using. A Print is most commonly the best way to address this type of comparison to see what values the strategy is actually using at that point in time.


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

        Comment


          #5
          Jesse, Take a look at this, I understand what you're saying, but it still looks like the signal occurs later than I would like even with Calculate = On Each Tick. I know that you're busy, but this is just a heuristic for understanding the Strategy Builder within NT8, so this is not urgent. Thanks for you time, patience and help. Dennis

          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.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 Lynx_LE_TriggerTrader : Strategy
          {
          private HMA hmaFast;
          private HMA hmaSlow;
          
          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDes criptionSampleMACrossOver;
          Name = "Lynx_LE_TriggerTrader";
          EntriesPerDirection = 1;
          EntryHandling = EntryHandling.AllEntries;
          IsExitOnSessionCloseStrategy = true;
          ExitOnSessionCloseSeconds = 30;
          IsFillLimitOnTouch = true;
          MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
          // OrderFillResolution = OrderFillResolution.High;
          OrderFillResolutionType = BarsPeriodType.Minute;
          OrderFillResolutionValue = 1;
          Slippage = 0;
          StartBehavior = StartBehavior.ImmediatelySubmit;
          TimeInForce = TimeInForce.Gtc;
          TraceOrders = false;
          RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
          StopTargetHandling = StopTargetHandling.PerEntryExecution;
          BarsRequiredToTrade = 20;
          
          Fast = 8;
          Slow = 21;
          
          // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
          // See the Help Guide for additional information
          IsInstantiatedOnEachOptimizationIteration = false;
          }
          else if (State == State.DataLoaded)
          {
          hmaFast = HMA(Fast);
          hmaSlow = HMA(Slow);
          
          hmaFast.Plots[0].Brush = Brushes.Red;
          hmaSlow.Plots[0].Brush = Brushes.Cyan;
          
          AddChartIndicator(hmaFast);
          AddChartIndicator(hmaSlow);
          }
          }
          
          protected override void OnBarUpdate()
          {
          if (CurrentBar < BarsRequiredToTrade)
          return;
          
          if (CrossAbove(hmaFast, hmaSlow, 1))
          EnterLong();
          else if (CrossBelow(hmaFast, hmaSlow, 1))
          ExitLong();
          }
          
          #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
          }
          }
          Attached Files

          Comment


            #6
            Hi Jesse, What do you mean 'Print'.

            D

            Comment


              #7
              Hello dmking,

              Thank you for your reply.

              Was this an image of a historical test? If so, the result looks to be about what I would expect based on how historical bars are processed.

              For example, the first entry shown I can see the cross visually appears 1 bar before the entry and then we see the entry the next bar after the bar where the signal is processed. In real-time, using OnEachTick would allow the cross condition to be evaluated in realtime so the entry could instead be within the same bar.

              Print's are a useful tool to output data to the output window, if you are using the strategy builder how you are currently visualizing the indicators would also be fine. In manual programming, you could also use prints to output the time and if the condition was true or not, etc..



              I look forward to being of further assistance.

              JesseNinjaTrader Customer Service

              Comment


                #8
                Thanks for all the help Jesse.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by ballboy11, Today, 05:22 PM
                0 responses
                3 views
                0 likes
                Last Post ballboy11  
                Started by ballboy11, Today, 04:33 PM
                2 responses
                4 views
                0 likes
                Last Post ballboy11  
                Started by dedouglas, Today, 03:16 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by TradeMyth, Today, 02:45 PM
                3 responses
                26 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Ticnician, Today, 01:46 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_Jim  
                Working...
                X