Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[STRATEGY] Double Scalper #33

Open
djfoster21 opened this issue Nov 10, 2021 · 1 comment
Open

[STRATEGY] Double Scalper #33

djfoster21 opened this issue Nov 10, 2021 · 1 comment
Assignees

Comments

@djfoster21
Copy link
Collaborator

djfoster21 commented Nov 10, 2021

// 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 djfoster21 self-assigned this Nov 10, 2021
@djfoster21 djfoster21 added this to Strategies & Indicators in Strategies & Indicators Nov 10, 2021
@djfoster21
Copy link
Collaborator Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Strategies & Indicators
Strategies & Indicators
Development

No branches or pull requests

1 participant