Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
trailstop simulated
Collapse
X
-
imported post
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
Comment
-
imported post
I suggest tracing the order placement logic of your strategy: http://www.ninjatrader-support.com/H...aceOrders.html
Comment
-
imported post
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:
protectedoverridevoid OnBarUpdate()
{
if (Historical){
return;
}
if (Position.MarketPosition == MarketPosition.Flat){
trailingStop = 15;
LookForEntries();
} elseif (Position.MarketPosition != MarketPosition.Flat){
ManageTrade();
}
}
Here's code forlookforentries():
///<summary>
/// Look For Entries
///</summary>
publicvoid 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>
publicvoid 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);
}
}
}
Comment
-
imported post
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.
Comment
-
imported post
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.
Comment
-
imported post
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.
Comment
-
imported post
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?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Aviram Y, Today, 05:29 AM
|
0 responses
1 view
0 likes
|
Last Post
by Aviram Y
Today, 05:29 AM
|
||
Started by quantismo, 04-17-2024, 05:13 PM
|
3 responses
25 views
0 likes
|
Last Post Today, 05:23 AM | ||
Started by ScottWalsh, 04-16-2024, 04:29 PM
|
7 responses
34 views
0 likes
|
Last Post Today, 05:15 AM | ||
Started by cls71, Today, 04:45 AM
|
0 responses
6 views
0 likes
|
Last Post
by cls71
Today, 04:45 AM
|
||
Started by mjairg, 07-20-2023, 11:57 PM
|
3 responses
216 views
1 like
|
Last Post
by PaulMohn
Today, 04:22 AM
|
Comment