NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 06-01-2009, 08:18 AM   #1
Anthero2000
Junior Member
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default Atr Stop

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
}
}
Anthero2000 is offline  
Reply With Quote
Old 06-01-2009, 08:26 AM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-01-2009, 10:56 AM   #3
Anthero2000
Junior Member
 
Join Date: Jun 2009
Posts: 2
Thanks: 0
Thanked 0 times in 0 posts
Default

How would I do that?
Anthero2000 is offline  
Reply With Quote
Old 06-01-2009, 11:03 AM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

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
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT -6. The time now is 08:07 PM.