Last active
March 15, 2024 01:42
-
-
Save bouroo/911dc5e7eb5ad88b05725871507057be to your computer and use it in GitHub Desktop.
SuperTrend + WaveTrend Strategy
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
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// From Network Lag Trading Teams | |
// © bouroo | |
//@version=5 | |
strategy("SuperTrend + WaveTrend Strategy", overlay=true) | |
// SuperTrend Parameters | |
atrLength = input(10, title="ATR Length") | |
factor = input(3.0, title="Factor") | |
[supertrend, direction] = ta.supertrend(factor, atrLength) | |
// WaveTrend Parameters | |
channelLength = input(10, title="Channel Length") | |
averageLength = input(21, title="Average Length") | |
obLevel1 = input(60, title="Over Bought Level 1") | |
osLevel1 = input(-60, title="Over Sold Level 1") | |
ap = hlc3 | |
esa = ta.ema(ap, channelLength) | |
d = ta.ema(math.abs(ap - esa), channelLength) | |
ci = (ap - esa) / (0.015 * d) | |
tci = ta.ema(ci, averageLength) | |
wt1 = tci | |
wt2 = ta.sma(wt1, 4) | |
// Buy and Sell Conditions | |
longCondition = (direction < 0) and (wt1 > wt2 and wt1 < obLevel1) and not bool(strategy.position_size > 0) | |
shortCondition = (direction > 0) and (wt1 < wt2 and wt1 > osLevel1) and not bool(strategy.position_size < 0) | |
// Plotting the Buy and Sell Signals | |
plotshape(series=longCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, size=size.small) | |
plotshape(series=shortCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small) | |
// Executing the Strategy | |
if (longCondition) | |
strategy.entry("Long", strategy.long) | |
if (shortCondition) | |
strategy.close("Long") | |
if (shortCondition) | |
strategy.entry("Short", strategy.short) | |
if (longCondition) | |
strategy.close("Short") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment