Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Would love some help with this study go what I'm trying to do. This simply plots a dashed line and cloud identifying the gap so when I go to the lower timeframes I can see it clearer. So the first thing i want to fix is that it appear on the previous candle but i want the gap to appear on the next candle. I've tried to displace it by one but not getting the result.
The second more complex piece is I would like to extend the high or ow of the gap forward until and only continue to plot it if the gap high or low have not been filled. I tired to add this code but didn't work. I guess i would need to something recursive?
def gapDown = if prevLow > curHigh then 1 else 0;
def gapUp = if curLow > prevHigh then 1 else 0;
plot gH = if gapUp then curLow else if gapDown then prevLow else double.nan;
plot gL = if gapUp then prevHigh else if gapDown then curHigh else double.nan;
gH.SetPaintingStrategy(PaintingStrategy.DASHES);
gH.AssignValueColor(if gapDown then Color.blue else Color.red);
gL.SetPaintingStrategy(PaintingStrategy.DASHES);
gL.AssignValueColor(if gapDown then Color.blue else Color.red);
gH.HideBubble();
gL.HideBubble();
AddCloud(gH, gL, Color.GRAY);
Can you help answer these questions from other members on NexusFi?
def secondsFromOpen = SecondsFromTime(marketOpenTime);
def secondsTillClose = SecondsTillTime(marketCloseTime);
def marketOpen = if secondsFromOpen >= 0 and secondsTillClose >= 0 then 1 else 0;
rec regularHoursOpen = if (secondsFromOpen >= 0 and secondsFromOpen[1] < 0) or
(GetDay() != GetDay()[1]) then open else regularHoursOpen[1];
def newDay = if GetDay() != GetDay()[1] then 1 else 0;
rec regHoursHigh = if newDay then high else if marketOpen then
if high > regHoursHigh[1] then high else regHoursHigh[1] else high;
rec regHoursLow = if newDay then low else if marketOpen then
if low < regHoursLow[1] then low else regHoursLow[1] else low;
def yc = if marketOpen then yesterdaysClose else Double.NaN;
def o = if marketOpen then regularHoursOpen else Double.NaN;
def hg = o + (yc - o) / 2;
def gapUp = if yc < o then 1 else 0;
def gapDown = if yc > o then 1 else 0;
def gapRemaining = if gapUp then
Max(regHoursLow - yc, 0) else
if gapDown then Max(yc - regHoursHigh, 0) else 0;
def percentRemaining = 100 * gapRemaining / AbsValue(yc - o);
def gapFilled = if percentRemaining == 0 then 1 else 0;
def halfGapFilled = if percentRemaining <= 50 then 1 else 0;
plot gH = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then regHoursLow else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then yc else Double.NaN;
plot gL = if (gapUp and !gapFilled and marketOpen and !newDay[-1])
then yc else if (gapDown and !gapFilled and marketOpen and !newDay[-1])
then regHoursHigh else Double.NaN;
plot hGF = if !gapFilled and !halfGapFilled and marketOpen and !newDay[-1]
then hg else Double.NaN;
gH.SetPaintingStrategy(PaintingStrategy.DASHES);
gH.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
gL.SetPaintingStrategy(PaintingStrategy.DASHES);
gL.AssignValueColor(if gapDown then Color.DARK_RED else Color.DARK_GREEN);
hGF.SetStyle(Curve.LONG_DASH);
hGF.SetDefaultColor(Color.DARK_GRAY);
gH.HideBubble();
gL.HideBubble();
hGF.HideBubble();
AddCloud(gH, gL, Color.VIOLET, Color.VIOLET);
AddLabel(yes, Concat(percentRemaining, " % Gap Remaining" ),if percentRemaining > 0 then Color.green else Color.Red);