![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Member
Join Date: Nov 2006
Location: , ,
Posts: 46
Thanks: 3
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#2 |
|
Member
Join Date: Nov 2006
Location: , ,
Posts: 46
Thanks: 3
Thanked 0 times in 0 posts
|
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?
|
|
|
|
|
|
#3 |
|
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
|
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
Josh
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |