NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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 04-20-2009, 01:01 AM   #1
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Visual stops and limits

I have created a few systems using the wizard. Is there a way to display the initial stop and intial limit visually on the chart when the strategy enters a position? Is there a way also to display the trailing stop in real time?

Can you also assist with this piece of code?
I wish to exit a long position by using a limit order one ATR(5) from my entry price. ExitLongLimit(ATR(5)[0],'''',""). I am not sure what to use to show entry price.

Thanks
cptrader is offline  
Reply With Quote
Old 04-20-2009, 07:35 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader, to reference the entry price you can use 'Average Position Price' from the 'Strategy' category. Visualizing your stops would unfortunately need custom coding outside of the wizard.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-20-2009, 10:30 AM   #3
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default ATR Initial Stop

ExitLongStop(Position.AvgPrice - ATR(5)[0] , "", "");

The above initial stop would be entry price less ATR(5).
The ATR would be calculated on each new bar. Correct?
How would I reference the ATR to the entry bar only?
cptrader is offline  
Reply With Quote
Old 04-20-2009, 10:48 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

You would need to store the ATR value in a variable when you enter and then reference this in your order as offset for the stop.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 04-20-2009, 08:55 PM   #5
cptrader
Member
 
Join Date: Oct 2008
Location: Western Australia
Posts: 80
Thanks: 0
Thanked 0 times in 0 posts
Default Stored ATR value

Thanks for your feedback Bertrum

I am not entirely sure how to store the ATR value in a variable when you enter. I have included sample code with a stored ATR value of 5.

private int aTRPeriod = 5; // Default setting for ATRPeriod

{// Condition set 1
if (Low[0] > SMA(High, 10)[0])
{
EnterLong(DefaultQuantity, "SMAabove");
}

// Condition set 2
if (Position.MarketPosition == MarketPosition.Long)
{
ExitLongLimit(Position.AvgPrice + ATR(aTRPeriod)[0] , "SMAaboveExit", "SMAabove");
cptrader is offline  
Reply With Quote
Old 04-21-2009, 06:38 AM   #6
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Hi cptrader, with storing I meant doing something like this
Code:
 
if (Position.MarketPosition == MarketPosition.Long)
{
double myATR = ATR(5)[0]; 
ExitLongLimit(Position.AvgPrice + myATR);
}
which I find simply more convenient, but your code should do it also.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 05-06-2009, 12:27 PM   #7
bkout
Senior Member
 
Join Date: Dec 2008
Location: Austin, TXs
Posts: 112
Thanks: 10
Thanked 0 times in 0 posts
Default

Just to verify since I'm using simple profit and loss stops. Without doing code is there any way to plot say plus and minus 10% from the entry price lines on a chart?
bkout is offline  
Reply With Quote
Old 05-06-2009, 12:42 PM   #8
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,421
Thanks: 252
Thanked 982 times in 964 posts
Default

Unfortunately not bkout, you would need to create an indicator were you enter your entryprice and then you can calculate and display those levels.
NinjaTrader_Bertrand 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
HELP on Coding Stops&Limits w/ the STRATEGY WIZARD Doctor D General Programming 3 04-02-2009 03:04 PM
Daily loss limits SystemTrading ATM Strategies (Discretionary Trading) 1 03-05-2009 09:52 AM
Visual Stops rtj4201 Charting 1 01-21-2009 08:58 AM
Test of difference within limits... fy260498 Strategy Development 1 08-07-2008 11:01 PM
MAX/MIN limits Richard Von Indicator Development 3 07-30-2007 08:29 AM


All times are GMT -6. The time now is 04:49 PM.