NexusFi: Find Your Edge


Home Menu

 





Do's n Dont's for realtime-trading


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one Big Mike with 3 posts (5 thanks)
    2. looks_two DarthTrader with 2 posts (0 thanks)
    3. looks_3 record100 with 1 posts (0 thanks)
    4. looks_4 BigDog with 1 posts (0 thanks)
    1. trending_up 5,380 views
    2. thumb_up 5 thanks given
    3. group 4 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Do's n Dont's for realtime-trading

  #1 (permalink)
 DarthTrader 
Cologne
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/Zen-Fire, Velocity/TT
Trading: Futures, Stocks
Posts: 10 since Jun 2009
Thanks Given: 29
Thanks Received: 3

Hi,

yesterday, after handling with a OCO-problem, I asked myself what are the differences in programming if I want to go live with a strategy.

During backtesting only at the open of a new bar orders are triggered, so I think there is a little difference and maybe you have to change your code for live-trading.

Because I'm not new to programming but to NinjaTrader I wanted to know what are your experiences or best-practices and what are the changes in code to go live with the strategy. Error-Handling is also an interesting point ...

Thx in advance
DT

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
How to apply profiles
Traders Hideout
MC PL editor upgrade
MultiCharts
Trade idea based off three indicators.
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Cheap historycal L1 data for stocks
Stocks and ETFs
 
  #2 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,460 since Jun 2009
Thanks Given: 33,234
Thanks Received: 101,655

Hi DT,

There is a lot to cover on this subject, but some advice I hope you take to heart is this:

Always test your strategy in simulation mode in a live market before allowing cash trades.

I have learned too many times that something did not behave as expected, but only after I started placing live trades. These things did not show up in Market Replay and especially did not show up in backtesting.

Some examples I can think of:
  1. One strategy that focuses on longs, a separate on shorts, each trying to open or close a position. [only if you have two separate strategies on same instrument]
  2. Stop orders - in general.
  3. Limit orders - in general.
Hopefully some others will chime in as well. There is a LOT to cover on this topic

Mike

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #3 (permalink)
 DarthTrader 
Cologne
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus/Zen-Fire, Velocity/TT
Trading: Futures, Stocks
Posts: 10 since Jun 2009
Thanks Given: 29
Thanks Received: 3


Thanks Mike, for your fast reply.

Could you explain it in more detail. I would prefer some code-snippets

Do you use only Market-Orders in Strategies, when you say there could be a problem with stops and limits?

From my point of view I used in other tools such things like:
  • check trading-hours
  • check price and order-server availability
  • check CurrentBar > XY
  • check current position of the strategy
  • ...
Maybe it could be the target of this thread to produce a template for strategies, with code-snippets to start live-trading, multiple comments included ... to prevent errors in live-trading ...

DT

Started this thread Reply With Quote
  #4 (permalink)
 
record100's Avatar
 record100 
Toronto, CA
 
Experience: Intermediate
Platform: NT
Broker: IB
Trading: YM, ES
Posts: 105 since Jun 2009
Thanks Given: 34
Thanks Received: 44

there are standard NT approaches that are recommended to do using methods onbarupdate, onorderupdate, onorederexecution, onpositionupdate, again we might need to wait for NT7 for better order processing control. That control could depend on data provider.

Reply With Quote
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,460 since Jun 2009
Thanks Given: 33,234
Thanks Received: 101,655


DarthTrader View Post
Do you use only Market-Orders in Strategies, when you say there could be a problem with stops and limits?

These problems are really not easy to explain, but basically...

I only use market orders in strategies anymore. This is because limit orders have several problems with backtests.

Everything I say below is assuming BACKTESTING not live trading:

First, if at any time on a bar your limit price is hit, it will be filled. Let's say you have a 5m bar or some other bar which can be large. Say your target is 4 ticks. Price can be at the top of the bar and falling, fill your LONG limit order, and then close on the low without ever going +1 tick after filling you, yet Ninja will show a profitable trade if there was 4 ticks between the bar open and your limit price. Ninja doesn't know the OHLC order, I get that.

Second, you try to set your profit target to not ever fill on bar #1. At least 2 bars are required. This plays it 'safe'. If you call SetProfitTarget after BarsSinceEntry() > 1, it will still show profit target on bar 1, even though it was called on bar 2 and during bar 1 no PT even existed.

Third, if you name your orders the same (ie "long" and "short") and you set your profit targets in #onbarupdate say right after the Enter() command, many times NT has the wrong PT values because it was left-over from a previous signal. If a signal 5 entries ago had a target of 4 ticks, NT screws up and doesn't always recalculate the new PT based on the new entry.

Needless to say, I wrote a lot of code that fixes all of these -- to the best of my knowledge -- but still I just prefer to deal with market orders in strategies given all my negative experience with limit orders.

Stop orders are just as bad. A stop limit order is twice the fun. The stop price can be met, the limit price never hit after the stop order was placed, yet ninja will show it filled, again all because OHLC order is unknown.

I do not know why NT cannot simply assume the worst OHLC order. Would be nice. Or it would be nice to have a menu option to never allow PT on bar #1 as well.

Anyway, that is as quick as I can make it.

Mike

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
BigDog
Chicago
 
Posts: 60 since Jun 2009
Thanks Given: 0
Thanks Received: 17

Always use the market data replay to backtest strategies... using the built in backtester is for all intents and purposes... worthless...

market replay will let you get a real flavor of what you migh or might not see

Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,460 since Jun 2009
Thanks Given: 33,234
Thanks Received: 101,655


BigDog View Post
Always use the market data replay to backtest strategies... using the built in backtester is for all intents and purposes... worthless...

market replay will let you get a real flavor of what you migh or might not see

Not practical when trying to test 1 year of data. Hell, not practical when trying to test more than a couple weeks.

But all of this backtest talk is steering me off course. I am really trying to stay away. I spent over a year on this stuff and have nothing to show for it, with the exception of identifying tons of bugs. I am not getting paid by NT so that is worthless.

My focus is 100% discretionary. Backtesting is just useful to me in the idea of proving an approximate concept is approximately profitable.

Mike

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on June 15, 2009


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts