Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parameter programming

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

    Parameter programming

    I have been adding parameters to code that was started with the Wizard and unlocked. It appears to kind of work, but there are some strange aspects. In the "Parameters Region" I copied other parameter code, ie:

    [Description("ATR bars")]
    [GridCategory("Parameters")]
    public int Atr_bars
    {
    get { return atr_bars; }
    set { atr_bars = value; }
    }

    I also added private initialization for the new parameter following the example:
    private int atr_bars = 200; // Default atr bars

    These show up when a add the strategy to the chart, and they take the parameter values I enter, however, there are some anomalies. When there was a Math.Min(10, value) in the code, then it behaved as though it was a Math.Max(10, value). It would basically fix values for parameters but not to what I expected. So I took out all Max and Min calls and then it at least accepted my inputs. Is there something else hidden that does a parameter bounds check?

    Also, it appears whenever I enable the strategy that the parameters are then grayed out. If I disable the strategy, thinking I would then be able to change parameters, then they stay grayed out. I have to remove and add a new version of the strategy. Is that expected behavior?

    #2
    Hello tradetree,

    There is nothing hidden with Math.Min() and Math.Max(). I tend to think of Math.Min as a ceiling and Math.Max as a floor. Share the expression you're having trouble with and we can provide more details on expected behavior.

    Yes, you should be able to edit the parameteres after disabling the strategy. Can you please try this with SampleMACrossOver and let us know your results. If you're unable to adjust these parameters, walk us through the steps you're using to apply, enable, and disable the strategy.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      I guess I don't have a good reference for language details. What is the best "wiki" like site? I looked at "Help" in NT and that only has basic information. Where do I get a language reference that has the definition of things like Math.Min and Math.Max?

      I thought these two API calls did the opposite. I've been using Math.Abs and that works just like I expect. But Math.Min I'd expect to be the "Minimum" of the two values, which would be a floor not a ceiling. Anyway, I think you are right.

      Also, I think I figured out that once I add a strategy and enable it, to change a parameter it is not enough to disable the strategy, you have to close and then return to the "Strategies" box because the disable has not yet taken effect. Seems fine now that I'm doing that.

      Now I have a problem with simulated positions. In my strategy I call EnterLong(DefaultQuantity, ""); and ExitLong("", "");
      I use "Print" to print when and at what price I am entering and exiting. So for example, here is an output:
      Enter Long: 3/12/2009 3:30:00 PM, 715.5, 2112
      Exit Long: 5/13/2009 1:30:00 PM, 853.25, 2390

      Well on the chart it shows my entry and exit one or two bars apart, in other words like it sold the same day as it bought. At first I thought maybe I had a stop loss in there, but it does this even for a profit. How can I track down what is going on with the transactions?

      Comment


        #4
        I also have parameter value problems in the optimizer. It says "Error on running optimizer. Parameter can not be null. Parameter name: value." I checked and all my parameters have values. I also ran a Backtest, and that works fine, which also uses the parameters. (Please don't miss my post #3 below, that is still relevant).
        Last edited by tradetree; 09-28-2010, 08:40 PM.

        Comment


          #5
          Math.Min is indeed the lower of two values. When you use it the input context, this has the effect of setting the ceiling for the two values.

          Example:
          Math.Min(3, value);

          If you input 10, it would select 3 instead.

          Our help guide focus is NinjaScript - methods and properties specific to our usage. It seems you are interested more in general C#.

          The official MS docs are good:
          http://msdn.microsoft.com/en-us/library/ms228593

          If you're looking for additional, there are many C# and .net resources available on the web.

          I'm not sure about your print statements and the connection between actual orders placed. The exact fill price of an order is available to you if that's what you're looking for. If you're just printing the Time in the same block that places the orders, this doesn't take into account any of the order management.

          If you're looking to expose information regarding an order, please look into IOrders and IExecution.
          http://www.ninjatrader-support.com/H...V6/IOrder.html
          http://www.ninjatrader-support.com/H...Execution.html
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks for those answers. I know I'm jumbling together several topics. What I'm focusing on right now is the order handling and back testing. I have a strategy which uses simple calls "EnterLong" and ExitLong." These calls produce simulated buy/sell orders when I run my strategy on ^SP500, the index data on the S&P500. This is just daily bars from YAHOO. If I try to run the strategy on 15min or 1 min ES data from Vision Financial in "SIM101" simulation, then the orders appear to be closed out at the end of each day. So if I hit a "EnterLong" on any particular day then by the end of that same day the order is exited. Is there some setting that says, "Close out all open orders at the end of each day?"

            Comment


              #7
              Yes, this is controlled with ExitOnClose setting. This setting is available anytime you run the strategy.
              http://www.ninjatrader-support.com/H...romAChart.html
              Ryan M.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by MonteK, Yesterday, 09:31 PM
              0 responses
              26 views
              0 likes
              Last Post MonteK
              by MonteK
               
              Started by nkhoi, Yesterday, 09:27 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by SuperDude123, Yesterday, 03:52 PM
              4 responses
              26 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by ErikY, Yesterday, 01:16 PM
              1 response
              25 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by BullyWig Trader, Yesterday, 12:42 PM
              1 response
              17 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X