Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I don't understand well..

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

    I don't understand well..

    Well... I'm trying to run a multitimeframe strategy. I'm using the code Add(periodTime.... ) and the BarsArray to refer to one or the other periods on the indicator conditions...

    But when I run the strategy it doesnt work properly. It should enter a long position when MACD.macd is over MACD.avg in the 15min period (and other conditions) but, it entered a long position when macd was below avg... and I don't understand that. I checked the strategy and is well writed... can anyone help me?

    #2
    cozar534, for debugging your conditions and the triggering of trades it it helpful to include draw statements in your code to visualize exactly when those conditions evaluate to true - http://www.ninjatrader-support.com/H...gOnAChart.html

    For a general overview over multiseries strategies, please see this link from the helpguide -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      cozar534, for debugging your conditions and the triggering of trades it it helpful to include draw statements in your code to visualize exactly when those conditions evaluate to true - http://www.ninjatrader-support.com/H...gOnAChart.html

      For a general overview over multiseries strategies, please see this link from the helpguide -

      http://www.ninjatrader-support.com/H...struments.html

      I've already read the part of the help guide you mentioned. I don't know what is my fault so please take a look of it:

      I added in the Initialize () method:

      Add(PeriodType.Minute, 3);
      Add(PeriodType.Minute,
      15);
      Add(PeriodType.Second,
      20);
      (This is supposed to be the BarsArray[1], [2] and [3] because the BarsArray[0] are the primary bars (the chart bars) and I used 3 minute period for them)

      I added in the OnBarUpdate() method:

      {
      if (BarsInProgress != 0)
      return;

      // Condition set 1
      if (MACD(BarsArray[2], X, Y, Z)[0] > MACD(BarsArray[2], X, Y, Z).Avg[0]
      && Stochastics(BarsArray[
      1], A, B, C).K[0] <= 20)
      {
      EnterLong(DefaultQuantity,
      "");
      }
      }

      When I backtest this, and shows me the 3 min chart, it still positions long when the condition MACD is below MACD.Avg (that's ok because the MACD must be for the 15min period).
      The problem is when I put it in real time: the MACD in the 15min period is below MACD.Avg and, on the 3min chart is OVER MACD.Avg).

      My question is.. why when I backtest the strategy it seems to run it rigth, but when I turn on the strategy in real-time it seems to pick just the 3 min chart?

      Comment


        #4
        cozar534, please Print statement or a drawing to your strategy to see in realtime when the condition for trade entry becomes true, in your code you reference both the 15 min and 3 min charts.

        Code:
         
        if (MACD(BarsArray[2], X, Y, Z)[0] > MACD(BarsArray[2], X, Y, Z).Avg[0]
        && Stochastics(BarsArray[1], A, B, C).K[0] <= 20)
        {
        EnterLong(DefaultQuantity, "");
        DrawArrowUp("tag1" + CurrentBar, true, 0, Low[0] - TickSize, Color.Blue);
        }
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Shansen, 08-30-2019, 10:18 PM
        24 responses
        938 views
        0 likes
        Last Post spwizard  
        Started by Max238, Today, 01:28 AM
        0 responses
        3 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by rocketman7, Today, 01:00 AM
        0 responses
        2 views
        0 likes
        Last Post rocketman7  
        Started by wzgy0920, 04-20-2024, 06:09 PM
        2 responses
        27 views
        0 likes
        Last Post wzgy0920  
        Started by wzgy0920, 02-22-2024, 01:11 AM
        5 responses
        32 views
        0 likes
        Last Post wzgy0920  
        Working...
        X