Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MArket Analyzer aborts Initialize(), CuurentBars[x] wrong

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

    MArket Analyzer aborts Initialize(), CuurentBars[x] wrong

    The market Analyzer value for an indicator is not matching the chart indicator value.
    Both usages are set to CalculateOnBarClose = false
    The time frames are 2 minute, 4 minutes, 6 minutes.
    Market Analyzer set to 2 minutes.
    Using 24/7 default in MA properties and chart, ES 3-13 2 min.

    I built a debugging statement to see what is happening.
    Here is sample debugging outputs of that line for the same tick from each usage
    Print(" c1n " +CurrentBars[0] + " c2n " + CurrentBars[1] + " c3n " + CurrentBars[2]);

    From Chart Indicator:
    c1n 12268 c2n 3882 c3n 1312
    From Market Analyzer indicator for look back 200
    c1n 254 c2n 199 c3n 199


    You can see the count ratios are related to that for the chart indicator values.
    But the values in the MA indicator instance for 4 minute and 6 minute are not updated
    They should be appropriately 254, 218, 206

    The CurrentBars[1] and CurrentBars[2] will update slowly if I run Replay
    for long time but are still not correct
    Here are the values after running replay for another 146 minutes worth of Replay data
    c1n 12341 c2n 3906 c3n 1320
    c1n 328 c2n 200 c3n 200

    Both CurrentBars[0] values are correct, but the CurrentBars[1] and
    CurrentBars[2] for the MA indicator has barely budged.

    Changing Look back value in MA properties and MA indicator reference to 1000 did not fix things

    The problem seems to be that MA does not like the Initialize() code that is OK in a Chart
    and aborts with an error some times "Add method only accepts positive value but value was -3 min"
    and other times about bad object reference.
    Here is the initialize() code which is OK in the Chart usage.but aborts in MA
    ===
    protected override void Initialize()
    {
    CalculateOnBarClose = false;
    Overlay = true;
    PriceTypeSupported = false;
    BarsRequired = barsReq;
    Print("Initialize open " );
    tpSignal = new DataSeries (this);
    Add(new Plot(Color.FromKnownColor(KnownColor.SlateBlue), PlotStyle.Bar, "BuySell"));
    // Plots[0].PanelUI = 1; // nope doesn't work
    if (secondInstDupe == true)
    secondInstrument = Instrument.FullName; // force identical
    string pType = BarsPeriod.BasePeriodType.ToString();
    var pBaseType = BarsPeriod.BasePeriodType;
    string tunit = BarsPeriod.ToString(); // e.g. "3 Min"
    string tId = BarsPeriod.Id.ToString();
    Print("Initialize period length = " + tunit);
    int iPos=tunit.IndexOf(" ");
    if (iPos!=-1) {
    tunit=tunit.Substring(0,iPos);
    // Print("Initialize period Type = " + pType + ", <" + tunit + ">");
    baseSize = Convert.ToInt32(tunit);
    Print("Initialize period Type = " + pType + ", <" +
    tunit + "> baseSize " + " ID<" + tId + "> " +
    + baseSize);
    }

    // Add(secondInstrument, pBaseType, baseSize);
    int b2count = (int) (bigMult * baseSize);
    int b3count = (int) (bigMult * bigMult * baseSize);
    Print("Initialize period 2 & 3 length = " + b2count + " " +
    b3count);
    Add(secondInstrument, BarsPeriod.Id, b2count);
    Add(secondInstrument, BarsPeriod.Id, b3count);
    }




    How can I get Initialize to perform in MA the same way as in the Chart usage
    Thanks in advance
    Roland

    #2
    Market Analyse and BarsPeriod

    Possible hint:
    Further experimentation reveals that if this line is commented out
    tunit = BarsPeriod.ToString(); // e.g. "3 Min"
    Initialize() perform to completion.

    OK so the Help section says don't use this in Initialize() (even though it is OK in Charts).
    So how do I get the equivalent information during Initialize() so that i can set up variable higher level time frames on starting up?
    Last edited by roland_nt; 02-17-2013, 11:40 PM.

    Comment


      #3
      Thanks for the update Roland, that's unfortunately correct - we could not fully support dynamic adding of series, it may or may not as expected and race conditions could exist (like the one you hit). I would suggest making a user variable to configure the added series as needed prior to running through Initialize() then.
      BertrandNinjaTrader Customer Service

      Comment


        #4
        Market Analyzer detect setting of Dataseries for indicator column

        So does that mean there is no (maybe sneaky) way to detect the settings that DataSeries holds in the Column when an indicator is used in the column?

        Or for the case of user supplied values as you suggest, in the line
        Add(secondInstrument, BarsPeriod.Id, b2count);
        what is the datatype and values for BarsPeriod.Id?
        Last edited by roland_nt; 02-18-2013, 08:56 AM.

        Comment


          #5
          Market Analyzer multi time frame not referencong same bars as indicator

          Bertrand:
          Changed to hard coded multi time frame setup per recommendation.
          However still getting odd results
          Here is the debug line:
          Print(CurrentBar.ToString("00000") + " getTpdir tlevel " + tLevel + " tpSignal " + tpSignal[0]+ " cdir " + currentDir
          + " cl 0,1,2 " + Closes[0][2] + " " + Closes[tf2][2] + " " + Closes[tf3][2]);
          Here are the results for indicator
          13939 getTpdir tlevel 3 tpSignal -1 cdir -3 cl 0,1,2 1464.25 1463.75 1462.5
          Here are the results for Market Analyzer instance
          00239 getTpdir tlevel 3 tpSignal 0 cdir -1 cl 0,1,2 1464.25 1463.75 1462.75
          Note that Closes[tf3][2] are different.
          (tf2 and tf3 are hard coded as 1,2 respectively.)
          (tpSignal is the value I am trying to calculate, code not shown but is based on closes))

          Here are the CurrentBars values for indicator, MA for the same tick (BarsInProgress = 0)
          Print(CurrentBar + " onbru2 " + Time[0] + " c1n " +CurrentBars[0] + " c2n " + CurrentBars[1] + " c3n " + CurrentBars[2]);
          13939 onbru2 1/11/2013 10:50:00 AM c1n 13939 c2n 3978 c3n 1345
          00239 onbru2 1/11/2013 10:50:00 AM c1n 239 c2n 213 c3n 204
          Bars required for MA set to 200, both have CalculateOnBarClose=false
          IndicatorGUI has BarsRequired of 150
          Base level is 2 minutes, 2nd level is 6 minutes, 3rd level is 18 minutes..

          I am unsure of how MA Bars Required needs to be set relative to indicator Bars Required
          so I just made MA value larger.

          I note that the MA values on reload at an earlier time might be something like
          00239 onbru2 1/11/2013 8:50:00 AM c1n 200 c2n 200 c3n 199
          which means that they start out not following the indicator
          CurrentBars 1x, 3x, 9x ratios seen in the indicator and that it
          takes several bars for the MA to begin to show that ratio.
          Any ideas here would be helpful.
          Thanks in advance.
          Roland
          Last edited by roland_nt; 02-19-2013, 03:27 PM. Reason: minor comment addition

          Comment


            #6
            Hi Roland, so all other settings between MarketAnalyzer and chart including COBC (MA per default false, Chart normally true) and session template are the same?

            I would set the same # of BarsRequired on the chart (it would apply to all series in your script) and load more data back on the Market Analyzer to your script more initialization to catch up.

            Would you see an issue on other instruments as well? Would it be possible to testdrive the same setup on my end for you?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Market Analyzer multi time frame not referencong same bars as indicator

              Bertrand:
              Yes everything matches up.
              You can run this, no special dependencies.
              Tell me where to email.
              Roland

              Comment


                #8
                Ok, please direct to my Attn to support at ninjatrader dot com Roland. Thanks.
                BertrandNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

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