Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How does this work?

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

    How does this work?

    I've created a template for an ATM strategy in my superdome named VolumeStop. I then enter a position on the Superdome with my VolumeStop ATM Strategy selected. However when running in debug mode of visual studio, the code doesn't even get hit. There are no errors in the log. This is the basic of my code.

    Code:
     
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        /// <summary>
        /// Enter the description of your strategy here
        /// </summary>
        [Description("Enter the description of your strategy here")]
        public class akVolumeStop : Strategy
        {
            #region Variables
      private double stoppoints = 5;
      private double stopvolumetrigger = 80;
      
      private double sp = 0;
      private double contractstraded=0;
      
      int[] mp = new int[2];
      
      private string VolumeStop  = string.Empty;
      private string orderId    = string.Empty;
      
      
      #endregion
            /// <summary>
            /// This method is used to configure the strategy and is called once before any strategy method is called.
            /// </summary>
            protected override void Initialize()
            {
                CalculateOnBarClose = true;      
            }
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {       
       if (Historical)
        return;
       
       if (orderId.Length == 0 && VolumeStop.Length == 0 && Close[0] > Open[0])
       {
        VolumeStop = GetAtmStrategyUniqueId();
        orderId = GetAtmStrategyUniqueId();
        AtmStrategyCreate(Action.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", VolumeStop);
       }
       
       mp[1]=mp[0];
       mp[0]=1;
       
       if (GetAtmStrategyMarketPosition(VolumeStop)==MarketPosition.Long)
       {
        mp[0]=1;
        if (mp[0]!=1)
         contractstraded=0;     
         
        sp = Positions[0].AvgPrice-stoppoints;
        
        if (Close[0]<=sp)
         contractstraded+=Volume[0];
        
        if (contractstraded>=stopvolumetrigger)
         ExitLong();
       }
       
       else if (GetAtmStrategyMarketPosition(VolumeStop)==MarketPosition.Short)
       {
        mp[0]=-1;
        if (mp[0]!=-1)
         contractstraded=0; 
        
        sp = Positions[0].AvgPrice+stoppoints;
        
        if (Close[0]>=sp)
         contractstraded+=Volume[0];
        
        if (contractstraded>=stopvolumetrigger)
         ExitShort();
       }
       else
        mp[0]=0;
            }
            #region Properties
    
            #endregion
        }
    }

    #2
    Hi SystemTrading,

    not sure I follow - you can use NinjaScript and ATM strategies to manually exit (via your ATM templates) NinjaScript strategy generated trades, to attach an ATM template to a strategy you want to use the ATMStrategyCreate() - http://www.ninjatrader-support.com/H...egyCreate.html

    Here is some general info on NinjaScript and ATM strategies - http://www.ninjatrader-support.com/H...trategies.html

    Comment


      #3
      So is it possible to enter a trade using the dome window and attach an ATM strategy to it for money management?

      Comment


        #4
        Hi SystemTrading,

        Yes, of course - if it is a template created in the SuperDOM - http://www.ninjatrader-support.com/H...nStrategy.html

        Or you can code a NinjaScript strategy and use a predefined ATM strategy template as exit order management strategy, to see how to link those to your NinjaScript strategy, please review the 'SampleATMStrategy' installed by default with your NinjaTrader.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        88 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        48 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        31 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        34 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        69 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X