Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programming question

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

    Programming question

    Using NT 7 V 17 and am trying to modify a sample stratagy. I have no useful knowledge of the C language. Have made a copy of the MA crossover stratagy provided and am attempting to make some changes tnside i.e. MA type and lengths. I have the following piece of code that is a streight copy from the Sample provided (I think) When I try to compile it I get an error CSO118 "Ninja TraderMA Strategy" is a namepspace but is used like a type. This happens wether I use sample code 1 or sample code 2. I have tried them both by commenting out the one I don't want run. Any Help Plese???

    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTraderMA.Strategy
    {
    /// <summary>
    /// Simple moving average cross over strategy.
    /// </summary>
    ///
    /// sample 1 a copy and paste from the originag Sample file

    /// [Description("Simple moving average cross over strategy.")]
    /// public class SampleMACrossOver : Strategy

    ///Sample 2
    [Description("Moving average cross over strategy.")]
    public class MACrossOver : Strategy

    #2
    Hello DeanlDavis475,

    It may be best to delete the copy of the strategy and start over. To delete: Click Tools > Edit NinjaScript > Strategy. Highlight the strategy and click delete.

    Let us know what changes you would like to make to the SampleMACrossover and we can advise an approach for you.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan. What I would relly like is to make the following changes Make the slow MA a 13 EMA and the fast an 8 WMA and add an alert for when there is a crossover. I can get through the changes to the MAs but the alert and the problem with the namespace are above my current knowledge level. Thank you in advance.
      Dean Davis

      Comment


        #4
        A good way to get started with the syntax is through the Strategy Wizard. You can create conditions in a point and click interface and then view the code output for those conditions.

        The periods for fast and slow are user definable inputs so should not require manipulating the code to change. You just set from the UI whenever you run the strategy. Below is a snippet that adds an Alert() within the same block that places the orders. It will also use the EMA for slow and WMA for fast.

        Code:
         
        if (CrossAbove(WMA(Fast), EMA(Slow), 1))
        {
        EnterLong();
        Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert1.wav", 10, Color.Black, Color.Yellow);
        }
         
         
        else if (CrossBelow(WMA(Fast), EMA(Slow), 1))
        {
        EnterShort();
        Alert("myAlert", NinjaTrader.Cbi.Priority.High, "Reached threshold", "Alert1.wav", 10, Color.Black, Color.Yellow); 
        }
        Your Initialize() method can be modified as well for the different moving average types:
        Add(WMA(Fast));
        Add(EMA(Slow));

        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X