NinjaTrader Development - Long/Short Strategy (Multi-Time-Frame, Multi-Instrument)

  • Posted:
  • Proposals: 0
  • Remote
  • #56286
  • Expired
  • 0


Experience Level: Intermediate
The code in the attached file should be written and fixed in NinjaTrader 7. I will then review the result, test it and amend it slightly so that it fits my needs.

Rough description
1) You have two stocks (one where you perform the backtest/run the strategy on), the second can be entered as input field (i.e. QQQQ). For better description, let us call stock 1 the stock and stock2 the benchmark
2) the strategy checks entry conditions: long vs pair trade
if the benchmark is trending up (i.e. Close > SMA(200), then trade long only.
if benchmark is trending down, then do pair trade
3) if stock shows a higher momentum (relative outperformance or RSI stronger), than StrategyEntryON
3) if entry criterias are fulfilled (such as SMA crossover, C0 > C1 etc.)
&& StrategyEntryON = TRUE, then long stock
4) if pair trade, then hedge (calculate exposure)

update trailing stop loss

exit criteria:
if stock is exited, check if hedged and then also exit the benchmark

if stopped out, then exit benchmark also

if trend of benchmark changes while being long stock, then calculate current exposure in stock
after determining exposure in stock, enter or exit hedge accordingly

on update bar, calculate and check current exposure in stock and current exposure in benchmark.
in addition, calculate stop loss level, calculate realized and unrealized PnL (NT provides functions which are fine)
if long only (do nothing)
if hedged with benchmark, adjust benchmark position if dollar value of position in benchmark is more than X% away from the long position (with the goal to always be hedged, but not trade every bar, but only if the values of the positions are too far apart.

before strategy, as input field choose print function (1=streamwriter into txt file, 2= print into output window). If you find streamwriter too complicated, I can add it later myself.
print function using streamwriter into text file
print function into output window

New Proposal

Create an account now and send a proposal now to get this project.

Sign up

Clarification Board Ask a Question

    There are no clarification messages.