NinjaTrader Development - Long/Short Strategy (Multi-Time-Frame, Multi-Instrument)
- or -
Post a project like this£50(approx. $64)
- Posted:
- Proposals: 0
- Remote
- #56286
- Expired
Description
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
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
Andreas B.
0% (0)Projects Completed
-
Freelancers worked with
-
Projects awarded
33%
Last project
13 Dec 2024
Switzerland
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies