Spaces:
Running
26272829303132333435363738394041171819202122232425
Browse files// Adaptive SSL Filter based on volatility
atrValue = ta.atr(14)
atrRatio = atrValue / close * 100
volatilityFactor = math.max(1, math.min(3, atrRatio * 3))
sslUp = sslBaseUp + (atrValue * 0.5 * volatilityFactor)
sslDown = sslBaseDown - (atrValue * 0.5 * volatilityFactor)
// Multi-Timeframe SuperTrend Confirmation
[supertrendTrend, supertrendDir] = request.security(syminfo.tickerid, "15",
ta.supertrend(3, 10)[1] > close ? -1 : 1, lookahead=barmerge.lookahead_on)
5:36:59 AM "Untitled script" opened
5:38:38 AM Compiling...
5:38:39 AM Error at 47:60 Could not find function or function reference 'security'
5:40:18 AM Compiling...
5:40:20 AM Compiled.
5:40:20 AM Updated on chart.
5:48:44 AM Compiling...
5:48:45 AM Error at 65:65 The "strategy.entry" function does not have an argument with the name "when"
5:48:45 AM Error at 69:67 The "strategy.entry" function does not have an argument with the name "when"
5:50:50 AM Compiling...
5:50:52 AM Compiled.
5:50:52 AM Updated on chart.
6:03:34 AM Compiling...
6:03:35 AM Error at 29:77 Syntax error at input "end of line without line continuation"
- ssl-hybrid-bot.pine +5 -8
|
@@ -27,8 +27,7 @@ sslUp = sslBaseUp + (atrValue * 0.5 * volatilityFactor)
|
|
| 27 |
sslDown = sslBaseDown - (atrValue * 0.5 * volatilityFactor)
|
| 28 |
// Multi-Timeframe SuperTrend Confirmation
|
| 29 |
[supertrendTrend, supertrendDir] = request.security(syminfo.tickerid, "15",
|
| 30 |
-
ta.supertrend(3, 10)[1] > close ? -1 : 1
|
| 31 |
-
|
| 32 |
// Volume Weighted Trend Confirmation
|
| 33 |
volumeAvg = ta.sma(volume, 20)
|
| 34 |
volumeFactor = volume > volumeAvg * 1.5 ? 1.5 : volume > volumeAvg ? 1 : 0.5
|
|
@@ -89,7 +88,7 @@ isNewsTime = dayofweek == dayofweek.friday and hour >= 13 and hour <= 15
|
|
| 89 |
isOptimalTime = (hour >= 8 and hour <= 18) or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday)
|
| 90 |
|
| 91 |
if time > timestamp(2020, 1, 1, 0, 0)
|
| 92 |
-
|
| 93 |
strategy.entry("Long", strategy.long, qty=positionSize)
|
| 94 |
strategy.exit("Long Exit", "Long",
|
| 95 |
stop=longTrailPrice,
|
|
@@ -97,7 +96,7 @@ if time > timestamp(2020, 1, 1, 0, 0)
|
|
| 97 |
trail_points=close * 0.005,
|
| 98 |
trail_offset=close * 0.003)
|
| 99 |
|
| 100 |
-
|
| 101 |
strategy.entry("Short", strategy.short, qty=positionSize)
|
| 102 |
strategy.exit("Short Exit", "Short",
|
| 103 |
stop=shortTrailPrice,
|
|
@@ -105,10 +104,8 @@ if time > timestamp(2020, 1, 1, 0, 0)
|
|
| 105 |
trail_points=close * 0.005,
|
| 106 |
trail_offset=close * 0.003)
|
| 107 |
// Enhanced Plotting with Candlestick Alignment
|
| 108 |
-
plot(sslUp, color=color.new(
|
| 109 |
-
plot(sslDown, color=color.new(
|
| 110 |
-
plot(hullTrend, color=color.new(#008FFB, 0), linewidth=2, title="Hull Trend")
|
| 111 |
-
|
| 112 |
// Visual Indicators
|
| 113 |
plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
|
| 114 |
plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
|
|
|
|
| 27 |
sslDown = sslBaseDown - (atrValue * 0.5 * volatilityFactor)
|
| 28 |
// Multi-Timeframe SuperTrend Confirmation
|
| 29 |
[supertrendTrend, supertrendDir] = request.security(syminfo.tickerid, "15",
|
| 30 |
+
ta.supertrend(3, 10)[1] > close ? -1 : 1)
|
|
|
|
| 31 |
// Volume Weighted Trend Confirmation
|
| 32 |
volumeAvg = ta.sma(volume, 20)
|
| 33 |
volumeFactor = volume > volumeAvg * 1.5 ? 1.5 : volume > volumeAvg ? 1 : 0.5
|
|
|
|
| 88 |
isOptimalTime = (hour >= 8 and hour <= 18) or (dayofweek != dayofweek.saturday and dayofweek != dayofweek.sunday)
|
| 89 |
|
| 90 |
if time > timestamp(2020, 1, 1, 0, 0)
|
| 91 |
+
if (autoTradeLong and (not inputUseNewsFilter or not isNewsTime) and barstate.isconfirmed and isOptimalTime)
|
| 92 |
strategy.entry("Long", strategy.long, qty=positionSize)
|
| 93 |
strategy.exit("Long Exit", "Long",
|
| 94 |
stop=longTrailPrice,
|
|
|
|
| 96 |
trail_points=close * 0.005,
|
| 97 |
trail_offset=close * 0.003)
|
| 98 |
|
| 99 |
+
if (autoTradeShort and (not inputUseNewsFilter or not isNewsTime) and barstate.isconfirmed and isOptimalTime)
|
| 100 |
strategy.entry("Short", strategy.short, qty=positionSize)
|
| 101 |
strategy.exit("Short Exit", "Short",
|
| 102 |
stop=shortTrailPrice,
|
|
|
|
| 104 |
trail_points=close * 0.005,
|
| 105 |
trail_offset=close * 0.003)
|
| 106 |
// Enhanced Plotting with Candlestick Alignment
|
| 107 |
+
plot(sslUp, color=color.new(color.green, 0), linewidth=2, title="SSL Up")
|
| 108 |
+
plot(sslDown, color=color.new(color.red, 0), linewidth=2, title="SSL Down")
|
|
|
|
|
|
|
| 109 |
// Visual Indicators
|
| 110 |
plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
|
| 111 |
plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
|