Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

.cs Question

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

    .cs Question

    Hi,
    I have a indicator I wouyld like to turn into a strategy. I was wondering how to take the .cs file and zip it up into a strategy the import feature will regonize
    Thanks

    #2
    Widgetman,

    Indicators are indicators. You need to make them strategies if you want a strategy. When you have your strategy made you can use File->Utilities->Export NinjaScript to export that strategy for others to import.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      Thanks for the reply. I have a strategy script I have modified manually that is saved as a .cs file. My question is how do I now import it into Ninja. When I try to create a new strategy and paste the code into it I do not see a way to do so. In the old version 5 I am familiar with creating a new strategy or indicator allowed you to paste and compile code.
      Thanks

      Comment


        #4
        Hi,
        I figured it out. It seems a new indicator or strategy is automaticaly locked.
        I was wondering though if it is possible to use a indicator as a signal and pass triggers into a strategy. I noticed in a few of the sample indicators I reviewed that there is code generated at the end of the indicator which is for the market analyzer, and the strategy. below is a example I took from one of the sample indicators. How would I access the triggers from it or can I combine a indicator into a strategy ?
        Thanks

        // This namespace holds all strategies and is required. Do not change it.
        namespace NinjaTrader.Strategy
        {
        public partial class Strategy : StrategyBase
        {
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        [Gui.Design.WizardCondition("Indicator")]
        public Indicator.CycleIdentifiernew CycleIdentifiernew(int filterStrengthRSI, int filterStrengthSMA, int length, int majorCycleStrength, int priceActionFilter, bool useCycleFilter, int useFilterSMAorRSI)
        {
        return _indicator.CycleIdentifiernew(Input, filterStrengthRSI, filterStrengthSMA, length, majorCycleStrength, priceActionFilter, useCycleFilter, useFilterSMAorRSI);
        }

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public Indicator.CycleIdentifiernew CycleIdentifiernew(Data.IDataSeries input, int filterStrengthRSI, int filterStrengthSMA, int length, int majorCycleStrength, int priceActionFilter, bool useCycleFilter, int useFilterSMAorRSI)
        {
        if (InInitialize && input == null)
        throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");

        return _indicator.CycleIdentifiernew(input, filterStrengthRSI, filterStrengthSMA, length, majorCycleStrength, priceActionFilter, useCycleFilter, useFilterSMAorRSI);
        }

        }

        Comment


          #5
          you can create a strategy that keys off of logic in your indicator ... just initialize your indicator in the strategy, and you can access the properties accordingly.

          EDIT: here's an example, if it helps
          Code:
                  #region Variables
                  // all your other variables ...
                  private YourCustomIndicatorName myInd;
                  #endregion
          
                  protected override void Initialize()
                  {
                      // other your other initialize stuff ...
                      myInd = YourCustomIndicatorName(Parm1, Parm2, Parm3);
                   }
          
                  protected override void OnBarUpdate()
                  {
                      // other code may go before this
                      if (myInd.SomeBooleanProperty[0] == true)
                      { 
                          // do something when SomeBooleanProperty is true for this bar
                      }
                      else if (myInd.SomeDoubleProperty[0] > Close[0])
                      {
                          // do something when SomeDoubleProperty is greater than close of this bar
                      }
                      else if (myInd.TrendLine[0] < High[0])
                      {
                          // do something when trendline is less than high of this bar
                      }
                       // other code may go after this
                  }
          hope that helps ... cheers,
          -e
          Last edited by e-man; 04-30-2009, 08:29 PM.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X