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 12-19-2006, 10:28 AM   #1
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

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?


SuzyG is offline  
Reply With Quote
Old 12-19-2006, 10:47 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
Post imported post

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 12-19-2006, 11:02 AM   #3
SuzyG
 
Join Date: Nov 2006
Location: , ,
Posts: 66
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

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.
SuzyG is offline  
Reply With Quote
Old 12-20-2006, 01:22 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
Post imported post

Not planned at this moment.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 03-23-2007, 02:34 PM   #5
KBJ
Senior Member
 
Join Date: Mar 2007
Location: , Florida, USA
Posts: 663
Thanks: 36
Thanked 7 times in 6 posts
Post imported post

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?

KBJ is offline  
Reply With Quote
Old 03-24-2007, 04:14 AM   #6
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
Post imported post

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
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-02-2007, 09:52 PM   #7
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

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?
funk101 is offline  
Reply With Quote
Old 04-02-2007, 11:39 PM   #8
funk101
Senior Member
 
Join Date: Jan 2006
Location: Margate, Florida, USA
Posts: 426
Thanks: 0
Thanked 2 times in 2 posts
Send a message via AIM to funk101
Post imported post

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.
funk101 is offline  
Reply With Quote
Old 04-02-2007, 11:47 PM   #9
NinjaTrader_Dierk
Administrator
 
NinjaTrader_Dierk's Avatar
 
Join Date: Mar 2005
Location: Bamberg, Germany
Posts: 9,994
Thanks: 0
Thanked 6 times in 6 posts
Post imported post

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.
NinjaTrader_Dierk 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


All times are GMT -6. The time now is 07:16 AM.