Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Max. Consecutive Losers and Winners Switched in Monte Carlo Drop Down

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

    Max. Consecutive Losers and Winners Switched in Monte Carlo Drop Down

    I suspect this is already on your bug list.

    I'm using:
    NT8
    version 8.0.18.0 64-bit

    If you select "Max. consecutive losers" in the Graph dropdown, it actually displays the probability graph for the winners.

    And then when you select "Max. consecutive winners" it displays the probability graph for the losers.

    This might be a little hard to test for because you need a sample strategy that has a noticeable difference between the two metrics or the ability to compare to a known distribution. I have my own Monte Carlo code which makes it pretty obvious.

    The following are for a losing strategy with a lot of losing trades. The consecutive losers should definitely outpace the winners.

    The left graph is my own MonteCarlo code for comparison.

    Capture_Losers.JPG
    Capture_Winners.JPG
    Steve L
    NinjaTrader Ecosystem Vendor - Ninja Mastery

    #2
    Hello Steve L,

    Thank you for the post.

    I just wanted to provide a quick note to let you know that I will review this. Once I have more details I will reply back here.

    Comment


      #3
      Hello Steve L,

      After further review of the information I believe that we would need a more specific test case here. Are you able to create a sample script or use one of the existing sample strategies to demonstrate the values you described in some way? We also won't be able to use the custom tool you created as a comparison for this, the analyzers code is not exposed for us to compare with your code to know if that should be identical. Do you have some other way to demonstrate this without using an external tool? If you have some means to reproduce this using included tools/a custom script, we can pass that to development for further review.

      I look forward to being of further assistance.




      Comment


        #4
        I'll see what I can come up with.
        Steve L
        NinjaTrader Ecosystem Vendor - Ninja Mastery

        Comment


          #5
          -- Deleted. Duplicate posts. ---
          Last edited by Steve L; 09-13-2019, 01:50 PM.
          Steve L
          NinjaTrader Ecosystem Vendor - Ninja Mastery

          Comment


            #6
            The easiest way to demonstrate the issue is with a strategy of all winners or all losers.

            The below strategy will produce a result with either all winners or all losers depending on the parameter setting.

            It does this by looking into the future.

            For ES ##-## from 1/1/2014 to 1/1/2019 it produces 451 winning trades when set to WinnersOnly.

            Therefore we would expect there to be 0 entries in the MonteCarlo MaxConsecutiveLosers graph...cause there are no losers.

            And we would expect one entry with a value of 451 in the MaxConsecutiveWinners graph.

            However, this is reversed.

            MC_StrategyAnalyzer_AllWinners.png

            MC_StrategyAnalyzer_AllWinners_MaxConsLosers.png

            MC_StrategyAnalyzer_AllWinners_MaxConsWinners.png

            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.Test
            {
                public enum Mode
                {
                    WinnersOnly,
                    LosersOnly
                }
            
                public class MonteCarloMaxConsTest : Strategy
                {
            
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description                                    = @"Enter the description for your new custom Strategy here.";
                            Name                                        = "MonteCarloMaxConsTest";
                            Calculate                                    = Calculate.OnBarClose;
                            EntriesPerDirection                            = 1;
                            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;
            
                            Mode = Mode.WinnersOnly;
                        }
                        else if (State == State.Configure)
                        {
                        }
                    }
            
                    protected override void OnBarUpdate()
                    {
                        if (CurrentBar < BarsRequiredToTrade) { return; }
            
                        bool isFlat = Position.MarketPosition == MarketPosition.Flat;
                        if (isFlat && CurrentBar < Bars.Count - 2)
                        {
                            // Entry
            
                            double open1 = Bars.GetOpen(CurrentBar + 1);
                            double open2 = Bars.GetOpen(CurrentBar + 2);
                            if (Mode == Mode.LosersOnly && open2 < open1)
                            {
                                EnterLong();
                            }
                            else if (Mode == Mode.WinnersOnly && open2 > open1)
                            {
                                EnterLong();
                            }
                        }
                        else
                        {
                            // Exit
                            if (!isFlat)
                            {
                                ExitLong();
                            }
                        }
            
            
                    }
            
                    [NinjaScriptProperty]
                    [Display(ResourceType = typeof(Custom.Resource), Name = "Trade Type", GroupName = "Parameters", Order = 0)]
                    public Mode Mode
                    { get; set; }
            
                }
            }
            Steve L
            NinjaTrader Ecosystem Vendor - Ninja Mastery

            Comment


              #7
              I submitted a reply and it came back as "pending." I don't know what that means. Does that mean it's posted but in review? If you did not receive a post, please let me know and I'll try again.
              Steve L
              NinjaTrader Ecosystem Vendor - Ninja Mastery

              Comment


                #8
                Hello Steve L,

                Thank you for the additional details, I provided this to development and now have a tracking id for this item: NTEIGHT-14051


                I look forward to being of further assistance.
                Last edited by NinjaTrader_Jesse; 09-27-2019, 11:33 AM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                578 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                334 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                553 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                551 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X