Spaces:
Running
Running
43
Browse filespositionSize = strategy.equity * 0.01 / (close * 0.01) // 1% risk per trade
takeProfitLong = close + (close - longTrailPrice) * inputRiskReward
takeProfitShort = close - (shortTrailPrice - close) * inputRiskReward
// Strategy Execution
if time > timestamp(2020, 1, 1, 0, 0) // Backtest period filter
if longCondition and (not inputUseNewsFilter or not na(security("ECONOMIC_CALENDAR", "D")))
strategy.entry("Long", strategy.long, qty=positionSize)
strategy.exit("Long Exit", "Long", stop=longTrailPrice, limit=takeProfitLong)
Could not find function or function reference 'security'
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'
- ssl-hybrid-bot.pine +5 -4
ssl-hybrid-bot.pine
CHANGED
|
@@ -36,22 +36,23 @@ if shortCondition
|
|
| 36 |
shortTrailPrice := close + trailOffset
|
| 37 |
else
|
| 38 |
shortTrailPrice := nz(shortTrailPrice[1], close + trailOffset)
|
| 39 |
-
|
| 40 |
// Risk Management
|
| 41 |
positionSize = strategy.equity * 0.01 / (close * 0.01) // 1% risk per trade
|
| 42 |
takeProfitLong = close + (close - longTrailPrice) * inputRiskReward
|
| 43 |
takeProfitShort = close - (shortTrailPrice - close) * inputRiskReward
|
| 44 |
|
|
|
|
|
|
|
|
|
|
| 45 |
// Strategy Execution
|
| 46 |
if time > timestamp(2020, 1, 1, 0, 0) // Backtest period filter
|
| 47 |
-
if longCondition and (not inputUseNewsFilter or not
|
| 48 |
strategy.entry("Long", strategy.long, qty=positionSize)
|
| 49 |
strategy.exit("Long Exit", "Long", stop=longTrailPrice, limit=takeProfitLong)
|
| 50 |
|
| 51 |
-
if shortCondition and (not inputUseNewsFilter or not
|
| 52 |
strategy.entry("Short", strategy.short, qty=positionSize)
|
| 53 |
strategy.exit("Short Exit", "Short", stop=shortTrailPrice, limit=takeProfitShort)
|
| 54 |
-
|
| 55 |
// Plotting
|
| 56 |
plot(sslUp, color=color.new(color.green, 0), linewidth=2, title="SSL Up")
|
| 57 |
plot(sslDown, color=color.new(color.red, 0), linewidth=2, title="SSL Down")
|
|
|
|
| 36 |
shortTrailPrice := close + trailOffset
|
| 37 |
else
|
| 38 |
shortTrailPrice := nz(shortTrailPrice[1], close + trailOffset)
|
|
|
|
| 39 |
// Risk Management
|
| 40 |
positionSize = strategy.equity * 0.01 / (close * 0.01) // 1% risk per trade
|
| 41 |
takeProfitLong = close + (close - longTrailPrice) * inputRiskReward
|
| 42 |
takeProfitShort = close - (shortTrailPrice - close) * inputRiskReward
|
| 43 |
|
| 44 |
+
// News Filter Alternative (using time-based filtering)
|
| 45 |
+
isNewsTime = dayofweek == dayofweek.friday and hour >= 13 and hour <= 15 // Example: Friday afternoon news
|
| 46 |
+
|
| 47 |
// Strategy Execution
|
| 48 |
if time > timestamp(2020, 1, 1, 0, 0) // Backtest period filter
|
| 49 |
+
if longCondition and (not inputUseNewsFilter or not isNewsTime)
|
| 50 |
strategy.entry("Long", strategy.long, qty=positionSize)
|
| 51 |
strategy.exit("Long Exit", "Long", stop=longTrailPrice, limit=takeProfitLong)
|
| 52 |
|
| 53 |
+
if shortCondition and (not inputUseNewsFilter or not isNewsTime)
|
| 54 |
strategy.entry("Short", strategy.short, qty=positionSize)
|
| 55 |
strategy.exit("Short Exit", "Short", stop=shortTrailPrice, limit=takeProfitShort)
|
|
|
|
| 56 |
// Plotting
|
| 57 |
plot(sslUp, color=color.new(color.green, 0), linewidth=2, title="SSL Up")
|
| 58 |
plot(sslDown, color=color.new(color.red, 0), linewidth=2, title="SSL Down")
|