Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Difficulty with making strategy functional when not using Wizard

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

    Difficulty with making strategy functional when not using Wizard

    Hi,

    I am a very amateur coder, which is how all these posts usually start. I am having trouble making my strategy "functional". What I mean is that when I DON'T use the wizard to code the strategy, I can't get the initialization inputs to come up.

    For example, say I want to backtest my new strategy. When I click backtest, then click on my Strategy, its all blank underneath. But if I click on the ATMstrategies or one of my wizard generated ones, input options come up immediately.

    I thought maybe it was something I was coding wrong, so I copied a simple SMA cross strategy & compiled it manually, same thing, no inputs. The strategy I coded on my own debugged fine & compiled fine, but if I don't use the wizard to 'finish' it, it seems like its not reading it like a strategy. Not sure what I am missing. Any help is greatly appreciated. Thank you!

    Tom

    #2
    Hello Tom,

    Thanks for your post and welcome to the forums!

    I suspect what you are missing is the code that would provide the input for the user defined variables, typically this would be located in the section between #region Properties and #endregion.

    To illustrate this, open the strategy SampleMACrossOver that came with your Ninjatrader. Expand out the section "Properties" (Properties will show as slightly gray and will have a box around it and if you look next to the line numbers you will see a small "+" that you can click on to expand the "properties" view.

    In the SampleMACrossOver properties you will see "Public int Fast" and "Public int Slow", these ("Fast" and "Slow") are the variables you would see when you go to backtest or when you apply the strategy. Note that below each of these you will see the private variables "fast" and "slow", this is how the local variables are related to the public variables.

    As a suggestion, when you decide to create a strategy is to use the wizard if only to create the user defined inputs, once you have created the user defined variables then click on the wizard button to unlock the code. At that point you would have all the correct NinjaScript structure and the public variables set up and it would then be a matter of adding your logic in the OnBarUpdate section.

    I hope this helps, please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thank you for the reply. I checked Properties and it seems to match the Variables region. None of these variables come up when I try to start the strategy or backtest it?? Any other suggestions? I attached a screenshot of what it looks like when I pull up the strategy. Here is a the code of Properties below:

      Code:
      #region Properties
              [Description("")]
              [GridCategory("Parameters")]
              public int StartingBalance
              {
                  get { return startingBalance; }
                  set { startingBalance = Math.Max(1, value); }
              }
      
              [Description("(Ticks)")]
              [GridCategory("Parameters")]
              public int ReversalAmount
              {
                  get { return reversalAmount; }
                  set { reversalAmount = Math.Max(1, value); }
              }
      
              [Description("(Ticks)")]
              [GridCategory("Parameters")]
              public int ReversalLimit
              {
                  get { return reversalLimit; }
                  set { reversalLimit = Math.Max(1, value); }
              }
      
              [Description("")]
              [GridCategory("Parameters")]
              public int ReversalMultiplier
              {
                  get { return reversalMultiplier; }
                  set { reversalMultiplier = Math.Max(1, value); }
              }
      
              [Description("")]
              [GridCategory("Parameters")]
              public int InitialContracts
              {
                  get { return initialContracts; }
                  set { initialContracts = Math.Max(1, value); }
              }
      		
      		[Description("")]
              [GridCategory("Parameters")]
              public int ReversalCounter
              {
                  get { return reversalCounter; }
                  set { reversalCounter = Math.Max(1, value); }
              }
              #endregion
      Thanks for your help!!

      -Tom
      Attached Files

      Comment


        #4
        Never Mind

        I checked the log and saw that I had an error in the Initialize method. That fixed the problem. Sorry for the trouble of reading this. Thanks again!

        -Tom

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by naanku, Today, 07:25 PM
        0 responses
        6 views
        0 likes
        Last Post naanku
        by naanku
         
        Started by milfocs, Today, 07:23 PM
        0 responses
        5 views
        0 likes
        Last Post milfocs
        by milfocs
         
        Started by PaulMohn, Today, 06:59 PM
        0 responses
        7 views
        0 likes
        Last Post PaulMohn  
        Started by bortz, 11-06-2023, 08:04 AM
        48 responses
        1,753 views
        0 likes
        Last Post carnitron  
        Started by Jonker, 04-27-2024, 01:19 PM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X