Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Alexander Elder, Multiple TimeFrame

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

    Alexander Elder, Multiple TimeFrame

    Dear,

    I've started to use Ninjatrader outside the wizard, because I want to use a multiple-timeframe strategy (alexander elder). I've been working on it and reading your manual, forum, etc. But can't figure out what I've been missing. Can you help? My code is in attachement.

    PS: nice software and support team! Good job!
    Attached Files

    #2
    Hello Orbital,

    Thank you for your post.

    When running the strategy is there an error message listed on the Log tab of the Control Center? If so, what does this error report?

    Comment


      #3
      Hi, thanks for the fast response. Actually I don't have any error message, It's just that the orders aren't generated anymore... when using the strategy without the weekly period layer (as an extra time frame). The strategy generates buy and sell orders, from the moment I add the extra weekly time period layer, no orders are generated.

      KR.

      Comment


        #4
        Hello Orbital,

        Thank you for your response.

        The item here would be that we need to check to ensure we have the necessary bars before processing the code. First, in the code we need to add this check with the following line:
        Code:
        			if (BarsInProgress != 0 || CurrentBars[0] <= 26 || CurrentBars[1] <= 26)
        				return;
        And then we need to ensure the chart we apply the strategy to does in fact have a 26+ week date range by right clicking in the chart --> selecting Data Series --> either select CustomRange under 'Load data based on' and select a start date that would cover this data or use Bars or Days for the 'Load data based on' and ensure we set this far enough back to encompass 26+ weeks for the base series of the chart.

        For information on this item please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=3170

        Comment


          #5
          Hi Patrick,

          Thanks. I've added your suggestion in the code (see below) (I read it earlier, but thought the "if (BarsInProgress != 0) return;" was the same. I also load 10Y of daily closes, so this should cover the 10 weeks period. Still no single buy-order was initiated, Do I miss something with the use of BarsArray? It's just one condition and I don't get any error messages when compiling.

          protected override void Initialize()
          {
          Add(PeriodType.Week, 1); //BarsArray[1]
          Add(EMA(Close, 26)); // To be added for BarsArray
          Add(MACD(Close, 12, 26, 9));
          CalculateOnBarClose = true;
          }

          /// <summary>
          /// Called on each bar update event (incoming tick)
          /// </summary>
          protected override void OnBarUpdate()
          {
          if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
          return;

          if (BarsInProgress != 0)
          return;

          if (Rising(EMA(BarsArray[1], 26)) == true
          && Rising(MACD(BarsArray[1], 12, 26, 9).Avg) == true)

          {

          // Condition set 1
          if (MACD(Close, 12, 26, 9).Diff[0] > MACD(Close, 12, 26, 9).Diff[1]
          && BarsSinceExit() > 1)
          {
          EnterLong(1000, "");
          }

          // Condition set 2
          if (Performance.AllTrades.TradesPerformance.Currency. CumProfit == 0)
          {
          EnterLong(1000, "");
          }
          }

          // Condition set 3
          if (CrossAbove(Close, MAEnvelopes(Close, 4.5, 1, 7).Upper, 1))
          {
          ExitLong("", "");
          }
          }

          Comment


            #6
            Hello Orbital,

            Thank you for your response.

            I would recommend using Print statements after each conditions to verify they are returning true and checking this in the Output window (Tools > Output window): http://www.ninjatrader.com/support/f...ead.php?t=3418

            You can also add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window: http://www.ninjatrader.com/support/f...ead.php?t=3627

            It may also help to add drawing objects to your chart for signal and condition confirmation: http://www.ninjatrader.com/support/f...ead.php?t=3419

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by ETFVoyageur, 05-18-2024, 12:45 AM
            10 responses
            53 views
            0 likes
            Last Post ETFVoyageur  
            Started by ETFVoyageur, Today, 08:39 AM
            14 responses
            26 views
            0 likes
            Last Post ETFVoyageur  
            Started by voltation, 07-20-2020, 09:06 PM
            8 responses
            2,296 views
            0 likes
            Last Post Ttrade12  
            Started by tkaboris, Yesterday, 07:53 PM
            7 responses
            25 views
            0 likes
            Last Post tkaboris  
            Started by JGriff5646, 05-19-2024, 05:47 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X