Script (1)
Script (1)
Script (1)
alert_message}}
//@version=5
pc_id = input.string(title='License ID', defval='', group='MT4/5 Settings', tooltip='This is your license ID')
sps = strategy.position_size
//Bars
is_newbar(sess) =>
is_session(sess) =>
//London
londonNewbar = is_newbar(london)
londonSession = is_session(london)
float londonLow = na
londonLow := if londonSession
if londonNewbar
low
else
math.min(londonLow[1],low)
else
londonLow
float londonHigh = na
londonHigh := if londonSession
if londonNewbar
high
else
math.max(londonHigh[1],high)
else
londonHigh
fill(plotLL, plotLH, color = londonSession and London and bgColor ? LondonColor : na)
bgcolor(londonSession and London and not bgColor ? LondonColor : na,title = "London BG")
//New York
nyNewbar = is_newbar(ny)
nySession = is_session(ny)
float nyLow = na
nyLow := if nySession
if nyNewbar
low
else
math.min(nyLow[1],low)
else
nyLow
float nyHigh = na
nyHigh := if nySession
if nyNewbar
high
else
math.max(nyHigh[1],high)
else
nyHigh
//Misc
//----
src = close
lower = 0.
upper = 0.
trend = 0
//----
dn = hl2 - atr
//----
ama = 0.
//----
from_cross = ta.barssince(ta.cross(hist_,0))
// PARAMETERS {
// WaveTrend
// FUNCTIONS {
// Divergences
f_top_fractal(src) =>
src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]
f_bot_fractal(src) =>
src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]
f_fractalize(src) =>
f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0
f_findDivs(src, topLimit, botLimit, useLimits) =>
fractalTop = f_fractalize(src) > 0 and (useLimits ? src[2] >= topLimit : true) ? src[2] : na
fractalBot = f_fractalize(src) < 0 and (useLimits ? src[2] <= botLimit : true) ? src[2] : na
bearSignal = fractalTop and high[2] > highPrice and src[2] < highPrev
bullSignal = fractalBot and low[2] < lowPrice and src[2] > lowPrev
bearDivHidden = fractalTop and high[2] < highPrice and src[2] > highPrev
bullDivHidden = fractalBot and low[2] > lowPrice and src[2] < lowPrev
// WaveTrend
// Calculates WaveTrend
// } ALERTS
loss_done = ta.change(strategy.losstrades)
from_lost = ta.barssince(loss_done)
f_b = super_b and wt_b and session_ok and sps<=0 and (strategy.losstrades>1?from_lost>=no_tr:true)
f_s = super_s and wt_s and session_ok and sps>=0 and (strategy.losstrades>1?from_lost>=no_tr:true)
//
lowest_ = ta.lowest(swingsl)-buff
highest_ = ta.highest(swingsl)+buff
if f_b
l_sl_ := 0
n_tsl_l := 0
if sps<0
alert(shorta_close,alert.freq_once_per_bar_close)
l_ep := close
l_sl := lowest_*(1-mtbuff)
longa = pc_id + ',buy,' + symbol + ',risk=' + str.tostring(pc_risk, '#.##')+ ',sl=' + str.tostring(l_sl, '#.#####')
+ ',tp=' + str.tostring(l_tp*(1+tpbuff), '#.#####')
l_sl := l_ep*(1+mtbuff)
l_sl_ := 1
l_sl := l_tp*(1-ttpbuff)
l_sl_ := 2
l_sl_ := 3
n_tsl_l := low
f_l_sl =ttpon ? math.max(l_sl,n_tsl_l) :l_sl
if f_s
s_sl_ := 0
n_tsl_s := 99999999
if sps>0
alert(longa_close,alert.freq_once_per_bar_close)
s_ep := close
s_sl := highest_*(1+mtbuff)
// s_sl := s_ep*(1-mtbuff)
s_sl := s_ep*(1-mtbuff)
s_sl_ := 1
s_sl := s_tp*(1+ttpbuff)
s_sl_ := 2
s_sl_ := 3
n_tsl_s := high