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 mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Started by Waxavi, Today, 02:10 AM
        0 responses
        7 views
        0 likes
        Last Post Waxavi
        by Waxavi
         
        Working...
        X