Created
August 15, 2019 13:41
-
-
Save GuntharDeNiro/91dc8437bb71d8dc88ac454b7224e1f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@version=4 | |
strategy("MM_Trend_Test", overlay=true) | |
start = input(0.02) | |
increment = input(0.02) | |
maximum = input(0.2) | |
psar = sar(start, increment, maximum) | |
plot(psar, title="SAR", linewidth=1, style=6, color=color.white) | |
conversionPeriods = input(9, minval=1, title="Conversion Line Periods"), | |
basePeriods = input(26, minval=1, title="Base Line Periods") | |
laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Periods"), | |
displacement = input(1, minval=1, title="Displacement") | |
donchian(len) => avg(lowest(len), highest(len)) | |
conversionLine = donchian(conversionPeriods) | |
baseLine = donchian(basePeriods) | |
leadLine1 = avg(conversionLine, baseLine) | |
leadLine2 = donchian(laggingSpan2Periods) | |
plot(conversionLine, color=#0496ff, title="Conversion Line") | |
plot(baseLine, color=#991515, title="Base Line") | |
plot(close, offset = -displacement, color=#459915, title="Lagging Span") | |
p1 = plot(leadLine1, offset = displacement, color=color.green, | |
title="Lead 1") | |
p2 = plot(leadLine2, offset = displacement, color=color.red, | |
title="Lead 2") | |
fill(p1, p2, color = leadLine1 > leadLine2 ? color.green : color.red) | |
lookback = input(2,minval=1) | |
cciLong = cci(close,14) > 100 | |
cciShort = cci(close,14) < -100 | |
longCondition = leadLine1 > leadLine2 and low > leadLine1 and psar < low and cciLong | |
if (longCondition) | |
strategy.entry("LONG", strategy.long) | |
shortCondition = leadLine1 < leadLine2 and high < leadLine1 and psar > high and cciShort | |
if (shortCondition) | |
strategy.entry("SHORT", strategy.short) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment