Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Bars.GetTime() with LowestBar() and/or Highest() problems

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

    Bars.GetTime() with LowestBar() and/or Highest() problems

    Hi All,
    I am relatively new to NinjaTrader. I have been working with and writing NinjaScripts. I have a problem while using LowestBar() and HighestBar() with Bars.GetTime().

    While it seems the values returned by HighestBar() and LowestBar() are correct the DateTime and highestbarsago & lowestbarsago will print incorrect values in Draw.TextFixed. The Print() will print the correct values but

    Shouldn't this work?

    highestbarsago = HighestBar(High, (CurrentBars[0] < LookBackMax ? CurrentBars[0] : LookBackMax)); // Limit HighestBar Lookback to input value
    lowestbarsago = LowestBar(Low, (CurrentBars[0] < LookBackMax ? CurrentBars[0] : LookBackMax)); // Limit LowestBar Lookback to input value
    rescaleoldmin = Low[lowestbarsago];
    rescaleoldmax = High[highestbarsago];
    rescaleoldrange = rescaleoldmax - rescaleoldmin;

    dtmax = Bars.GetTime(highestbarsago);
    dtmin = Bars.GetTime(lowestbarsago);
    string str = "\n" + dtmax + " Bars: " + highestbarsago + " High: " + rescaleoldmax + "\n" + dtmin + " Bars: " + lowestbarsago + " Low: " + rescaleoldmin;
    Draw.TextFixed(this, ProcDescript + "FixedTextBottomLeft", str, TextPosition.BottomLeft);

    Print(ProcDescript + " CurrentBars[0]: " + CurrentBars[0] + " " + Bars.GetTime(CurrentBars[0]) + " highestbarsago: " + highestbarsago + " High: " + High[highestbarsago] +
    " lowestbarsago: " + lowestbarsago + " Low: " + Low[lowestbarsago] + " rescaleoldmin: " + rescaleoldmin + " rescaleoldmax: " + rescaleoldmax +
    " Reset Range Scale >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >> >>>>>>>>>>>>");

    Importantly it does yeild the correct vales for highestbarsago and lowestbarsago and rescaleoldmin & rscaleoldmax(correct High and Low values are attained). Problem is with Bars.GetTime(); It is not returning the correct Date Time for the barsago values. Is there something I may have missed? Test code attached.
    Attached Files

    #2
    Hello MartinT,

    Your assumption is correct however the GetTime method takes an Index and not a BarsAgo. To use GetTime you would have to use CurrentBars[0] - lowestbarsago to get the index. Alternatively you can just use the time series:

    Code:
    dtmax =Time[highestbarsago];
    dtmin = Time[lowestbarsago];
    https://ninjatrader.com/support/help...ghtsub=GetTime

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks a Heap! That will help for sure.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by daniel_weber8, Today, 01:21 PM
      0 responses
      2 views
      0 likes
      Last Post daniel_weber8  
      Started by jungsoohuh, Today, 12:07 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Started by SharonSS, Today, 11:54 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by crystalet, Today, 11:20 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by SuperDude123, Today, 09:23 AM
      1 response
      30 views
      0 likes
      Last Post NinjaTrader_JustinD  
      Working...
      X