PDA

View Full Version : trailstop simulated


funk101
04-24-2007, 05:18 PM
Trailstop simulated doesn't actually trail, right? It's not for me. I just downloaded the released version of V6. I will check and see if it does there. Is it supposed to? BTW, kudos on the new site. Great job!

funk101
04-24-2007, 05:26 PM
oops, sorry, it does work in the newly released version :) Is there something I should know about simulated trail stop? Does it "hide" the order from the floor until triggered?

NinjaTrader_Dierk
04-24-2007, 05:38 PM
SimStops are held on your PC and only submitted as they trigger.

funk101
04-24-2007, 05:42 PM
I wonder how much of a performance hit that is. Any idea? As far as "getting the order in"?

NinjaTrader_Dierk
04-24-2007, 05:43 PM
Sorry, we don't know.

funk101
04-24-2007, 05:49 PM
Here's an issue. I'm using a 15 tick trailing stop loss. When 8 points profit reached, trailstop changes to a 2 tick stop loss. Works fine, sometimes. Sometimes I never get the 15 tick initial stop loss value. It gives me a 4 tick, or 2 tick, or even the SAME fill price as a stop loss, so it INSTANTLY gets stopped out. This happens when a trade get's stopped out, then my strategy places another limit order seconds later. Why would this be happening? I've given each trade a unique name,the trailstop is re-init'd. I can' figure out why sometimes it get's tripped up. Right now I'm usinga 30 min bar. However, it hashappened onother time frames as well.

AMP/Zen-Fire/MarketReplay

NinjaTrader_Dierk
04-24-2007, 09:29 PM
I suggest tracing the order placement logic of your strategy: http://www.ninjatrader-support.com/HelpGuideV6/TraceOrders.html

funk101
04-25-2007, 04:56 AM
Sorry, but I'm almost positive there is a bug with the SetTrailStop(). I've traced out my orders, and I took a snapshot of the trade. You'll notice, I have2 trades circled in yellow on chart. The first trade was stopped out IMMEDIATELY and should've been 15 ticks initial stop. The second I have the output showing a trailstop set to 15. I have the DOM showing the trade entered with a stoploss set at 6 ticks, should be 15. *Nothing* in my code says reset to 6 ticks. I've attached a screen capture. Sorry for the big size, but was necessary for you to see the details.

Here's my onbarupdate code:

protected override void OnBarUpdate()

{

if (Historical){

return;

}



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

trailingStop = 15;

LookForEntries();

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



ManageTrade();

}

}


Here's code forlookforentries():

/// <summary>

/// Look For Entries

/// </summary>

public void LookForEntries()

{

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



// Logic removed...



Print ("trail stop set to "+trailingStop);

SetTrailStop(orderName, CalculationMode.Ticks, trailingStop, true);

}




Here's my code for managing trailing stop loss:



/// <summary>

/// Manage Trade

/// </summary>

public void ManageTrade()

{

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

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

trailingStop = 2;

Print ("Setting new TrailStop for "+instrumentName+" - "+trailingStop.ToString());

SetTrailStop(orderName, CalculationMode.Ticks, trailingStop, true);

}

}

}

NinjaTrader_Dierk
04-25-2007, 05:14 AM
Sorry, I'm unable to analyse what is happening here, since the scenario is way to complex (and incomplete since code is missing).

Let's start real simple: Please start with a simple a possible strategy to see if the SetTrailStop works as you would expect. If not, then please let us know.

Next amend your strategy and add complexitity step by step. Monitor your TraceOrder output and the Logs to see if it still works as you would expect until you finally isolated the cause of the trouble.

funk101
04-25-2007, 05:19 AM
Ok, it seems that

Position.MarketPosition does not get changed from "Flat" to "!Flat" apparently. Look at this trace output. Trade sells short, trialstop get's set to 15 next line sells short again, right? Unless I'm reading it wrong.

Entered internal PlaceOrder() method at 4/25/2007 1:30:00 PM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=835.8 StopPrice=0 SignalName=1S_133000' FromEntrySignal=''

trail stop set to 15

Entered internal SetStopTarget() method at 4/25/2007 1:30:00 PM: Type=TrailStop FromEntrySignal='1S_133000' Mode=Ticks Value=15 Currency=0 Simulated=True

Entered internal PlaceOrder() method at 4/25/2007 1:30:00 PM: Action=SellShort OrderType=Limit Quantity=1 LimitPrice=835.8 StopPrice=0 SignalName=1S_133000' FromEntrySignal=''



In my code below I test for MarketPosition twice, to make sure.

NinjaTrader_Dierk
04-25-2007, 05:53 AM
There is no correlation between Position.MarketPosition (your actual strategy position) and the order placement (PlaceOrder or SetStopTarget).

The trace output you posted is not (!) the actual order fills. Please check the logs to see actual order fills and executions.

funk101
04-25-2007, 11:34 AM
Ok, another snap. This time market replay. Strategy works fine. Trades get's entered in with 15 pt trailstop. Simplified -> if5 pt profit tighten trail to 2 ticks. This does not happen. I've snapped a photo, showing log files, and the trade outlining the trade in the log files and on chart. I would like to PM you the strategy for you to look at to see if I'm missing something. I'm using a "simulated" trail stop. btw, the picture shows a 6 point profit, that's ONE beyond the 5 pt strategy, at this point the trails should be 2 ticks behind, as you can see it's still 15 or so behind.

funk101
04-25-2007, 12:30 PM
Ok, I was using a 33 tick chart *was not working*. Switched to a 3min chart, *working fine*...so, what'ya think?

funk101
04-25-2007, 01:37 PM
Man, I'm havig a major problem the this trailstop() issue. I've simplified my strat. just to see it working. Doesn't work with 33 tick chart, does work with 3 min chart. HOWEVER, on big bars, order get's filled, then get's stopped out INSTANTLY. I've given unique names, went over my logic and I can't find anything that is wrong. I can only think that the market is a bit fast, and the "order pending" issue is what's making the stop not work. According to my logic, every new trade should have an initial stop of 15 ticks. After the firsttrade, in a fast market, it seems to move to 1 tick, or SAME tick stop, without my logic. Can you take a look at my very simple script to see if you see anything wrong?

NinjaTrader_Dierk
04-25-2007, 04:27 PM
Please PM me a simple as possible strategy to "dierk AT ninjatrader DOT com".

- this ER2?
- on a 33 tick series?
- which provider/broker? sim feed?

Thanks

NinjaTrader_Dierk
04-25-2007, 07:25 PM
Got your PM. PM'ed you for more information.

Thanks