igoooor

Cowabunga V2 Alert Trigger

70
Refer to forums.babypips.com/...cator-post30491.html

This is the converison from mql4 files, credits goes to original poster.
Script de código abierto

Siguiendo el verdadero espíritu de TradingView, el autor de este script lo ha publicado en código abierto, para que los traders puedan entenderlo y verificarlo. ¡Un hurra por el autor! Puede utilizarlo de forma gratuita, aunque si vuelve a utilizar este código en una publicación, debe cumplir con lo establecido en las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

Exención de responsabilidad

La información y las publicaciones que ofrecemos, no implican ni constituyen un asesoramiento financiero, ni de inversión, trading o cualquier otro tipo de consejo o recomendación emitida o respaldada por TradingView. Puede obtener información adicional en las Condiciones de uso.

¿Quiere utilizar este script en un gráfico?
//@version=2
study(title="Cowabunga V2 Alert Trigger", shorttitle="CowabungaV2AlertTrigger", precision=0)
    
fastLength = input(defval=5, title="Fast MA Length", type=integer)
slowLength = input(defval=10, title="Slow MA Length", type=integer)
rsilength = input(defval=9, title="RSI Length", type=integer)
stochlength = input(defval=10, title="Stochastic Length", type=integer)
stirct4H = input(defval=true, title="Strict 4H", type=bool)
price = close

mafast15M = ema(price, fastLength)
maslow15M = ema(price, slowLength)
rsi15M = rsi(price, rsilength)
stoch15M1 = sma(stoch(close, high, low, stochlength), 3)
signal15M1 = sma(stoch15M1, 3)
stoch15M2 = stoch15M1[1]
signal15M2 = signal15M1[1]
[macdLine15M1, signalLine15M1, _] = macd(close, 12, 26, 9)
macdLine15M2 = macdLine15M1[1]
signalLine15M2 = signalLine15M1[1]

OsMA15M1 = macdLine15M1 - signalLine15M1
OsMA15M2 = macdLine15M2 - signalLine15M2

MACDChangebuy = OsMA15M2<0 and OsMA15M2<OsMA15M1
MACDChangesell = OsMA15M2>0 and OsMA15M2>OsMA15M1

mafast4H = security(tickerid, "240", mafast15M)
maslow4H = security(tickerid, "240", maslow15M)
rsi4H = security(tickerid, "240", rsi15M)
stoch4H1 = security(tickerid, "240", stoch15M1)
stoch4H2 = security(tickerid, "240", stoch15M2)
signal4H1 = security(tickerid, "240", signal15M1)
signal4H2 = security(tickerid, "240", signal15M2)

StochCHANGE4Hbuy = (stoch4H1>stoch4H2 and signal4H1>signal4H2) or (stoch4H1>signal4H1) ? 1 : 0
StochCHANGE4Hsell = (stoch4H1<stoch4H2 and signal4H1<signal4H2) or (stoch4H1<signal4H1) ? 1 : 0
StochCHANGE15Mbuy = (stoch15M1>stoch15M2 and signal15M1>signal15M2) or (stoch15M1>signal15M1 and stoch15M2<signal15M2) ? 1 : 0
StochCHANGE15Msell = (stoch15M1<stoch15M2 and signal15M1<signal15M2) or (stoch15M1<signal15M1 and stoch15M2>signal15M2) ? 1 : 0

maCrossover15M = crossover(mafast15M, maslow15M)
maAbove4H = mafast4H > maslow4H
maCrossunder15M = crossunder(mafast15M, maslow15M)
maUnder4H = mafast4H < maslow4H

trendBuyOn = stirct4H ? (maAbove4H and (rsi4H > 50) and StochCHANGE4Hbuy) : maAbove4H
trendSellOn = stirct4H ? (maUnder4H and (rsi4H < 50) and StochCHANGE4Hsell) : maUnder4H

valplot15M = (maCrossover15M and (rsi15M > 50) and StochCHANGE15Mbuy and MACDChangebuy and trendBuyOn ) ? 1 : ((maCrossunder15M and (rsi15M < 50) and StochCHANGE15Msell and MACDChangesell and trendSellOn ) ? 1 : 0)
//1 = buy, -1 = sell

plot(valplot15M, "cowabunga", color=red, linewidth=1, style=line)