Fibonacci Bollinger Bands DCA Martingale Strategy
Fibonacci Bollinger Bands DCA Martingale Strategy
Fibonacci Bollinger Bands DCA Martingale Strategy
// Input parameters
length = input.int(200, minval=1, title="Length")
src = input.source(hlc3, title="Source")
mult = input.float(3.0, minval=0.001, maxval=50, title="Multiplier")
initialTradePercent = input.float(10, title="Initial Trade Percentage (%)") / 100
scalingFactor = input.float(1.2, title="Scaling Factor")
shortEMA_length = input.int(50, title="Short EMA Length")
longEMA_length = input.int(200, title="Long EMA Length")
// Calculate EMAs
shortEMA = ta.ema(close, shortEMA_length)
longEMA = ta.ema(close, longEMA_length)
// Strategy Conditions
shortCondition1 = ta.crossunder(close, upper_1)
shortCondition2 = ta.crossunder(close, upper_2)
shortCondition3 = ta.crossunder(close, upper_3)
shortCondition4 = ta.crossunder(close, upper_4)
shortCondition5 = ta.crossunder(close, upper_5)
shortCondition6 = ta.crossunder(close, upper_6)
longCondition1 = ta.crossover(close, lower_1)
longCondition2 = ta.crossover(close, lower_2)
longCondition3 = ta.crossover(close, lower_3)
longCondition4 = ta.crossover(close, lower_4)
longCondition5 = ta.crossover(close, lower_5)
longCondition6 = ta.crossover(close, lower_6)
// Short Entries
if (shortTrend)
if (shortCondition1 and usedCapital + tradeAmount1 <= equity and not hasShort1)
strategy.entry("Short 0.236", strategy.short, qty=tradeAmount1/close)
usedCapital += tradeAmount1
hasShort1 := true
// Long Entries
if (longTrend)
if (longCondition1 and usedCapital + tradeAmount1 <= equity and not hasLong1)
strategy.entry("Long 0.236", strategy.long, qty=tradeAmount1/close)
usedCapital += tradeAmount1
hasLong1 := true
// Reset used capital and position trackers after closing all positions
if ((strategy.position_size > 0 and close >= basis) or (strategy.position_size < 0
and close <= basis))
strategy.close_all()
usedCapital := 0.0
hasShort1 := false
hasShort2 := false
hasShort3 := false
hasShort4 := false
hasShort5 := false
hasShort6 := false
hasLong1 := false
hasLong2 := false
hasLong3 := false
hasLong4 := false
hasLong5 := false
hasLong6 := false