![]() |
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
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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?? |
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
You sure its not just closing? In backtest, there is not ask so close price is subsituted.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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)
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
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.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
|
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.
Josh
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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? |
|
|
|
|
|
#8 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Maybe your signal names are not the same? Leave them as blank.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#9 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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
|
|
|
|
|
|
#10 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Make sure the only exit orders are then places in the stops/targets screen.
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#11 |
|
Senior Member
Join Date: Jan 2008
Posts: 147
Thanks: 0
Thanked 0 times in 0 posts
|
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?? |
|
|
|
|
|
#12 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
That is correct, that's how it works.
Ray
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |