Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Different Exit Times + Bool

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

    Different Exit Times + Bool

    Hello Programmers,

    I am locking for a code cosntruct, that helps me to control different exit times.

    In my code I am having an general exit time in the near from the end of the trading day: 21:45 MEZ/MESZ (central european time/central european summer time).

    Now I need different general exit times, that means for each instrument, that the position ends definitly on its. That means: if an instrument is reaching the NEXT exit time, then the strategy will stop its.

    In my example I am using 4 different exit times (color: red): 08:00, 14:25, 15:25, 21,45.

    1. First example is trading the DAX Future (FDAX) at EUREX. Entry zone is 9:00 until 11:30 = trade start zone. Its end is the NEXT exit time = 14:25. So in this example the trade can only have one latest exit.

    2. Second example is Crude Oil (CL) at NYMEX. Entry zone is 00:00 until 17:30. So there are now 4 possible exit times. Which exit time is the correct one? Answer: it is depending from start time of the trade. Example start time at 5:17: Exit time is the next one = 8:00. Another example: start time is 8:33: Exit time is the next one = 14:25. And so on.

    Click image for larger version

Name:	strategy_different_exit_times.png
Views:	179
Size:	609.2 KB
ID:	1263335

    And at last: I would love, if I can implement a bool variable, that is deactivating an specific exit time - for example 14:25 from on to off. The result would be, that the trade in the last example will not stop at 14:25. Its new exit time is then 15:25.

    Variables:
    Code:
    ContractsLong = 1;
    ContracsShort = 1;​
    
    //Possible Entry Time Zones
    MyStart1 = DateTime.Parse("00:01", System.Globalization.CultureInfo.InvariantCulture);
    MyEnd1 = DateTime.Parse("23:15", System.Globalization.CultureInfo.InvariantCulture);
    MyStart2 = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture);
    MyEnd2 = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture);
    MyStart3 = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture);
    MyEnd3 = DateTime.Parse("00:00", System.Globalization.CultureInfo.InvariantCulture);​
    
    // Possible Exit Times
    MyExitTime1 = DateTime.Parse("08:00", System.Globalization.CultureInfo.InvariantCulture);                
    MyExitTime2 = DateTime.Parse("14:25", System.Globalization.CultureInfo.InvariantCulture);                
    MyExitTime3 = DateTime.Parse("15:25", System.Globalization.CultureInfo.InvariantCulture);
    
    // Definitly Exit Time from the day
    MyLastestExitTime = DateTime.Parse("21:45", System.Globalization.CultureInfo.InvariantCulture);​
    
    //Bool-Variables for activating/deactivating the individual exit times
    MyBoolExit1 = true;
    MyBoolExit2 = true;
    MyBoolExit3 = true;
    MyBoolExit4 = true;​

    Here is the code from my 3 different entry time zones (manually fill out in Parameter-Menue, because its different for each instrument)

    Code:
    if (
                    ((Times[0][0].TimeOfDay >= MyStart1.TimeOfDay)
                     && (Times[0][0].TimeOfDay <= MyEnd1.TimeOfDay))
    
                     || ((Times[0][0].TimeOfDay >= MyStart2.TimeOfDay)
                     && (Times[0][0].TimeOfDay <= MyEnd2.TimeOfDay))
    
                     || ((Times[0][0].TimeOfDay >= MyStart3.TimeOfDay)
                     && (Times[0][0].TimeOfDay <= MyEnd3.TimeOfDay)))              
    ​

    Code of the lastest exit each trading day:
    Code:
    if (Times[0][0].TimeOfDay >= MyLastestExitTime.TimeOfDay)
                {
                    if (Position.MarketPosition == MarketPosition.Long)
                    {
                        ExitLong(Convert.ToInt32(ContractsLong), @"ExitLong", @"EntryLong");
                    }
                    if (Position.MarketPosition == MarketPosition.Short)
                    {
                        ExitShort(Convert.ToInt32(ContracsShort), @"ExitShort", @"EntryShort");
                    }        
                }​


    Thank you for helping me!

    Best regards,
    Rainbowtrader
    Last edited by Rainbowtrader; 08-07-2023, 03:57 AM.

    #2
    Hello Rainbowtrader,

    If you are needing the trading hours session end time of instruments, you can use SessionIterators (supplying the BarsArray[barsInProgressIndex]) for each instrument series to get the session close time of the trading hours of each instrument series added.



    With the conditions using datetime inputs in the comparisons, you can add your bool comparisons to those conditions.

    if ((Times[0][0].TimeOfDay >= MyStart1.TimeOfDay)
    && (Times[0][0].TimeOfDay <= MyEnd1.TimeOfDay) && MyBoolExit1 == true )

    Where you have inquiried:
    Now I need different general exit times, that means for each instrument, that the position ends definitly on its. That means: if an instrument is reaching the NEXT exit time, then the strategy will stop its.
    I'm not understanding what this means.

    You would like to submit an exit order on the 4th time comparison only?​
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea,

      the exit from a position at the 4. exit-time is working. That is the same like 300 or 3.000 or 6.000 seconds before market is closing NT8 will quit all my positions.

      What I want, is: there are 4 fix ending times while the day (including the last exit of the day). If a trade is starting, then this one has 1 or 2 or 3 or 4 exit times in its front for the rest of the day. How many, that is depending from the start time. Please take a look on the picture. Crude Oil.

      a) does the trade is starting between 00:00:00 (hours:minutes:seconds) and 07:59:59 then its stop is the exit at 8:00:00.
      b) for another trade in CL, that is starting between 8:00:01 and 14:24:59 its exit is at 14:25:00.
      c) for starting a trade between 14:25:01 and 15:24:59, the end for this position will be at 15:25:00.
      d) for starting a trade between 15:25:01 and 17:30:00, the end for this position will be at 21:45:00.

      (if I am wrong for one second in my example, it is for better understanding the principle)

      So I need a condition, where the start time from my trade is neccessarey for calculating / choosing its exit time. and this ist NOT the last exit of a day - IT IS THE NEXT exit time, that is possible for the position.

      Best regards,
      Rainbowtrader
      Last edited by Rainbowtrader; 08-24-2023, 01:21 AM.

      Comment


        #4
        Hello Rainbowtrader,

        You will likely want to save the entry datetime to a variable when the entry fills in OnOrderUpdate() or OnExecutionUpdate() (or the entry order to a variable and check the order.Time).

        If the order.Time (or saved time) is between the specified hours and the current time is between the specified hours, then trigger exit.

        Something like:
        myEntry1 = order;

        if (myEntry != null && myEntry.OrderState == OrderState.Filled && myEntry1.Time.TimeOfDay >= MyStart1.TimeOfDay && myEntry1.Time < MyEnd1.TimeOfDay && ToTime(Time[0]) >= 80000 && ToTime(Time[0]) < 80001)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          thank yo for the idea. I will test its tommorrow.

          Do you mean, that in case of my 4 different exits I will copy this 4 times and changing the different stop times in the code. Is that right?

          Best regards,
          Rainbowtrader

          Comment


            #6
            Hello Rainbowtrader,

            Yes, there would be a condition set for each different logic you want to have. Each entry order fill time range and corresponding current bar time to exit would be a separate condition set.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hello Chelsea,

              that sounds good. I will giving you a feedback in a short time :-)

              Thank you!

              Best regards,
              Rainbowtrader

              Comment


                #8
                Hello Chelsea,

                here are all parts, that I put in the strategy. Some errors. But let us check please the structure, for validation, that we are on the right way. I am thinking, the structure is not real good, because if I am having for example 4 entry time zones and 8 possible fix exit times that I can switch on and of, so that are in combination 32 "code blocks" by multiplying of both values.


                Public Class
                Code:
                        // **************** Experimental *******************
                        private DateTime            myStartPeriod1;
                        private DateTime            myEndPeriod1;
                        private DateTime            myStartPeriod2;
                        private DateTime            myEndPeriod2;
                        private DateTime            myOrderEntryTime;
                        private DateTime            myFixExitTime1;
                        private DateTime            myFixExitTime2;
                        private DateTime            myFixExitTime3;
                        //**************************************************  ​

                State.SetDefaults
                Code:
                //**************** Experimental ******************************
                                myStartPeriod1                                = DateTime.Parse("00:01", System.Globalization.CultureInfo.InvariantCulture);
                                myEndPeriod1                                 = DateTime.Parse("12:30", System.Globalization.CultureInfo.InvariantCulture);
                                myStartPeriod2                                = DateTime.Parse("13:30", System.Globalization.CultureInfo.InvariantCulture);
                                myEndPeriod2                                 = DateTime.Parse("17:30", System.Globalization.CultureInfo.InvariantCulture);
                                myFixExitTime1                                = DateTime.Parse("14:25", System.Globalization.CultureInfo.InvariantCulture);
                                myFixExitTime1                                = DateTime.Parse("15:25", System.Globalization.CultureInfo.InvariantCulture);
                                myFixExitTime3                                = DateTime.Parse("18:00", System.Globalization.CultureInfo.InvariantCulture);
                //**********************************************************​

                Entry Long
                Code:
                           //...
                            if (Close[0] > amaCoralFilter1.CoralFilter[0])                              
                            {
                                EnterLong(Convert.ToInt32(ContractsLong), @"EntryLong");
                
                                //********** Experimental ************************
                                myOrderEntryTime = Order;
                                //**********************************************​

                Exit general with fix exit times in a day
                Code:
                // ****************** Experimental **************************
                
                            // the FIRST entry time session from 00:01 - 12:30 (for example)
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod1.TimeOfDay    //00:01
                                && myOrderEntryTime.Time < myEndPeriod1.TimeOfDay                        //12:30
                                && ToTime(Time[0]) >= myFixExitTime1)                                                //14:25
                
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod1.TimeOfDay    //00:01
                                && myOrderEntryTime.Time < myEndPeriod1.TimeOfDay                        //12:30
                                && ToTime(Time[0]) >= myFixExitTime2)                                                //15:25
                
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod1.TimeOfDay    //00:01
                                && myOrderEntryTime.Time < myEndPeriod1.TimeOfDay                        //12:30
                                && ToTime(Time[0]) >= myFixExitTime3)                                                //18:00
                
                
                            // the SECOND entry time session from 13:30 - 17:30 (for example)
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod2.TimeOfDay    //13:30
                                && myOrderEntryTime.Time < myEndPeriod2.TimeOfDay                         //17:30
                                && ToTime(Time[0]) >= myFixExitTime1)                                                 //14:25
                
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod2.TimeOfDay    //13:30
                                && myOrderEntryTime.Time < myEndPeriod2.TimeOfDay                        //17:30
                                && ToTime(Time[0]) >= myFixExitTime2)                                                //15:25
                
                            if (myOrderEntryTime != null
                                && myOrderEntryTime.OrderState == OrderState.Filled
                                && myOrderEntryTime.Time.TimeOfDay >= myStartPeriod2.TimeOfDay    //13:30
                                && myOrderEntryTime.Time < myEndPeriod2.TimeOfDay                        //17:30
                                && ToTime(Time[0]) >= myFixExitTime3)                                                //18:00
                
                            // the THIRD entry time session... (for example)
                            // ...repeat 3 times...
                
                            // the FOURTH entry time session... (for example)
                            // ...repeat 3 times...
                
                            {
                                if (Position.MarketPosition == MarketPosition.Long)
                                {
                                    ExitLong(Convert.ToInt32(ContractsLong), @"ExitLong", @"EntryLong");
                                }
                                if (Position.MarketPosition == MarketPosition.Short)
                                {
                                    ExitShort(Convert.ToInt32(ContractsShort), @"ExitShort", @"EntryShort");
                                }        
                            }
                //*************************************************************

                Properties
                Code:
                //**************** Experimental***************************************
                        [NinjaScriptProperty]
                        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                        [Display(Name="Fix Exit Time 1", Description="Fix Exit Time 1", Order=101, GroupName="Fix Exit Times")]
                        public DateTime FixExitTime1
                        { get; set; }
                
                        [NinjaScriptProperty]
                        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                        [Display(Name="Fix Exit Time 2", Description="Fix Exit Time 2", Order=102, GroupName="Fix Exit Times")]
                        public DateTime FixExitTime2
                        { get; set; }
                
                        [NinjaScriptProperty]
                        [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                        [Display(Name="Fix Exit Time 3", Description="Fix Exit Time 3", Order=103, GroupName="Fix Exit Times")]
                        public DateTime FixExitTime3
                        { get; set; }
                
                        //**********************************************************************​
                Thank you for your help!

                Best regards,
                Rainbowtrader
                Last edited by Rainbowtrader; 08-08-2023, 08:41 AM.

                Comment


                  #9
                  Hello Chelsea,

                  after starting an order by the system...

                  Code:
                  private DateTime                myOrderEntryTime;
                  Code:
                  EnterLong(Convert.ToInt32(ContractsLong), @"EntryLong");
                  
                  ... I want, that NT8 is writing the start time in the variable myOrderEntryTime
                  Please giving me the correct code line for this, because I cant find this simple information.

                  Thank you!

                  Best regards,
                  Rainbowtrader
                  Last edited by Rainbowtrader; 08-09-2023, 09:06 AM.

                  Comment


                    #10
                    Hello Rainbowtrader,

                    The exit conditions in OnBarUpdate() appear correct.

                    For the time of the order, this would be supplied from the order object parameter in OnOrderUpdate().

                    myOrderEntryTime = order.Time;
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Click image for larger version  Name:	order_error.png Views:	0 Size:	17.8 KB ID:	1263816
                      Hi Chelsea,

                      here is the Screenshot from the error:

                      the name "order" does not exist in the current context



                      Click image for larger version  Name:	order_error2.png Views:	0 Size:	20.0 KB ID:	1263818
                      And here is the second screenshot with writing "Order" instead "order":

                      An object reference is required for the non-static field, method or property 'NinjaTrader.Cbi.Order.Time.get'.


                      PS: I had forgotten to change from "OrderEinstiegZeit" (my variable name, that I am using) to "myOrderEntryTime" for the example. But I think, you had understooden this. Sorry
                      Attached Files
                      Last edited by Rainbowtrader; 08-09-2023, 11:27 AM.

                      Comment


                        #12
                        Hello Rainbowtrader,

                        My guess is that you have not put this code in OnOrderUpdate() as directed.


                        What override method was the code I suggested placed in?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello Chelsea,

                          you are absolutly right - I did no used OnOrderUpdate or OnExcecutionUpdate - because the Strategy Builder has not generated code for this. All this things are placed in OnBarUpdate.

                          Now I have to read the manuals and searching for the right examples for changing my structure. Its completly new for me.

                          Best regards,
                          Rainbowtrader

                          Comment


                            #14
                            Hello Chelsea,

                            sorry for the long break, but now I am back.

                            I built today an example script only with the minimum code for the example for you.
                            It has an problem for compiling, because I am not sure, what methods/variables/declarations in my case I had to fill in the OnExcecutionUpdate("...")

                            In the if-statement I had set only the minimum: a) a bool for activating the fix time, b) the stop time and c) a bit later for having a period and not a time stamp.

                            So in this script I am having two stop times for running orders.
                            The script has to stop each order, that is running, if its hits one of both time periods (if both are valid = activated with "true" in the parameter list).
                            It is fully not important, what time an order has started.
                            If it is reaching in my case 12:28 o'clock or 15:55 o'clock, then exit.

                            You would make me happy if you could fix this little script for me.
                            I commented out the code, so I could compile the script.
                            You can see this section of code between lines 102 to 117 (121).

                            Best regards,
                            Andreas

                            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 SampleDifferentFixedExitTimes : Strategy
                                {
                                    // Variables
                                    private SMA SMA1;                    
                                    private int contractsLong                    = 1;
                                    private int contractsShort                    = 1;
                                    private bool myBoolExit1                     = true;
                                    private bool myBoolExit2                     = true;​
                            
                                    protected override void OnStateChange()
                                    {
                                        if (State == State.SetDefaults)
                                        {
                                            Description                                    = @"Some different exit times, for that each trade will canceled by the strategy. For example 14:30 Central European Time in Germany, that represents the news time 8:30 Eastern Daylight Time in New York";
                                            Name                                        = "SampleDifferentFixedExitTimes";
                                            Calculate                                    = Calculate.OnBarClose;
                                            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;
                                            IsInstantiatedOnEachOptimizationIteration    = true;    
                            
                                            // Fixed trade closing times periods - regardless of the time at which an order was started
                                            FixExit1Start                                = DateTime.Parse("12:28", System.Globalization.CultureInfo.InvariantCulture);
                                            FixExit1End                                    = DateTime.Parse("12:30", System.Globalization.CultureInfo.InvariantCulture);
                                            FixExit2Start                                = DateTime.Parse("15:55", System.Globalization.CultureInfo.InvariantCulture);
                                            FixExit2End                                    = DateTime.Parse("15:58", System.Globalization.CultureInfo.InvariantCulture);                
                                        }
                                        else if (State == State.Configure)
                                        {
                                        }
                            
                                        else if (State == State.DataLoaded)
                                        {                
                                            SMA1                = SMA(Close, 14);
                                            SMA1.Plots[0].Brush = Brushes.Red;
                                            AddChartIndicator(SMA1);
                                            SetTrailStop(@"EntryLong", CalculationMode.Ticks, 50, false);
                                            SetTrailStop(@"EntryShort", CalculationMode.Ticks, 50, false);
                                        }
                                    }
                            
                                    protected override void OnBarUpdate()
                                    {
                                        if (BarsInProgress != 0)
                                            return;
                            
                                        if (CurrentBars[0] < 1)
                                            return;
                            
                                         // Entry Long
                                        if (CrossAbove(Close, SMA1, 1))
                                        {
                                            EnterLong(Convert.ToInt32(DefaultQuantity), @"EntryLong");
                                        }
                            
                                         // Entry Short
                                        if (CrossBelow(Close, SMA1, 1))
                                        {
                                            EnterShort(Convert.ToInt32(DefaultQuantity), @"EntryShort");
                                        }            
                                    }
                            
                                    // Stopps, Trailings & Take Profits
                            /*        protected override void OnExecutionUpdate(Execution execution, int contractsLong, int contractsShort, MarketPosition marketPosition, DateTime time)
                                    {                                
                                        // 1. Fix Exit Time: 12:28 o'clock Central European Time in Germany
                                        if (myBoolExit1 == true && Times[0][0].TimeOfDay >= FixExit1Start.TimeOfDay && Times[0][0].TimeOfDay <= FixExit1End.TimeOfDay)
                                        {
                                            if (Position.MarketPosition == MarketPosition.Long)
                                            {
                                                ExitLong(Convert.ToInt32(contractsLong), @"ExitLong", @"EntryLong");
                                            }
                                            if (Position.MarketPosition == MarketPosition.Short)
                                            {
                                                ExitShort(Convert.ToInt32(contractsShort), @"ExitShort", @"EntryShort");
                                            }        
                                        }​            
                                    }
                            */        
                                    // 2. Fix Exit Time: 15:55 o'clock Central European Time in Germany
                                    //...
                                    //...
                                    //...
                            
                            
                                    #region Properties        
                                    [NinjaScriptProperty]
                                    [Display(ResourceType = typeof(Custom.Resource), Name = "Fix Exit Period 1", Description = "Fix Exit Period 1", GroupName = "Activate Closing Times", Order = 1)]
                                       public bool MyBoolExit1
                                    {
                                        get { return myBoolExit1; }
                                        set { myBoolExit1 = value; }
                                    }    
                            
                                    [NinjaScriptProperty]
                                    [Display(ResourceType = typeof(Custom.Resource), Name = "Fix Exit Period 2", Description = "Fix Exit Period 2", GroupName = "Activate Closing Times", Order = 2)]
                                       public bool MyBoolExit2
                                    {
                                        get { return myBoolExit2; }
                                        set { myBoolExit2 = value; }
                                    }
                            
                                    [NinjaScriptProperty]
                                    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                                    [Display(Name="Fix Exit Period 1 Start", Order=5, GroupName="Trade Closing Times")]
                                    public DateTime FixExit1Start
                                    { get; set; }
                            
                                    [NinjaScriptProperty]
                                    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                                    [Display(Name="Fix Exit Period 1 End", Order=6, GroupName="Trade Closing Times")]
                                    public DateTime FixExit1End
                                    { get; set; }
                            
                                    [NinjaScriptProperty]
                                    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                                    [Display(Name="Fix Exit Period 2 Start", Order=7, GroupName="Trade Closing Times")]
                                    public DateTime FixExit2Start
                                    { get; set; }
                            
                                    [NinjaScriptProperty]
                                    [PropertyEditor("NinjaTrader.Gui.Tools.TimeEditorKey")]
                                    [Display(Name="Fix Exit Period 2 End", Order=8, GroupName="Trade Closing Times")]
                                    public DateTime FixExit2End
                                    { get; set; }
                                    #endregion
                                }
                            }
                            Attached Files

                            Comment


                              #15
                              Hello Rainbowtrader,

                              In your code you have not properly declared the OnExecutionUpdate override.

                              You have:
                              protected override void OnExecutionUpdate(Execution execution, int contractsLong, int contractsShort, MarketPosition marketPosition, DateTime time)

                              This is not the method signature for OnExecutionUpdate(). Copy and paste the method signature from the help guide:
                              Code:
                              protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by NullPointStrategies, Yesterday, 05:17 AM
                              0 responses
                              56 views
                              0 likes
                              Last Post NullPointStrategies  
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              132 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              73 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              45 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              49 views
                              0 likes
                              Last Post TheRealMorford  
                              Working...
                              X