• 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

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.

    Click image for larger version

Name:	Capture_Losers.JPG
Views:	1
Size:	209.0 KB
ID:	1069451
    Click image for larger version

Name:	Capture_Winners.JPG
Views:	1
Size:	212.8 KB
ID:	1069452
    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.
    JesseNinjaTrader Customer Service

    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.




      JesseNinjaTrader Customer Service

      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.

            Click image for larger version

Name:	MC_StrategyAnalyzer_AllWinners.png
Views:	1
Size:	69.0 KB
ID:	1070804

            Click image for larger version

Name:	MC_StrategyAnalyzer_AllWinners_MaxConsLosers.png
Views:	1
Size:	61.0 KB
ID:	1070805

            Click image for larger version

Name:	MC_StrategyAnalyzer_AllWinners_MaxConsWinners.png
Views:	1
Size:	60.4 KB
ID:	1070806

            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 will review this and see what I can provide to development for review. Pending means your content was posted but is pending approval to be viewed.

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

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by RandanAL, Today, 09:05 AM
                0 responses
                2 views
                0 likes
                Last Post RandanAL  
                Started by cstern71, 09-02-2019, 10:30 AM
                4 responses
                59 views
                0 likes
                Last Post Lancer
                by Lancer
                 
                Started by Hanstanz, Today, 04:44 AM
                0 responses
                10 views
                0 likes
                Last Post Hanstanz  
                Started by juniortut, Today, 04:38 AM
                0 responses
                5 views
                0 likes
                Last Post juniortut  
                Started by rojiinko, Today, 03:58 AM
                0 responses
                5 views
                0 likes
                Last Post rojiinko  
                Working...
                X