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

Error : order has been ignored....

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

    Error : order has been ignored....

    Hi, every time I enable my strategy I get the error in picture 1, do you know what it means?

    here is my strategy, not working properly, don't know why, sometimes the orders are not cancelled and he can't update properly.

    #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 Aversion3 : Strategy
    {
    private int PositionCalc;
    private double SLprice;
    private double Entryprice;

    private MyDonchianClose MyDonchianClose1;

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "Aversion3";
    Calculate = Calculate.OnPriceChange;
    EntriesPerDirection = 1;
    EntryHandling = EntryHandling.AllEntries;
    IsExitOnSessionCloseStrategy = false;
    ExitOnSessionCloseSeconds = 30;
    IsFillLimitOnTouch = false;
    MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
    OrderFillResolution = OrderFillResolution.Standard;
    Slippage = 0;
    StartBehavior = StartBehavior.ImmediatelySubmit;
    TimeInForce = TimeInForce.Gtc;
    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
    StopTargetHandling = StopTargetHandling.ByStrategyPosition;
    BarsRequiredToTrade = 60;
    // Disable this property for performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = true;
    Virtual_Account_Value = 10000;
    Risk = 0.06;
    Contract_Multiplier = 1;
    Entry_Stop_Spread_TICKS = 100;
    PositionCalc = 1;
    SLprice = 1;
    Entryprice = 1;
    }
    else if (State == State.Configure)
    {
    }
    else if (State == State.DataLoaded)
    {
    MyDonchianClose1 = MyDonchianClose(Close, 54);
    }
    }

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

    if (CurrentBars[0] < 55) //you have to put 2, unless it wont run because you are asking indicator data [1]barago, so need 2 bars at least.
    return; //you have to put 55, so you would have at least 55 bars, unless he tries to enter position on 3 bars distance which is huge!

    // Set 1
    if (Position.MarketPosition == MarketPosition.Flat)
    {
    Entryprice=MyDonchianClose1.Upper[1]; //calculating what should be the position size of the trade
    SLprice=MyDonchianClose1.Lower[1];
    double PositionCalc=Math.Ceiling((Virtual_Account_Value*R isk)/((Entryprice-SLprice)*Contract_Multiplier));

    EnterLongStopLimit(Convert.ToInt32(PositionCalc), (MyDonchianClose1.Upper[1] + (Entry_Stop_Spread_TICKS * TickSize)) , MyDonchianClose1.Upper[1], @"EnterLong");
    }

    // Set 2
    if (Position.MarketPosition == MarketPosition.Long)
    {
    //here you put Position.Quantity=equal to currentposition, so the position size will be the same as we enter the trade.
    ExitLongStopMarket(Convert.ToInt32(Position.Quanti ty), MyDonchianClose1.Lower[1], @"ExitLong", @"EnterLong");
    }

    }

    #region Properties
    [NinjaScriptProperty]
    [Range(1, double.MaxValue)]
    [Display(Name="Virtual_Account_Value", Description="This is the cash value before you start the strategy in the small virtual account", Order=1, GroupName="Parameters")]
    public double Virtual_Account_Value
    { get; set; }

    [NinjaScriptProperty]
    [Range(0.01, double.MaxValue)]
    [Display(Name="Risk", Description="Risk percent on each trade of the virtual account", Order=2, GroupName="Parameters")]
    public double Risk
    { get; set; }

    [NinjaScriptProperty]
    [Range(1, int.MaxValue)]
    [Display(Name="Contract_Multiplier", Description="Multiplier for futures", Order=3, GroupName="Parameters")]
    public int Contract_Multiplier
    { get; set; }

    [NinjaScriptProperty]
    [Range(0, int.MaxValue)]
    [Display(Name="Entry_Stop_Spread_TICKS", Description="what is the distance of the LMT in the StopLmt order", Order=4, GroupName="Parameters")]
    public int Entry_Stop_Spread_TICKS
    { get; set; }
    #endregion

    }
    }

    would appreciate if you see something screamingly wrong... thanks in advance!

    #2
    Hello zoharcho,

    Thank you for your post.

    Strategies have a property called BarsRequiredToTrade that basically restricts the strategy from entering until at least that number of bars is on the chart.

    The note you're seeing isn't actually an error, just telling you that the strategy wasn't to the minimum number of bars on the chart before it tried to take a trade. You can set this to a different value by setting BarsRequiredToTrade in State.SetDefaults.



    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      thank you, happy to hear

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by mattbsea, Today, 05:44 PM
      0 responses
      2 views
      0 likes
      Last Post mattbsea  
      Started by RideMe, 04-07-2024, 04:54 PM
      6 responses
      31 views
      0 likes
      Last Post RideMe
      by RideMe
       
      Started by tkaboris, Today, 05:13 PM
      0 responses
      2 views
      0 likes
      Last Post tkaboris  
      Started by GussJ, 03-04-2020, 03:11 PM
      16 responses
      3,281 views
      0 likes
      Last Post Leafcutter  
      Started by WHICKED, Today, 12:45 PM
      2 responses
      19 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Working...
      X