TradingView
fareidzulkifli
16 Ara 2020 10:25

MACD With Trend Filter: Visual Backtest Module Template 

EUR/USDOANDA

Açıklama

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 [x] 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

Sürüm Notları

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 [PineCoders] Backtest Engine Module:
External Signal Protocol --> Set ESP State to send to "Backtesting & Trading Engine [PineCoders]"
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 [PineCoders] 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
Yorumlar
Asif1001
I want strategy tester for this script it will help when we test different settings
jammy1971
Amazing script.. many thanks!
vijaypadayatchi
Sir can you provide me mostly all profitable settings on this indicator
fareidzulkifli
@vijay198626, All? No i cant, it depends on what instrument/timeframe u trading. Plus this indicator came with backtest functionality, so u should do your homework and look for the best setting fit your strategy.
vijaypadayatchi
@fareidzulkifli, my timeframe is one minute chart, and instrument are cash segment for NSE Indian stock market
Meisam_TA
ru0ka
Awesome script. The visualization is A+!
jfigs86
Love this script, but I can't seem to enable MA filter. I use a 200EMA fitler with it enabled in the settings, but buy/sell signals still appear regardless of the position of the 200 EMA.
Any users have any tips for this?
fareidzulkifli
@jfigs86, Hi, can u provide a screenshot or tell me which symbol and timeframe u tested this on? The filter is working fine for me
akuevil
Thanks! looks good
Daha Fazla