kibicricket 1 posts msg #121343 - Ignore kibicricket |
8/16/2014 1:24:10 PM
Hey all, I found this board through several different websites. I came across the Yabsi indicator today which I thought was awesome upon first glance, but now realize is almost completely worthless since it prints its signal a few bars after the fact. Can anyone make a mod of the code below to include the same kind of mathematical analysis but have the indicator issue a signal immediately instead of having to wait several bars later?
Code Below -------------------------------------------------------
input signalOffsetFactor = 0.20;
def signalOffset = AvgTrueRange(high,close,low,9)*signalOffsetFactor; plot Data = hlc3;
def triggerSell = if(if(close[-1] < high, 1, 0) and (hlc3[-2] < close[-1] or hlc3[-3] < close[-1]), 1, 0);
def triggerBuy = if(if(close[-1] > low, 1, 0) and (hlc3[-2] > close[-1] or hlc3[-3] > close[-1]), 1, 0);
rec buySellSwitch = if(triggerSell, 1, if(triggerBuy, 0, buySellSwitch[1]));
def thirdBarClosed = if(IsNaN(hlc3[-3]), 0, 1);
plot SBS = if(triggerSell and thirdBarClosed and !buySellSwitch[1], high+signaloffset, if(triggerBuy and thirdBarClosed and buySellSwitch[1],low-signaloffset, double.nan));
SBS.SetStyle(curve.FIRM);
SBS.SetPaintingStrategy(paintingStrategy.LINE_VS_P OINTS);
SBS.SetLineWeight(2);
SBS.AssignValueColor(if triggerSell then
if thirdbarclosed then
#UpPos
CreateColor(255, 0, 0) else
#UpNeg
CreateColor(255, 0, 0)
else if Triggerbuy then
#DnPos
CreateColor(0, 255, 0) else
#DnNeg
CreateColor(0, 255, 0));
|