View Full Version : setstoploss order from TS 8.1
ppreal
12-19-2006, 03:32 AM
Hi again,
When implementing a strategy via TS 8.1 with a "setstoploss" order, NT puts the stop order on hold, as it should, but then keeps adding subsequent stop orders on hols as time goes by and the strategy does not require the stop to be filled.
Then eventually, when the strategy calls forthe stop to befilled, NT will fill as many stops orders as it generated....
Result: if the original position was short , after the stop is called, instead of being flat, we'll be long by as many stop orders as were put on hold, except for the last one, which was the only real stop that the strategy needed.
Any ideas on how to prevent this from happening?
Tks, Pepe
NinjaTrader_Vincent
12-19-2006, 03:46 AM
Pepe,
Can you send an email from within the application to support. Go to Help--> Mail to Support. That way log files are attached and we can take a look at the messages in the log.
Put in the subjec 'For Vince'
Vince
NinjaTrader_Ray
12-19-2006, 03:57 AM
Are you running the TS Email interfaceor making DLL calls within your strategy?
Ray
ppreal
12-19-2006, 07:23 AM
Sorry for the delay - I was out.
I just sent Vince the log files - I am running the TS e-mail interface.
Pepe
NinjaTrader_Ray
12-19-2006, 07:31 AM
Is your stop order generated with a new signal name each time? If yes, NT wouldcreate a new stop order since each signal name is unique.
Ray
ppreal
12-19-2006, 07:42 AM
Ray, not sure what you mean by "signal name".
The log shows actions "buy to cover" or "sell" if short or long respectively, and order "stop" in every case of repetition, with different ID and Token...
The TS strategyplaces a "setstoploss" after going long or short and a trailing stop after it reaches a certain profit level- trailing stop if working fine.
NinjaTrader_Ray
12-19-2006, 07:49 AM
Please do the following:
Create a strategy where this behaviour is seen.
Delete all files in C:\Program Files\NinjaTrader 5\trace
Start NT
In NT, Tools > Options > General enable "Diagnostics"
A Diagnostics tab will appear in the Control Center. On this tab, check "Server"
Run the strategy so this behaviour is experienced.
Once you have experiences several stop orders generated
Shut down
Send me the following file
C:\Program Files\NinjaTrader 5\trace\ninjatrader.txt
to ray at ninjatrader.com
ppreal
12-19-2006, 01:58 PM
Ok, did it and I'm waiting to get a few more repeats...
But already it's giving me trouble -I hada long position initiated after 3 pm on GBPUSD filled at 1.9685... and it was closed at 8 pm with one of the stops "on hold" with a fill at 1.9633, a loss of 52 pips, while the market at that time was actually above 1.9700, so it should have been a profitable trade!!!
ppreal
12-19-2006, 02:34 PM
Ray,
I just sent you the file - this time I got 2 trailing stop orders at around 10 pm where there should have been only one, turning a long position into a short one insetad of going flat...and there's still a stop order on hold from after 3 pm ... :shock:
NinjaTrader_Ray
12-20-2006, 02:56 AM
Thanks for sending the file.
NT is working as designed. Your strategy is sending duplicate stop orders for what I suspect is only meant to bea replaced order.
For example, this is the an email we receive at about 10 PM which is an "Active order" which then submits this as an order.
TradeStation - Strategy Active Order for GBPUSD
Order: Sell 1 GBPUSD @ 1.9666 Stop Market
Account:
Occurred: 12/19/2006 8:00:05 PM
Signal: Stop Loss
Interval: 60 min.
Workspace: C:\Program Files\TradeStation 8.1 (Build 3258)\MyWork\NinjaTraderPP
Two minutes later we receive the following which is also an "Active order" so NT submits another stop order. I suspect you likely wanted to replace the order above with this new price.
TradeStation - Strategy Active Order for GBPUSD
Order: Sell 1 GBPUSD @ 1.9664 Stop Market
Account:
Occurred: 12/19/2006 9:59:45 PM
Signal: Stop Loss
Interval: 60 min.
Workspace: C:\Program Files\TradeStation 8.1 (Build 3258)\MyWork\NinjaTraderPP
Please check your TS strategy since that is the source of the issue.
Ray
ppreal
12-20-2006, 05:15 AM
tks Ray,
my strategy has only one lines which reads: "setstoploss (stoplossamt) ;"
as to how TS implements that line I have no idea, apparently it sends repeated signals as time goes by, which messes things up at the NT end.
so, how do we deal with this,
- tell TS to redesign their "setstoploss" so that it works with NT? I think not...
- have NT reinterpret the signals generated by said function? maybe...
- use some other kind of stop loss generating order/code? maybe...
I tried the last optionbut only got a worse performing strategy and I'm not knowledgeable enoughin EasyLanguage to find a way around it.
Any ideas anybody?
Pepe
NinjaTrader_Ray
12-20-2006, 05:40 AM
There for sure is nothing for us to do on our side. TS Emails are very clear:
Active Order
Filled Order
Replaced Order
Cancelled Order
The strategy is sending Active Order several times so we must follow the logic and submit as manyorders as we receive notifications for.
Funny thing is, no one else has this issue which is why I pointed back at your strategy. Maybe a setting somewhere in TS?
Ray
ppreal
12-20-2006, 07:06 AM
yeah, and maybe nobody is using the "setstoploss" ...
How about using the DLL instead of the emil interface - I am not familiar with it and don't know how it works - can you explain the difference?
tks, Pepe
NinjaTrader_Ray
12-20-2006, 07:13 AM
DLL interface requires programming, much more advanced. A little faster as well since there is no email delay.
SetStopLoss works, I have tested it many times.
ppreal
12-20-2006, 07:42 AM
You mean setstoploss works with TS email?
NinjaTrader_Ray
12-20-2006, 07:46 AM
Yes.