PDA

View Full Version : SetTrailStop()


funk101
04-04-2007, 03:30 AM
Ok, when I enter a trade TraceOrders tells me...

Entered internal PlaceOrder() method at 4/4/2007 11:30:00 AM: Action=SellShort OrderType=Limit Quantity=2 LimitPrice=1.3414 StopPrice=0 SignalName=EXTREME short 3 4/4/2007 11:30:00 AM' FromEntrySignal=''

The TrailStop get's set to it's initial value, which is 12 ticks...

Entered internal SetStopTarget() method at 4/4/2007 11:30:00 AM: Type=TrailStop FromEntrySignal='EXTREME short 3 4/4/2007 11:30:00 AM' Mode=Ticks Value=12 Currency=0 Simulated=False

Then I run my TrackTrade() in OnBarUpdate()...

if (Position.MarketPosition != MarketPosition.Flat) {

if (Position.GetProfitLoss(Close[0], PerformanceUnit.Points) >= 4){

int stopLoss = 2;

Print("Setting stop to "+stopLoss+" in "+instrumentName+" at "+Time[0]);

SetTrailStop(orderName, CalculationMode.Ticks, stopLoss, false);

}

The Print() outputs properly, indicating that this indeed get's called, however,TraceOrders does not display that the TrailStop() get's changed from 12 to 2.

Steer me in the right direction please.

NinjaTrader_Ray
04-04-2007, 03:39 AM
This would suggest thatthis the SetTrailStop() is not getting called if there was no trace output. I checked our code and there is nothing once a call to this method is made that would prevent a trace ouput.

The only thing left to do is start stripping down the strategy and debug.

What I would do is create a base strategy that sets the initial trail stop in the Initialize() method, then in OnBarUpdate() call it again with a different offset value and run the strategy. This should show the trace output with the change.

Then start adding components until you get to a point where it does not behave as expected.

Ray