mcDucksProject / mcDucksBroker

What if mcDuck had a crypto broker?
GNU General Public License v3.0
16 stars 3 forks source link

[STRATEGY] Double Scalper #33

Open djfoster21 opened 3 years ago

djfoster21 commented 3 years ago
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © itsale-a

//@version=5
strategy("Doble RSI Scalper - Pelu", overlay=true)
//indicator("Doble RSI Scalper - Pelu", overlay=true)

// RSI same timeframe
overb = input.int(42, "Overbought same TF")
overs = input.int(52, "Oversold same TF")
len = input.int(14, minval=1, title="Length")
src = input(close, "Source")
up = ta.rma(math.max(ta.change(src), 0), len)
down = ta.rma(-math.min(ta.change(src), 0), len)
rsi1 = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))

// RSI higher timeframe

len2 = input.int(14, minval=1, title="2d RSI len")
src2 = input(close, "2d RSI source")
resolution  = input.timeframe(title="Select 2nd RSI Timeframe", defval="720")
overb2 = input.int(42, "Overbought higher TF")
overs2 = input.int(52, "Oversold higher TF")
up2 = ta.rma(math.max(ta.change(src2), 0), len2)
down2 = ta.rma(-math.min(ta.change(src2), 0), len2)
rsi2_f = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
rsi2 = request.security(syminfo.tickerid, resolution, ta.rsi(src2, len2), lookahead=barmerge.lookahead_on)

// Prueba ema 
//ema = ta.ema(close,14)
//plot(ema)

long_rsi = rsi1 > overs

long_rsi_ht = rsi2 > overb2

longCondition = (long_rsi and long_rsi_ht)

// TPS y SL

tp = input.float(140, "Take profit (%)") / 100
sl = input.float(140, "Stop Loss (%)") / 100

longStop = strategy.position_avg_price * (1 - sl)
longTake = strategy.position_avg_price * (1 + tp)

plot(longStop, color=color.red, style=plot.style_linebr , linewidth=2)
plot(longTake, color=color.green, style=plot.style_linebr, linewidth=2)

strategy.entry("Longaniza",strategy.long, when=longCondition)
//plotshape(longCondition,  title = "Buy",  text = 'Buy',  style = shape.labelup,   location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
//alertcondition(longCondition,  "Doble RSI - BUY",  "Doble RSI - BUY")

if strategy.position_avg_price > 0
    strategy.exit("Close longaniza!", stop=longStop, limit=longTake, when=longCondition)`
djfoster21 commented 3 years ago

@AleArdanaz cualquier cosa que se te ocurra, escribila por acá o por el discord