Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator within an indicator not updating

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

    #16
    darckeen, the simple looking code example in my last post hides some remarkable functionality: The Indicator-baseclass creates an instance for every combination of the parameters. Therefore it maintains an uptodate BAMTest1() instance for every combination and they are all linked to the regular event handling. If I understand your last post correctly, usage of this approach could save you a lot of effort.

    Regards
    Ralph

    Comment


      #17
      Thanks alot for the help Ralph, this code works as intended.

      Code:
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1 : Indicator[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] sum;[/SIZE][/FONT]
       
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize() {[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]PriceTypeSupported = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate() { sum += Value[[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]]; }[/SIZE][/FONT]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] GetSum() { Update(); [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] sum; }[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT]
      [FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]public [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest2 : Indicator[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]{[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]private[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] BAMTest1 testhigh, testlow;[/SIZE][/FONT]
       
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] Initialize() {[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]CalculateOnBarClose = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]PriceTypeSupported = [/FONT][/SIZE][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]testhigh = BAMTest1(High);[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]testlow = BAMTest1(Low);[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]override [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] OnBarUpdate() {[/SIZE][/FONT]
      [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] (CurrentBar==Bars.Count-[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]) { Print(testhigh.GetSum() + [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]" "[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2] + testlow.GetSum()); }[/SIZE][/FONT]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [SIZE=2][FONT=Courier New]}[/FONT][/SIZE]
      [/SIZE][/FONT]
      Last edited by darckeen; 04-11-2009, 12:16 PM.

      Comment


        #18
        Hi Ralph & Darckeen,

        Interesting thread you got going here, quite informative.

        I'm experiencing the same problem, yet not with an indicator but with an strategy. So far, I've haven't had much success with calling the Update() method, mainly because I'm not allowed to call this in the Strategy class, and have not found a workaround for it.

        Do you guys have an idea as how to access price data outside the OnBarUpdate() method en inside an Strategy base class?

        Here's what I have so far:

        In the strategy file:
        PHP Code:
        private MyMethods mymeth;
        
        protected void UpdateAccountValue()
        {
            mymeth = MyMethods(Open);
            openPrice = mymeth.GetOpenForStrategy();
        } 
        
        and in the MyMethods.cs file:
        PHP Code:
        public class MyMethods : Indicator
        {
            private double openForMoneyManagement;
        
            protected override void OnBarUpdate()
            {
                openForMoneyManagement = Value[0];
            }
        
            public double GetOpenForStrategy()
            {
                Update();
                return openForMoneyManagement;
            }
        } 
        
        Any idea where I'm going wrong?

        Regards,

        Comment


          #19
          Does dataseries "Value" contain valid data? If yes, then I would expect that your code is working.

          Regards
          Ralph

          Comment


            #20
            Originally posted by Ralph View Post
            Does dataseries "Value" contain valid data? If yes, then I would expect that your code is working.

            Regards
            Ralph
            Thanks for your comment Ralph, it gave me some good ideas to pursue, but sadly none of which gave an solution. I'm wondering if the Update() method even works with an strategy, because when I debug it, the debugger always "jumps over" the Update() method, and never 'into' the method. So, it just seems like an empty statement.

            This seems to be confirmed in the NinjaTrader.Indicator.IndicatorBase.cs file, where the Update() method originates, and where it is defined as
            Code:
            public void Update();
            Do I need to manually override the Update() method? According to the Update() helppage, that wouldn't be needed. Is the Update() method perhaps changed/depreciated with the latest NT version? Does it still work for you guys?

            Btw, if I give the variable which should contain the current Open price an fixed value, for example 12, the variable still doesn't get updated:
            Code:
            protected override void OnBarUpdate()
            {
                 openForMoneyManagement = 12;
            }
            
            public double GetOpenForStrategy()
            {
                Update();
                return openForMoneyManagement;
            }
            Who can tell me why NinjaTrader jumps over the Update() statement in the above example?

            Regards,

            Comment


              #21
              openForMoneyManagement is a "simple" double value. If you set it to 12, then GetOpenForStrategy() will return 12 unless you change it. Update() syncronises the indicator's internal state, so you are guaranteed to get correct indicator-generated values (i.e. Close[0]). Your double variable is not affected by Update(). Update() is probably code-protected and you will not be able to see its content.

              Regards
              Ralph

              Comment


                #22
                Originally posted by Ralph View Post
                openForMoneyManagement is a "simple" double value. If you set it to 12, then GetOpenForStrategy() will return 12 unless you change it. Update() syncronises the indicator's internal state, so you are guaranteed to get correct indicator-generated values (i.e. Close[0]). Your double variable is not affected by Update(). Update() is probably code-protected and you will not be able to see its content.

                Regards
                Ralph
                You're right Ralph, the "simple" double value will not be updated by Update(). Reading back my previous post, I see that I made an typo: I said that, when I gave openForMoneyManagement a fixed value of 12, that it didn't got updated (which is obvious, because it's fixed). I meant to say that: the value doesn't get returned (i.e. it returns 0.0). (Btw, thanks already for your help Ralph, I already learned a lot ).

                So, it looks to me that, even though the GetOpen() method returns the openForMM variable, the Update() never enters the OnBarUpdate method, the part in which openForMM is assigned it's fixed value of 12.

                Btw, I found this example. I've implemented that, and it works, as long as I call the variable which needs the Update() method to get updated directly from the Strategy file. Yet when I call it from another place (which is the goal) it doesn't work.

                Taking that example as starting point, here's what I have:
                PHP Code:
                // in TestStrategy.cs
                public class TestStrategy : Strategy
                {
                    private double testAttempt1, testAttempt2;
                    private MoneyManagement mm = new MoneyManagement();
                    
                    protected override void OnBarUpdate()
                    {
                        testAttempt1 = mm.GetOpen();            // delegating to MoneyManagement; doesn't work
                
                        testAttempt2 = MyMethods().MyExposedVariable;    // does work
                    }
                
                } 
                
                PHP Code:
                // In MoneyManagement.cs
                public class MoneyManagement : Strategy
                {
                    public double GetOpen()
                    {
                        return MyMethods().MyExposedVariable;
                    }
                } 
                
                PHP Code:
                // in MyMethods.cs
                public class MyMethods : Indicator
                {
                    private double myExposedVariable;
                    
                    protected override void OnBarUpdate()
                    {
                        myExposedVariable = Open[0];
                    }
                            
                    [Browsable(false)]
                    [XmlIgnore()]
                    public double MyExposedVariable
                    {
                        get { Update(); return myExposedVariable; }
                    }
                } 
                
                The goal of this is to give the Open price to the MoneyManagement method, so that it is capable of calculating the various metrics. I've chosen to (try to) incorporated this in an separate Strategy file, because the money management calculations are quite long and the UserDefinedMethod.cs is already full enough to be comprehensive. If I can use this goal on another way, I'm all ears.

                The above code segments look quite to me, and I don't get any errors or exceptions. Yet, the value returns is 0.0. Who can enlighten me?

                Regards,

                Comment


                  #23
                  I think you make a conceptual mistake, J_o_s. You design a strategy MoneyManagement and you instantiate it by your own (mm = new MoneyManagement()). I never do that because how you do know that this strategy instance (mm) is correctly scheduled by NT?

                  It is a good approach to design own classes to hide complex problems like money managment. But I would not derive it from strategy. And I would instantiate the indicator MyMethods (implementation seems to be correct) directly in TestStrategy, that will work correctly, something like:

                  private indicator indi;
                  protected overrride void OnStartUp() {indi = MyMethods();}

                  And if you like to, you then could pass the indicator reference "indi" over to MoneyManagement() during construction.

                  Regards
                  Ralph

                  Comment


                    #24
                    Thanks for your suggestions Ralph, I guess you're right track, though I didn't had enough time to test / implement them all. Sadly, I need to work on other projects this week so my NinjaTrader programming time is limited. If you don't mind, I'll come back to you next week.

                    Thanks,

                    Comment


                      #25
                      Originally posted by Ralph View Post
                      I think you make a conceptual mistake, J_o_s. You design a strategy MoneyManagement and you instantiate it by your own (mm = new MoneyManagement()). I never do that because how you do know that this strategy instance (mm) is correctly scheduled by NT?
                      Interesting point Ralph, but I'm afraid I do not follow you completely, because I don't see a way to access a custom class without creating a new instance. Or are we talking about different things here?

                      Originally posted by Ralph View Post
                      It is a good approach to design own classes to hide complex problems like money managment. But I would not derive it from strategy. And I would instantiate the indicator MyMethods (implementation seems to be correct) directly in TestStrategy, that will work correctly, something like:

                      private indicator indi;
                      protected overrride void OnStartUp() {indi = MyMethods();}

                      And if you like to, you then could pass the indicator reference "indi" over to MoneyManagement() during construction.

                      Regards
                      Ralph
                      That's a good idea, to instantiate the MyMethods directly in the TestStrategy, and then passing it to the MoneyManagement class. When you say 'during construction', do you mean the instantiating in the OnBarUpdate() method or in the variables section directly below the 'public class TestStrategy'? I'm asking because I did succeed in passing 'indi' to the MoneyManagement class during the OnBarUpdate(), but failed to do so when passing 'indi' to the initial instantiation in the variables section. I'm wondering if this is good, efficient coding or that I'm better suited to try to make your suggestion work.

                      Here's what I have so far, which at this moment is working (Thanks again Ralph!)
                      PHP Code:
                      // TestStrategy
                      public class TestStrategy : Strategy
                      {
                          private static MyMethods indi;
                          private static MM3FixedPercentage mm3FP = new MM3FixedPercentage(10000, 2.3f);
                          
                          protected override void OnBarUpdate()
                          {
                              mm3FP.GetPositionSize(indi);
                          }
                          
                          protected override void OnStartUp()
                          {
                              indi = MyMethods();
                          }
                      } 
                      
                      PHP Code:
                      public class MM3FixedPercentage : MM3
                      {
                          private float percentRiskPerTrade;
                      
                          public MM3FixedPercentage(double accountValueStart, float percentRiskPerTrade)
                              : base(accountValueStart)
                          {
                              this.percentRiskPerTrade = percentRiskPerTrade;
                          }
                      
                          public void GetPositionSize(IndicatorBase indi)
                          {
                              openPriceVariable = indi.Open[0];
                      
                              Print("percentageRisk= " + percentRiskPerTrade + ", and openPriceVariable = " + openPriceVariable);
                          }
                      } 
                      
                      Though I'm not sure if the base class (MM3 in the code above) is a good use of inheritance. Got more exploration to do

                      Edit:
                      Though the above example does succeed in displaying the open and other (price related) metrics, I can't access the performance of the strategy itself in the MoneyManagement class. So for example, the CumProfit can not be used (it prints 0), what off course is a big hindrance for any money management calculation.

                      For example:
                      PHP Code:
                      // In money management class
                      public void GetPositionSize(IndicatorBase indi, StrategyBase strat)
                      {
                          Print("Cumprofit: " + strat.Performance.AllTrades.TradesPerformance.Currency.CumProfit);
                      }
                      
                      // in TestStrategy
                      private static SampleStrategyForTesting strat;
                      
                      protected override void OnBarUpdate()
                      {
                          mm3FP.GetPositionSize(indi, strat);
                      } 
                      
                      ..doesn't work, nor does setting the 'strat' variable to the strategy in the OnStartUp() method. Is it really this difficult to implement an simple idea or am I missing something very obvious?

                      Edit 2: While it is possible to pass the 'cumProfit' variable into the MoneyManagement method, and so calculate the cumulative profit, these values are (way) off due to Cumprofit lagging behind. I'd love to hear any suggestions as how to use cumprofit in MoneyManagement calculations.

                      Regards,
                      Last edited by J_o_s; 02-28-2011, 05:27 AM. Reason: typo's & provided more info

                      Comment


                        #26
                        To use a customised class you always need to instantiate it. But I am personally do not instantiate a customised indicator or strategy myself.
                        With 'during construction' I ment the construction of class MoneyManagement. If you want to pass the reference of an instance to another one during construction, then you need to do that in OnStartUp().
                        I don't know if it is enough to pass strat as StrategyBase or if you have to use the customised instance instead (SampleStrategyForTesting), because there is a reason why you defined such customised strategy.

                        Regards
                        Ralph

                        Comment


                          #27
                          Originally posted by Ralph View Post
                          If you want to pass the reference of an instance to another one during construction, then you need to do that in OnStartUp().
                          Thanks for sharing Ralph, I didn't know about that.

                          Passing as StrategyBase or SampleStrategyForTesting both doesn't work, but now I have a workaround in which I pass these values into the method (instead of the MoneyManagement calculating or accessing them):
                          PHP Code:
                          mm.GetPositionSize(indi, cumProfit, stopLossValue); 
                          
                          Not as pretty or easy to use as I would like , but it works, and my skills aren't up to the task I sense.

                          Thanks once again for your help Ralph,

                          Regards,

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          576 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