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 wildleanketosale, Today, 03:49 AM
      0 responses
      1 view
      0 likes
      Last Post wildleanketosale  
      Started by wildleanketosale, Today, 03:48 AM
      0 responses
      3 views
      0 likes
      Last Post wildleanketosale  
      Started by hiltonvarai, Today, 03:10 AM
      0 responses
      1 view
      0 likes
      Last Post hiltonvarai  
      Started by afyuwi, Today, 02:33 AM
      0 responses
      2 views
      0 likes
      Last Post afyuwi
      by afyuwi
       
      Started by wushutrades, Today, 01:41 AM
      0 responses
      5 views
      0 likes
      Last Post wushutrades  
      Working...
      X