Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MTF and referring to indicators

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

    MTF and referring to indicators

    NT 7.22
    I've added an indicator TSS to my primary chart in Initialize(). I also want to access it in the other time frame BPI=1. How do i call TSS values for the 2nd time frame (BPI=1)?
    TSS.UpTrend[3] retrieves the value from 3 bars ago, for the primary timeframe
    but it won't allow me to use TSS.UpTrend[3][0]

    {main strategy....}
    protected override void Initialize()
    {
    if (_debug) Print(" Begin Initialize() section");

    Add(TSSuperTrend(atrLength, MovingAverageType.HMA, plFactor, 1, SuperTrendMode.ATR));
    TSS=TSSuperTrend(atrLength, MovingAverageType.HMA, plFactor, 1, SuperTrendMode.ATR); //sds usually ATR

    Add(PeriodType.Tick, 90); // adds a xx Tick bar to strategy




    namespace NinjaTrader.Indicator
    {
    [Description("TSSuperTrend Indicator developed by TradingStudies.com (Version 2.3)")]
    public class TSSuperTrend : Indicator
    {
    private SuperTrendMode _smode = SuperTrendMode.ATR;
    private int _length = 14; // ATR/DT; TSS strat uses 100; 5 much better for CL
    private double _multiplier = 2.01; // 2.618;
    //sds private MovingAverageType _maType = MovingAverageType.WMA;
    private MovingAverageType _maType = MovingAverageType.HMA;
    private int _smooth = 1; // 14
    ...
    protected override void Initialize()
    {
    Add(new Plot(Color.Green, PlotStyle.Hash, "UpTrend"));
    Add(new Plot(Color.Red, PlotStyle.Hash, "DownTrend"));

    #2
    ssylvester, you would need to point to the needed BarsArray to calculate the indicator on - http://www.ninjatrader.com/support/h.../barsarray.htm
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes, before i posted my question, i had read through the bars array material for the last 8 hours, and searched on MTF on the boards. I am still not making any headway.

      Doesn't TSS.UpTrend[3][1]
      point to the bars array with BarsIndex 1? it doesn't work?

      I know i'm missing something basic, but have not been able to solve it.
      Thanks for any help you can provide

      Comment


        #4
        This will not work, this is just the plot series, you need to calculate the indicator first on your added series - if your for example take the SMA, you could call it like this (SMA, 20)[0] - this would just use the basic Close series of the primary instrument as input data for the indicator calcs, but you could also call it SMA(BarsArray[1], 20)[0] -> this would then point to the added series Close value which you added to your Initialize(). You would need to proceed like this with your custom indicator, any indicator would implement the IDataSeries interface in NinjaScript, assuring you can pass in any series to base the calcs on.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Thanks Bertrand. I finally figured out how to add the BarsArray to the indicator -- pretty basic, i just didnt know that you could stick it into the first param of calling the indicator.

          Q: i created the BIP=1 time period in initialize.
          For convenience in referring to the indicator across the 2 time frames, call/rename the indicator as
          TSS0=indicator(...parms) in the Initialize area
          but i cannot call
          TSS1=TSSuperTrend(BarsArray[1],atrLength, MovingAverageType.HMA, plFactor, 1, SuperTrendMode.ATR);
          in the init area, so i call that in the OnBarUpdate area.
          Which i do, and the strategy functions.

          does this TSS1= call take lots of memory? now when i run a backtest over 2 days, it runs ok, but over 10 days, it clubs the memory in my machine and shuts down.


          protected override void Initialize()
          {
          Add(PeriodType.Tick, 80); // BIP=1, xx Tick bar as MT

          Add(TSSuperTrend(atrLength, MovingAverageType.HMA, plFactor, 1, SuperTrendMode.ATR));
          TSS0 = TSSuperTrend(atrLength, MovingAverageType.HMA, plFactor, 1, SuperTrendMode.ATR);
          //TSS1? cannot call BarsArray inside Initialize

          Comment


            #6
            Great you got it working, correct you would need to work with BarsArray in the OnBarUpdate() part. Unfortunately I would not know how efficient the indicator you work with is called, but a 10 day tick based script should not pose such issues performance wise, if you comment out this call and run the script would the issue you see be different?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              (apologies if i responded elsewhere)
              I moved the indicator reference call from OnbarUpdate to OnStartUp (won't allow the call in Initialize), and that has eliminated the memory problem.
              Thx for help.
              S

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Patlpp, 08-16-2021, 03:10 PM
              11 responses
              505 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by DawnTreader, Yesterday, 05:58 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by ntram, Yesterday, 05:39 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by bmarovets, Yesterday, 06:33 PM
              1 response
              15 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Started by FishTrade, Yesterday, 03:42 PM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Working...
              X