Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization with multitime frame strategy

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

    Optimization with multitime frame strategy

    Hallo,

    I have very simple multi time frame strategy.I use SMA cross over in 10 min. chart, but
    also I need daily MACD as a filter. My problem is when I do optimization for exapmle
    for 6 month period and it starts 1.1.2009 to 6.30.2009. In the optimization results I never get the results for the first month. It always starts trading in this case from 2.1.2009. What am I missing in order that my strategy trades from the begining of the optimization period. My startegy is bellow:

    protected override void Initialize()
    {
    SetStopLoss("LONG", CalculationMode.Ticks, Stop, false);
    Add(PeriodType.Day , 1); //BarsArray[1]
    Add(MACD(12, 26, 9));

    CalculateOnBarClose = true;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (CrossAbove(SMA(Slow), SMA(Fast), 1)
    && MACD(BarsArray[1], 12, 26, 9).Diff[1] > 0)

    {
    EnterLong(DefaultQuantity, "LONG");
    }

    // Condition set 2
    if (RSI(14, 3).Avg[0] > RsiValue)
    {
    ExitLong("PROFIT", "LONG");
    }
    }

    Thanks

    #2
    Hello flexi,

    Are you doing a Walk Forward Optimization or a regular Optimization?

    Do you have Daily data going back to Jan 1st downloaded?
    (Tools -> Historical Data Manager... -> Edit -> instrument -> data type -> interval type -> date)


    Also, if you would like me to test your code, please create an export of the code so that the code is complete. (This is missing variable declarations)

    To export your script do the following:
    1. Click File -> Utilities -> Export NinjaScript
    2. Enter a unique name for the file in the value for 'File name:'
    3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
    4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


    By default your exported file will be in the following location:
    • (My) Documents/NinjaTrader 7/bin/Custom/ExportNinjaScript/<export_file_name.zip>


    Below is a link to the help guide on Exporting NinjaScripts.
    http://www.ninjatrader.com/support/h...nt7/export.htm
    Last edited by NinjaTrader_ChelseaB; 11-25-2014, 01:18 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes I have the data. And it is happening in Walk Forward Optimization and regular Optimization as well. When I remove the daily bars array form the MACD and use
      only 10 min. MACD all is fine. The problem arises only when I combine daily indicator
      with for example 10 min. strategy.

      Comment


        #4
        Here is my strategy
        Attached Files

        Comment


          #5
          Hello flexi,

          I think you are running to an issue with BarsRequired.

          The BarsRequired will need to be satisfied for all data series before the script will start evaluating.

          If this is set to 20 (which is where it defaults), there need to be 20 daily bars before the script will start evaluating.

          Try setting BarsRequired to 1.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            I guess that was the problem.

            Thanks a lot

            Comment


              #7
              Can you tell me as well why on this chart in the backtesting it takes 20 bars
              for the MACD to be displayed but min. Bars required is set to 1?
              Attached Files

              Comment


                #8
                Hi flexi,

                When the Strategy Analyzer is used, the indicators will have their own BarsRequired which defaults to 20.

                Hard-coding the BarsRequired in the indicator or making a parameter that sets the BarsRequired could get around this.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rocketman7, Today, 02:12 AM
                2 responses
                16 views
                0 likes
                Last Post rocketman7  
                Started by briansaul, Today, 05:31 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by PaulMohn, Today, 03:49 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by frslvr, 04-11-2024, 07:26 AM
                6 responses
                106 views
                1 like
                Last Post NinjaTrader_BrandonH  
                Started by trilliantrader, 04-18-2024, 08:16 AM
                6 responses
                26 views
                0 likes
                Last Post trilliantrader  
                Working...
                X