fareidzulkifli

MACD With Trend Filter: Visual Backtest Module Template

fareidzulkifli 已更新   
Sample Strategy: MACD Crossover with trend filter options

MA Filter : Price Close Above MA, Search for Buy, Price Close Below MA, Search for Sell
ADX Filter : Take trade only when ADX is above certain treshold
MACD Signal : MACD Cross above signal line while under 0 line indicate Buy Signal
MACD Cross below signal line while above 0 line indicate Sell Signal

-----------------------------
Using Alert Module:

Enable Alert --> Enable TV's alert and plot signal to chart
Alert Type --> Set to take Buy only, Sell only or Both alert

----------------------------
Using Backtest Module:

Enable Backtest --> Enable Backtest simulation
Backtest Type --> Set to take Buy only, Sell only or Both
SL Type -->
ATR : Set SL in ATR times Multiplier below/above entry price
Fixed : Set SL in fixed point below entry point (in 'Dollar'). e.g. for Stocks -> 0.5 equals to 50cent while for EURUSD currency -> 0.005 equal to 50 pips
HiLo Bar : Set SL at highest/lowest wick of previous bar plus/minus Fixed point. e.g. EURUSD HiLo=3 and Fixed Point = 0.0005, buy trade will place SL 5 Pips below lowest of previous 3 bar

SL ATR Period --> Set Lookback Period used for SL's ATR calculation
SL ATR Multi --> Set ATR Multiplier for SL
SL Fixed --> Set Fixed Level for SL (Use when SL Type is either Fixed or HiLo Bar)
SL Bar --> Set Number of previous bar to check for SL placement
TP RR Ratio --> Set TP based on RR multiplier. e.g. 2 means TP level will be twice further from entry point compared to Entry-SL distance.

Notes: The point is for preliminary testing, so it only supports 1 trade at a time and no Trailing Stop

----------------------------
Disclaimer:
This script main objective is to create my personal indicator template so that i just have to modify the indicator module for preliminary testing in future.

Testing Alert Module so i can re-use it as template in future study/indicator
Testing Visual Backtest Module so i can re-use it as template in future study/indicator

i believe using Strategy function is a better approach for this but the entry/exit level seems to be hit n miss (at least for me, still trying to figure what i did wrong)
also, i rather code the strategy in other platform where i can use the more accurate tick data if i want to validate backtest statistics.
My study scripts was built only to test/visualize an idea to see its viability and if it can be used to optimize existing strategy.

credit: ADX code are originally from "ADX and DI" by @BeikabuOyaji although i re-wrote so i can have cleaner read and use RMA instead of SMA
發布通知:
Backtesting & Trading Engine Signal Line
 • An invisible plot named "BTE Signal" is provided. It can be used as an entry signal when connected to the PineCoders Backtesting & Trading Engine (click to read their full documentation) as an external input.
  It will generate an entry whenever a marker is displayed.

i just found out about PineCoders very own Backtest Engine so i decided to enable it in my study template. Updated description as below:

Using Backtest Engine Module:
External Signal Protocol --> Set ESP State to send to "Backtesting & Trading Engine "
Signal With Filter --> Use this to send entry signal that already filtered by this study indicator (without stoploss level)
Signal Without Filter --> Use this to send raw entry signal that are NOT YET FILTERED by this study indicator (without stoploss level)
Signal and Stop With Filter --> Use this to send entry signal WITH StopLoss that already filtered by this study indicator (with stoploss level)
Signal and Stop Without Filter --> Use this to send raw entry signal WITH StopLoss that are NOT YET FILTERED by this study indicator (with stoploss level)

Notes: Backtesting & Trading Engine already have built-in Filter, Entries and Stop Level. e.g. Unselect all their filter state if only want to use custom filter and make sure send Signal with Filter (with or without SL level)

Credit: PineCoders Teams

開源腳本

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?