![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
|
Hi, Can someone help me, I am new to this?
I want to program a simple ATR Stop: In my System I have Two Positions A & B: I want it so, When the current price is > Entryprice of B - ATR (14). Action: Exit Both Longs A&B How can I do this in the Wizards? Did I need to code it instead? What Variables are used for the Entryprice of Positions and Current Price of Positions? Thank you for the help Here is my code: // 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 ATRSTOPSSS : Strategy { #region Variables // Wizard generated variables private int myInput0 = 1; // Default setting for MyInput0 // User defined variables (add any user defined variables below) #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() { // Condition set 1 if (DonchianChannel(14).Upper[1] < High[0]) { EnterLong(DefaultQuantity, "A"); } // Condition set 2 if (High[0] > Position.AvgPrice + ATR(14)[0]) { EnterLong(DefaultQuantity, "B"); } } #region Properties [Description("")] [Category("Parameters")] public int MyInput0 { get { return myInput0; } set { myInput0 = Math.Max(1, value); } } #endregion } } |
|
|
|
|
|
#2 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
Anthero2000,
You will need to custom code this because from the wizard you can only get the whole position's fill price. You will need to program to access the individual "B"'s fill price.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
|
How would I do that?
|
|
|
|
|
|
#4 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
You will need to create an IOrder object for each entry order and individually access the IOrder property for fill price.
http://www.ninjatrader-support.com/H...V6/IOrder.html
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ATR Trailing Stop | cowcool | ATM Strategies (Discretionary Trading) | 4 | 05-30-2009 10:24 AM |
| ATR Trailing Stop | BigDog008 | Strategy Development | 12 | 03-12-2009 10:20 AM |
| ATM ATR Trailing stop | net01 | ATM Strategies (Discretionary Trading) | 1 | 10-23-2008 10:34 AM |
| ATR Stop | ATI user | Strategy Development | 8 | 09-29-2008 10:12 AM |
| ATR based Stop Loss | moon_rainz | Strategy Development | 2 | 07-17-2008 11:42 PM |