Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi Time frame reflection decalred indicators not working in Strategy

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

    Multi Time frame reflection decalred indicators not working in Strategy

    Hello Forum,

    I'm building a strategy that uses three timeframes. It runs in the 60 minute timeframe (BarsArray[0]) and uses 1 day (BarsArray[1]) and 1 minute (BarsArray[2]) for entries and exits.

    Here what's happening. I've reflected a couple of indicators Bollinger, SMA, VOL and VOLMA. Some are reflected and all put on the Strategies chart with AddChartIndicator().

    I saw some results that didn't make sense and when I investigated I found that the Bollinger I reflected was using the 60 minute time frame inspite of my explicit declaration to use the daily (BarsArray[1]).

    Here's the code:
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Day,1); // BarsArray[1]
    AddDataSeries(BarsPeriodType.Minute,1); // BarsArray[2]

    StratVOLMA = VOLMA(BarsArray[1], VOLMAPeriod1);
    StratVOLMA.Panel = 2;
    VOL(BarsArray[1]).Panel = 2;
    AddChartIndicator(VOL(BarsArray[1]));
    AddChartIndicator(StratVOLMA);

    StratSMA50 = SMA(BarsArray[1], SMAPeriod2);
    StratSMA50.Plots[0].Brush = Brushes.Magenta;
    AddChartIndicator(StratSMA50);

    StratBB = Bollinger(BarsArray[1], BBStdDev, BBPeriod);
    AddChartIndicator(Bollinger(BarsArray[1], BBStdDev, BBPeriod));
    ClearOutputWindow();
    }

    Even when adding the Bollinger to chart with a specific declaration (and not the reflected StratBB), the chart says I added it with the 60 minute timeframe.


    This isn't just showing me the 60 minute on the chart , the value of the reflected variable also corresponds to the 60 minute timeframe.

    If I explicitly declare the indicator each time I'm checking values (Bollinger(BarsArray[1], BBStdDev, BBPeriod).Upper[0]) it works as expected.

    Not a big deal for indicators with few variables, but reflection is critical for me using some custom indicators with lots of variables.

    Let me know if you more info to duplicate this.
    Last edited by daqu40; 09-05-2016, 12:58 PM.
    daqu40
    NinjaTrader Ecosystem Vendor - QTradez

    #2
    Hello daqu40,

    Thank you for your post.

    The StratBB should reflect the correct values. However you cannot add a chart indicator using a secondary series that you add in the code that is calling AddChartIndicator.

    You would need to have the indicator you are calling add the secondary series to it's code as well and use it for it's values.

    Development is tracking requests for being able to add chart indicators using adding bar series in the same code under SFT-1576.

    Comment


      #3
      The chart indicator I can understand.

      How about if I reflect an indicator with a different BarsArray that I use internally to the strategy and don't put on the chart. Is this expected to work?
      daqu40
      NinjaTrader Ecosystem Vendor - QTradez

      Comment


        #4
        Hello daqu40,

        Thank you for your response.

        Yes, you can use the BarsArray for the indicator in this manner. You would need to ensure that the DataLoaded State has processed. For example:
        In OnStateChange():
        Code:
        			else if (State == State.Configure)
        			{
        				AddDataSeries(BarsPeriodType.Minute, 5);
        				
        			}
        			else if (State == State.DataLoaded)
        			{
        				mySMA = SMA(BarsArray[1], 1);
        			}

        Comment


          #5
          Thanks, I'll try that.
          daqu40
          NinjaTrader Ecosystem Vendor - QTradez

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,611 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          22 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X