只有当1M发生交叉而5M的指示器低于零线时,才使用1M和5M上的一个指示器来获得信号。
为1M和5M创建了tickerID和安全性,并为1M和指标<0使用了crossover()并将它们组合在一起。
//@version=3
study(title="Sobh-New-HA-Study-Short", shorttitle="Sobh-New-HA-Study-Short", overlay=true)
///////////////// START Getting the HA candle /////////////////
openHA = security(heikinashi(tickerid), period, open)
closeHA = security(heikinashi(tickerid), period, close)
highHA = security(heikinashi(tickerid), period, high)
lowHA = security(heikinashi(tickerid), period, low)
////////////
haTicker = heikinashi(tickerid)
haOpenValue(r) => security(haTicker, r, open)
haCloseValue(r) => security(haTicker, r, close)
halowValue(r) => security(haTicker, r, low)
hahighValue(r) => security(haTicker, r, high)
Close1MHA=haCloseValue("1")
Open1MHA=haOpenValue("1")
High1MHA=hahighValue("1")
Low1MHA=halowValue("1")
Close5MHA=haCloseValue("5")
Open5MHA=haOpenValue("5")
High5MHA=hahighValue("5")
Low5MHA=halowValue("5")
///////////////////////////////////////////////////////////////////////
study(title="WaveTrend [LazyBear]", shorttitle="WT_LB")
n1 = input(10, "Channel Length")
n2 = input(21, "Average Length")
obLevel1 = input(60, "Over Bought Level 1")
obLevel2 = input(53, "Over Bought Level 2")
osLevel1 = input(-60, "Over Sold Level 1")
osLevel2 = input(-53, "Over Sold Level 2")
////////////////////////////////1MIN////////////////////////////////////////
ap1HA = (High1MHA + Low1MHA + Close1MHA)/3
esa1HA = ema(ap1HA, n1)
d1HA = ema(abs(ap1HA - esa1HA), n1)
ci1HA = (ap1HA - esa1HA) / (0.015 * d1HA)
tci1HA = ema(ci1HA, n2)
wt1HA = tci1HA //// Green Indicator
wt2HA = sma(wt1HA,4) //// Red Indicator
//////////////////////////5MIN///////////////////////////////////
apHA = (High5MHA + Low5MHA + Close5MHA)/3
esaHA = ema(apHA, n1)
dHA = ema(abs(apHA - esaHA), n1)
ciHA = (apHA - esaHA) / (0.015 * dHA)
tciHA = ema(ciHA, n2)
wt5HAOne = tciHA //// Green Indicator
wt5HATwo = sma(wt5HAOne,4) //// Red Indicator
ema2005MHA = ema(Close5MHA, 200)
plot(ema(close, 200),linewidth=4,transp=0,color=orange)
//////////////////////////// SMA 50 //////////////////////////////
lenSimple = input(50, minval=1)
srcSimple = input(close)
sma50 = sma(srcSimple, lenSimple)
/////////////////////////////////////////////////////////////////
plot(sma50, color=aqua, linewidth=4,title="SMA 50",transp=0)
/////////////////////
PriceCloseAboveSMA50= Close5MHA > sma50
PriceCloseBelow50SMA= sma50 > Close5MHA
BearMarket= ema2005MHA > sma50
BullMArket= sma50 > ema2005MHA
wt5HAOneBelowZero= wt5HATwo < 0
Buy = wt5HAOneBelowZero and crossover(wt1HA,wt2HA)
Sell = crossunder(wt5HAOne,wt5HATwo)
plotshape(Buy ,location=location.top, style=shape.diamond, color=lime, size=size.small)
plotshape(Sell ,location=location.top, style=shape.diamond, color=red, size=size.small)
仅当指标wt1HA超过wt2HA时,我才应绘制石灰钻石(买入)信号,仅当wt5HATwo <0时才绘制。
但是我得到的是关于5M是高于还是低于零的交叉发生时在1M上的信号
我附上了图像,该图像表明在1M(数字1)和(数字2)上发生了信号,但是正如您在5M上确切的时间是指示器高于0(数字3看到零线)所示。因此,不应将1M上的此信号打印为1M上的绿色石灰钻石。