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
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,788 views
        0 likes
        Last Post aligator  
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        837 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,293 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        12 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        62 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X