Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can I find out what timeframe a strategy use from its code?

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

    Can I find out what timeframe a strategy use from its code?

    Hi Folks,

    I am very new to this topic. I am curious if I can find out the exact time frame a strategy is using from its code? I am studying the simplest "SampleMACrossOver" strategy in the installation package. I cannot find which time frame this strategy is using.

    From the code, it proceeds to add indicators directly. That confused me.

    Code:
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDes criptionSampleMACrossOver;
    Name = NinjaTrader.Custom.Resource.NinjaScriptStrategyNam eSampleMACrossOver;
    Fast = 10;
    Slow = 25;
    // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = false;
    }
    else if (State == State.DataLoaded)
    {
    smaFast = SMA(Fast);
    smaSlow = SMA(Slow);
    
    smaFast.Plots[0].Brush = Brushes.Goldenrod;
    smaSlow.Plots[0].Brush = Brushes.SeaGreen;
    
    AddChartIndicator(smaFast);
    AddChartIndicator(smaSlow);
    }
    }
    Thank you very much for your input.




    Best Regards
    David WANG

    #2
    Hi sinpeople,
    If you just wanted to identify the primary series the strategy is running on, add the following in OnStateChange():

    ...
    else if (State == State.DataLoaded)
    {
    Print(Instrument.FullName + " " + Bars.Period);
    }
    The result will look similar to this example: FDAX 06-21 1 Min Heiken-Ashi
    NT-Roland

    Comment


      #3
      Hello sinpeople,

      Below are supporting links to the help guide on BarsPeriod.BarsPeriodType and BarsPeriod.Value.
      https://ninjatrader.com/support/help...barsperiod.htm
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by timmbbo, Yesterday, 10:27 PM
      1 response
      6 views
      0 likes
      Last Post tgn55
      by tgn55
       
      Started by zacharydw00, Yesterday, 11:13 PM
      0 responses
      2 views
      0 likes
      Last Post zacharydw00  
      Started by luxurious_04, Yesterday, 10:55 PM
      0 responses
      1 view
      0 likes
      Last Post luxurious_04  
      Started by 7robert, Yesterday, 07:48 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by saltminer, Yesterday, 06:32 PM
      0 responses
      6 views
      0 likes
      Last Post saltminer  
      Working...
      X