Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Retreiving Candle duration / Chart timeframe

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

    Retreiving Candle duration / Chart timeframe

    Simple question, how do you retrieve the current chart candle duration setting (i.e. 1 minute, 5 minute, 10 minute, etc.) within a script? I want to be able to adjust strategy parameters dynamically in the script if I change the candle duration of the chart manually in real time.

    Thank you.

    #2
    Hello Dr Kerry,

    The values of the barstype can be accessed while the script is running but cannot be used for the purpose of controlling user inputs in the earlier states of the script. In your OnBarUpdate logic you could certainly use those values to deleage what the strategy is doing.

    To access the bars type values you can use the following values:

    Code:
    Print(Bars.BarsPeriod.Value + " " + Bars.BarsPeriod.BarsPeriodTypeName);
    
    if(Bars.BarsPeriod.BarsPeriodType == BarsPeriodType.Minute && Bars.BarsPeriod.Value > 5)

    Comment


      #3
      Jesse,

      Thank you very much for your quick reply. I think that what you suggest will work because the strategy restarts whenever the candle time scale is changed manually. So it will be able to get the current chart setting and use that in combination with the "if" statements to set the parameter values accordingly.

      Regards,

      Kerry

      Comment


        #4
        Hello Dr Kerry,

        Correct, each time you change the timeframe the strategy will restart so those will match the series that the strategy is applied to. The only time those values won't be available is during the early states of the strategy before State.DataLoaded. You can see some examples on the following page, that usage is the same as what I provided, Bars.BarsPeriod, the Bars property just refers to the primary bar series being used.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        132 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X