#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 } }
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How does this work?
Collapse
X
-
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:Tags: None
-
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.htmlBertrandNinjaTrader Customer Service
-
So is it possible to enter a trade using the dome window and attach an ATM strategy to it for money management?
Comment
-
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 volIQ, Yesterday, 04:28 PM
|
2 responses
16 views
0 likes
|
Last Post
by volIQ
Today, 01:42 PM
|
||
Started by adeelshahzad, Today, 11:49 AM
|
5 responses
16 views
0 likes
|
Last Post Today, 01:27 PM | ||
Started by spottysallrite, Today, 11:31 AM
|
5 responses
13 views
0 likes
|
Last Post Today, 01:20 PM | ||
Started by yaniv, Today, 12:50 PM
|
1 response
4 views
0 likes
|
Last Post Today, 01:15 PM | ||
Started by Lele2k24, Yesterday, 11:24 AM
|
10 responses
33 views
0 likes
|
Last Post Today, 01:04 PM |
Comment