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 05-16-2008, 04:46 AM   #1
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default Profit target

I have tried to set a target profit for a strategy in the Wizard so once it goes long it should straight away put a limit order on the ask price, however after it enters long it doesnt put in the exit order....

When the following conditions are true:

Position.MarketPosition == MarketPosition.Long


Do the following:

ExitLongLimit(GetCurrentAsk().""."")

Anyone had any luck with something similar??
maninjapan is offline  
Reply With Quote
Old 05-16-2008, 06:55 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

You sure its not just closing? In backtest, there is not ask so close price is subsituted.
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-16-2008, 07:06 AM   #3
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default

I havent actually backtested this. ITs all from watching it on realtime data. It enters no problems and my fixed tick stoploss comes up ok, its jsut the sell limit doesnt come up on the ask price like I would expect it too ( I have also set the entries per direction to 2)
maninjapan is offline  
Reply With Quote
Old 05-16-2008, 07:21 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Try removing the check for being long and see if that makes a difference. ExitLongLimit() will just be ignored if a long position does not exist.
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-18-2008, 11:01 PM   #5
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default getting closer

Ok, Ive removed the check for a long position and it seems to have fixed it. However it doesnt appear immediately.... It takes a while for the profit target limit order to appear after a new position is opened. Is it waiting for the next bar to start before it recognizes a new position?
I would like the order to appear immediately after a new position is taken.

Thanks
maninjapan is offline  
Reply With Quote
Old 05-19-2008, 03:29 AM   #6
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

If the line of code is in the OnBarUpdate() method then yes it will wait till the next bar provided you are using CalculateOnBarClose = true. Otherwise it will do it on the next tick. If you want it immediately you will need to code it in the OnOrderUpdate() and OnExecution() methods. There is a reference sample available.
NinjaTrader_Josh is offline  
Reply With Quote
Old 05-19-2008, 05:52 AM   #7
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default

I would like to keep it in the wizard, so by unchecking calculateonbarclose in the wizard It comes in straight away.

The problem that I am having now is that when I use a fixed tick stoploss my profit target doesnt come up at all. If I delete the Stoploss from the strategy it comes up fine. Is there a reason why the stoploss seems to be affecting the profit target rule?
maninjapan is offline  
Reply With Quote
Old 05-19-2008, 07:16 AM   #8
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Maybe your signal names are not the same? Leave them as blank.
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-19-2008, 07:18 AM   #9
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default

They are blank. Ive just checked and tested it again. But the same thing keeps happening. The profit target exit works fine if I dont add a stop loss. As soon as I do the profit target stops working and I jsut get the stop loss
maninjapan is offline  
Reply With Quote
Old 05-19-2008, 07:22 AM   #10
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

Make sure the only exit orders are then places in the stops/targets screen.
NinjaTrader_Ray is offline  
Reply With Quote
Old 05-19-2008, 07:34 AM   #11
maninjapan
Senior Member
 
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
Default

but that then only gives the options of percent/ticks or price.......
and then why am I able to create an exit in the other section??
maninjapan is offline  
Reply With Quote
Old 05-19-2008, 07:41 AM   #12
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

That is correct, that's how it works.
NinjaTrader_Ray 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
ATM - Profit Target Rmos22 ATM Strategies (Discretionary Trading) 1 12-13-2007 12:10 AM
Profit Target and Flag Agamenon General Programming 1 11-08-2007 01:41 PM
dollar profit target rally7 Strategy Development 6 10-31-2007 11:45 AM
profit target - no stop Futures_Shark Suggestions And Feedback 1 08-14-2007 10:51 PM
Changing the Profit Target SuzyG Strategy Development 2 01-05-2007 07:55 AM


All times are GMT -6. The time now is 10:01 PM.