Investment Portfolio Backtest Script

Job ID: 32703314

Budget: €250 – €750 EUR

want to back-test the investment strategy below. Will want max drawdown, standard deviation, compound annual growth rate, etc… for the time period that is specified. Should be able to choose a start and end date.

The securities to be utilized are as follows:
SPY, QQQ, DIA, IWM, SSO, QLD, DDM, UWM, TMF, VGLT, JNK.

Investment strategy is as follows:

ITEMS TO DEFINE:
– Is the TSI(40) indicator above zero for all four stock indexes (DOW, S&P 500, IWM, QQQ) (Yes or No)
– Which indexes (DOW, S&P 500, IWM, QQQ) have a TSI(40) above zero.
– What is the 3-month percentage performance of each of the indexes (DOW, S&P 500, IWM, QQQ)
– Is the TSI(40) indicator above zero for VGLT? (Yes or N)
– Is the TSI(40) Indicator above zero for JNK? (yes or No)
– What is the 3-month percentage performance of VGLT and JNK?
– Of the indexes with TSI(40) above zero, which two have outperformed in the past 3 months, percentage-wise? (Note, there may only be one index with a TSI(40) above zero.)

ENTRIES:
On the first trading day of each month, do this:
– If the TSI indicator is above zero for all four indexes, then invest 20% of the portfolio in the 2x ETF version of the two best performing stock indexes (over the past 3 months, percentage-wise) that have a TSI(40) above zero, and invest 20% in the 1x ETF version of the two best performing indexes with a TSI(40) above zero. (For a total of 80% of the portfolio.)

– If the TSI(40) indicator is above zero for some, but not all of the indexes, then invest 40% into the 1x version of the two top performing indexes (over the past 3 months, percentage-wise) with a TSI(40) above zero. (For a total of 80%)

– If there is only one index with a TSI(40) above zero, then invest 40% in the 1x version of that index. (For a total of 40% of the portfolio.)

– If the TSI(40) indicator is below zero for all of the indexes, then stay in cash.

For bonds:
If the TSI(40) indicator is positive for VGLT, then invest 20% in TMF.
If the TSI(40) indicator is not positive for VGLT, and the TSI(40) indicator is positive for JNK, then invest 20% in JNK.
If the TSI indicator is not positive for VGLT and TSI, stay in cash.

Exits:
During the month, if the TSI(40) indicator for the securities invested drops below zero, sell half the position. However, if the TSI indicator for all four major stock indexes drop below zero, then cash completely out of any stock index positions and JNK (if invested).

At the first trading day of the next month, re-evaluate per the instructions above.

Deliverables
Coder would deliver a script that produces the information requested above via HTML. Can use Pine script on TradingView.com to generate the output, or other code, as long as a paid subscription is not required. This is for personal use.
Related categories: Python C# Programming Pine Script Trading