NinjaTrader Support Forum  

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-01-2007, 09:25 AM   #1
thepcmd
Member
 
Join Date: Nov 2006
Location: , ,
Posts: 46
Thanks: 3
Thanked 0 times in 0 posts
Default SetStopLoss

I am trying to set my stop loss and have it update every tick not just at the close of the bar. I want the strategy to only calculate on the close of the bar but I would like to have the SetStopLoss react quicker than the close of the bar. In an ATMStrategy the stop is moved immediately when the event occurs but I cannot mange to accomplish this in my strategy.

if (Position.MarketPosition == MarketPosition.Flat)
{
SetStopLoss("", CalculationMode.Ticks, 8, false);
}

// If a long position is open, allow for stop loss modification to breakeven
else if (Position.MarketPosition == MarketPosition.Long)
{
// Once the price is greater than entry price + x ticks, set stop loss to breakeven
if (Close[0] > Position.AvgPrice + 3 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice);
}
if (Close[0] > Position.AvgPrice + 8 * TickSize)
{
SetStopLoss(CalculationMode.Price, Position.AvgPrice + 4 * TickSize);

Is it possible to switch CalculateOnBarClose from true to false. ex: it is set to true unless (Position.MarketPosition != MarketPosition.Flat) and then switch it back to true when Flat?
Last edited by thepcmd; 12-01-2007 at 09:30 AM.
thepcmd is offline  
Reply With Quote
Old 12-01-2007, 09:36 AM   #2
thepcmd
Member
 
Join Date: Nov 2006
Location: , ,
Posts: 46
Thanks: 3
Thanked 0 times in 0 posts
Default

I would prefer to use the ATMStrategy to place and managed my trades in my strategies but getting my accounts PnL to manage has been troublesome. I want to place a daily profit and stop level so if it reaches that level it will not take any additional trades. Is there any way to get my accounts realized PnL when using ATMStrategies?
thepcmd is offline  
Reply With Quote
Old 12-01-2007, 01:14 PM   #3
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

In NT6.5 you can do this with some of the new methods. You can place your SetStopLoss logic inside the OnMarketData() method and that will update your stop loss on a tick by tick basis while leaving your OnBarUpdate() to run with CalculateOnBarClose as true.

To get your accounts realized PnL when using ATM strategies you can use this. http://www.ninjatrader-support.com/H...rofitLoss.html
http://www.ninjatrader-support.com/H...rofitLoss.html
NinjaTrader_Josh 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
SetStopLoss() & SetTrailStop() Concurrent Use whitmark Strategy Development 8 11-14-2007 09:05 AM
SetStopLoss() and SetProfitTarget() SamIam Strategy Development 9 09-05-2007 08:49 PM
SetStopLoss Question aethelwulf General Programming 3 07-03-2007 04:00 PM
Currency in SetProfitTarget / SetStopLoss DarrylT Strategy Development 1 05-12-2007 10:54 AM
setstoploss order from TS 8.1 ppreal Automated Trading 15 12-20-2006 07:46 AM


All times are GMT -6. The time now is 12:24 AM.