yolotango

Combo 2/20 EMA & 3 Day Pattern - CME Mini

CME_MINI:ES1!   Contrats à terme E-mini S&P 500
Pulled from
1 month timeframe @ hour intervals, Combo 50 1 1 2005










//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 25/12/2021
// This is combo strategies for get a cumulative signal.
//
// First strategy
// This indicator plots 2/20 exponential moving average. For the Mov
// Avg X 2/20 Indicator, the EMA bar will be painted when the Alert criteria is met.
//
// Second strategy
// This startegy based on 3-day pattern reversal described in "Are Three-Bar
// Patterns Reliable For Stocks" article by Thomas Bulkowski, presented in
// January,2000 issue of Stocks&Commodities magazine.
// That pattern conforms to the following rules:
// - It uses daily prices, not intraday or weekly prices;
// - The middle day of the three-day pattern has the lowest low of the three days, with no ties allowed;
// - The last day must have a close above the prior day's high, with no ties allowed;
// - Each day must have a nonzero trading range.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
EMA20(Length ) =>
pos = 0.0
xPrice = close
xXA = ema(xPrice, Length)
nHH = max(high, high)
nLL = min(low, low)
nXS = iff((nLL > xXA)or(nHH < xXA), nLL, nHH)
pos := iff(nXS > close , -1, iff(nXS < close , 1, nz(pos, 0)))
pos

BarR()=>
pos = 0.0
pos := iff(open > close and high < high and low < low and low > low and high > high, 1,
iff(open < close and high > high and low > low and high < high and low < low, -1, nz(pos, 0)))
pos

strategy(title="Combo 2/20 EMA & 3 Day Pattern", shorttitle="Combo", overlay = true)
var I1 = "●═════ 2/20 EMA ═════●"
Length = input(14, minval=1, group = I1)
//var I2 = "●═════ 3-Bar-Reversal-Pattern ═════●"
var misc = "●═════ MISC ═════●"
reverse = input(false, title="Trade reverse", group = misc)
var timePeriodHeader = "●═════ Time Start ═════●"
d = input(1, title="From Day", minval=1, maxval=31, group=timePeriodHeader)
m = input(1, title="From Month", minval=1, maxval=12, group=timePeriodHeader)
y = input(2005, title="From Year", minval=0, group=timePeriodHeader)

StartTrade = time > timestamp(y, m, d, 00, 00) ? true : false
prePos3Bar = BarR()

posEMA20 = EMA20(Length)
pos3BarR = security(syminfo.tickerid, "D", prePos3Bar, barmerge.gaps_off, barmerge.lookahead_on)
pos = iff(posEMA20 == 1 and pos3BarR == 1 and StartTrade , 1,
iff(posEMA20 == -1 and pos3BarR == -1 and StartTrade, -1, 0))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1 , 1, pos))
if (possig == 1 )
strategy.entry("Long", strategy.long)
if (possig == -1 )
strategy.entry("Short", strategy.short)
if (possig == 0)
strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )
Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.