![]() |
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 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
If I have set SetStopLossand SetProfitTarget in the Initialize() method and one gets executed, how and where would I put code to capture the exit amount with the time and print it to the output window?
|
|
|
|
|
|
#2 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
There is not supported method to output the actual fills resulting from a stop or target order to the output window. Am I clear as to what you are asking?
You can getthis information from the Control Center Log tab or the Executions Tab. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
|
Yes, this is what I need. Is something like this planned? I see it in the Control Center Log or the Executions Tab, but when testing this is something that would be helpful because I retest and it is hard to determine which is which.
|
|
|
|
|
|
#4 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Not planned at this moment.
Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
|
This is something that I was trying to figure out how to handle as well.
It seems to me that another method would be useful for strategies in addition to Initialize() and OnBarUpdate(). Specifically, I'd like to be able to get the buy/sell amounts related to a fill or stop whenever EnterLong(), EnterShort(), etc. complete, and when a profit target or trailing stop is reached causing the position to be closed. I suggest that this capability might be implemented as another method which gets called when these types of events occur. Since these types of events are quite different than ticks and timed intervals that correspond to OnBarUpdate, I'd suggest a new method to implement this (e.g., OnMarketEvent() or something like that.) I would find this capability very useful. KBJ P.S. You mention that there is not a supported method. Does this mean there is currently a way to do this that is not supported? If so, could you give us an idea of how to do this? |
|
|
|
|
|
#6 |
|
Administrator
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
|
Hi KBJ,
Unfortunately I can't give you an idea since this then means we do provide support. We have a clear line that we have drawn right now. We anticpate releasing support for additional existing functionality as we are able to properly provide support for it. Ray
Ray
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Senior Member
|
Is there no way to trace out what the stoploss value is? I want to make sure the params are being met ie: trailing stop loss as I set them with setstoploss().
I'm having a hard time here. I can't get this stoploss to send in the order. What am I doing wrong? This runs in onBarUpdate(). It prints to output right, but the order never get's sent, I can see in my"Orders" panel. ///<summary> /// Track Trades ///</summary> publicvoid TrackTrade() { if (Position.MarketPosition != MarketPosition.Flat) { if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) >= 4){ double stopLoss = Close[1]; SetStopLoss(orderName, CalculationMode.Price,stopLoss, false); Print ("------------------------------------"); Print ("------------------------------------"); Print("Setting stop to "+stopLoss+" in "+Bars.BarsSinceSession); Print ("------------------------------------"); Print ("------------------------------------"); } Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points)); } } And I would actually prefer to do this with Points instead of Price. Any suggestions? |
|
|
|
|
|
#8 |
|
Senior Member
|
I realize that I wasn't sending in the order at time of entry. That's why. But, I'm still having a hard time trying to "amend" the orig. stoploss. Say, initial stop is 12 ticks, when a PnL of 4 points is hit, I want to move up to basically a trailing 2 tick stop. Can't seem to get this happening.
|
|
|
|
|
|
#9 |
|
Administrator
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
|
Let's see if we could clarify... some hints:
- NT6B10 has a new option "TraceOrders=true;", which you can set in the Initialize method. This traces info to the Output window and could give you an idea what is going wrong. - Sorry, there is no CalculationMode.Point but NT supports CalculationsMode.Ticks which should come close. - Do you have any other exit order placed which potentially prevents the submission of the stop loss order as you enter a position? In general it's a good idea to go from a simple strategy which works to a more complex one (I suppose your OnBarUpdate method does more than just calling TarckTrade). I suggest simplifying the strategy to a point where it works as expected and then add feature after feature to see where the logic breaks. PS: As I wrote this reply you added a new post. However, info above could help you to isolate issue in your recent post.
Dierk
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|