PDA

View Full Version : setstoploss setprofitTarget


Creamers
07-20-2008, 07:21 AM
Hi,

I created a strategy using in OnBarUpdate the following two:
-------------------------------------------------------------
protected override void Initialize()
{
CalculateOnBarClose = true;
}
--------------------------------------------------------------
if (Position.MarketPosition == MarketPosition.Flat){
SetStopLoss(CalculationMode.Ticks, 3);
SetProfitTarget(CalculationMode.Ticks, 4); }

--------------------------------------------------------------
1#When the strategy enters Long/Short (in replay), I would like to manually change stoploss/target in the Dome. This works as long as price is moving within the same bar. As soon as a new bar formes, it resets itself to the above settings even when I'm in a position?!

How come? Any suggestions how to solve this ?

ps 2# If using SetStopLoss & SetProfitTarget, is that created as bracket or oco or ... ?
3# I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins ? How come?

Hope you can help me out here,

Thanks in advance,

Greetings from the netherlands,

NinjaTrader_Dierk
07-20-2008, 11:06 AM
>> I would like to manually change stoploss/target in the Dome.
Unfortunately this is not supported. You can't manually change the prices of order placed by NinjaScript strategies

>> If using SetStopLoss & SetProfitTarget, is that created as bracket or oco
yes

>> I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins
Not sure I follow. Position will be reported as Long/Short as long as there is a position.

Creamers
07-20-2008, 11:14 AM
>> I would like to manually change stoploss/target in the Dome.
>>>Unfortunately this is not supported. You can't manually change the prices of order placed by NinjaScript strategies

I created a stategy to enter the market automatically because it goes lighting fast. What alternative could there be made so I ONLY enter the market automatically with a strategy but manage my position manually ?

>> I also noticed that Position.MarketPosition == MarketPosition.Long or short is seen as Flat until the next bar creation begins
>>>Not sure I follow. Position will be reported as Long/Short as long as there is a position.

If I'm long or short within the candle it triggered, MarketPosition.Long is not true untill the next rangebar ! (replay mode)
Is there an alternative to see if I'm long or short ?

NinjaTrader_Dierk
07-20-2008, 11:18 AM
You could try an ATM strategy (e.g. on the SuperDOM). However, it's not as flexible as a NinjaScript strategy.

Position.MarketPosition= Long/Short will be reported as a position has been entered, meaning an order was placed and filled and (!) OnBarUpdate is triggered again (which is on the next bar). To trigger OnBarUpdate on every tick see CalculateOnBarClose=false: http://www.ninjatrader-support.com/HelpGuideV6/CalculateOnBarClose1.html

Creamers
07-20-2008, 12:36 PM
Thanks for explaining, makes totally sense now ;) !!

But I have still one question left, it's about manually editing a strategy target/stoploss.
I know you try to answer in concept of you support and don't go into technical details, but if you could just give me a hint ...That way I can go and investigate it on my own.

(With ATM you mean sending AtmStrategyCreate() from within a strategy condition etc , right?)

But I assume Ninjatrader has also other posiblilities to interact with a strategy?

I hope you can give me a hint,

Anyway, thanks for answering the previous questions ! Have a nice sunday!

greetings,

NinjaTrader_Josh
07-20-2008, 12:40 PM
The idea of linking an ATM strategy inside a NinjaScript Strategy is that the NS strategy will fire off the entry order and then the ATM strategy will handle the protective exit orders.

You can interact with NinjaScript Strategies via read/write to text files if you would like. There is a reference sample you can check out in the Reference Sample section just about this. It is titled something along the lines of Reading from a text file.