Reading the book Machine Trading from Ernie P. Chang, on the first chapter it offers different oppinions about environments to gather historical data, do backtesting…
I started to analyze which one of the solutions was better to cover the whole picture proposed in the book. My analysis was basically to compare Tradingview and Ninja Trader.
I started to evaluate Quantopian, as it covers backtesting and the environment to develop is Perl on Notebook (which I am familar with), but I discarded it.
As conclusion, for my initial steps on backtesting I have selected Tradingview as tool to start building backtests scripts.
This one is the first one. It combines a simple strategy between RSI and MACD.
strategy(“Test-1 RSI”, overlay=true, initial_capital=1000, currency=’USD’)
/////////// inputs //////////
Length = input(14, minval=1)
Oversold = input(25, minval=1)
Overbought = input(70, minval=1)
fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)
/////////// individual long conditions //////////
rsiLongCondition = rsi(close, Length) < Oversold
MACD = ema(close, fastLength) – ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
macdDelta = MACD – aMACD
macdLongCondition = crossover(macdDelta, 0)
/////////// long condition //////////
// RSI and MACD
if (rsiLongCondition and macdLongCondition)
strategy.entry(“Long 1”, strategy.long)
/////////// individual short conditions //////////
rsiShortCondition = rsi(close, Length) > Overbought
macdShortCondition = crossunder(macdDelta, 0)
/////////// short condition //////////