NexusFi: Find Your Edge


Home Menu

 





daily gap study help


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one Lady with 2 posts (0 thanks)
    2. looks_two Blotty with 1 posts (0 thanks)
    3. looks_3 msko with 1 posts (0 thanks)
    4. looks_4 cookie75 with 1 posts (0 thanks)
    1. trending_up 2,939 views
    2. thumb_up 0 thanks given
    3. group 5 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread

daily gap study help

  #1 (permalink)
cookie75
Toronto Ontario
 
Posts: 5 since Jul 2012
Thanks Given: 0
Thanks Received: 1

Hi All

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?

Any help would be awesome!

Thanks

AA


#def forward = 30;

#def na = Double.NaN;
#def lfor = Lowest(low, forward)[-forward];
#def hfor = Highest(high, forward)[-forward];

#def gapDown = if prevLow > curHigh and prevlow > hfor then 1 else 0;
#def gapUp = if curLow > prevHigh and curlow < lfor then 1 else 0;


===================================
#Daily Gap Plot

declare upper;
input aggregationPeriod = AggregationPeriod.DAY;
input displace = -1;

def curHigh = high(period = aggregationPeriod);
def curLow = low(period = aggregationPeriod);
def prevLow = low(period = aggregationPeriod)[-1];
def prevHigh = high(period = aggregationPeriod)[-1];

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);

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
PowerLanguage & EasyLanguage. How to get the platfor …
EasyLanguage Programming
MC PL editor upgrade
MultiCharts
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #2 (permalink)
Blotty
Boston, MA
 
Posts: 2 since Jan 2014
Thanks Given: 0
Thanks Received: 0

Ever figure this out? I'm trying to do the same.

Reply With Quote
  #3 (permalink)
msko
Vancouver + B.C./Canada
 
Posts: 4 since Feb 2018
Thanks Given: 0
Thanks Received: 0



Blotty View Post
Ever figure this out? I'm trying to do the same.

me too, anyone?

Reply With Quote
  #4 (permalink)
xexykid
Colombo + Sri Lanka
 
Posts: 1 since Apr 2020
Thanks Given: 1
Thanks Received: 0

Yep, I too am looking to do this, still no one figured it out?

Reply With Quote
  #5 (permalink)
 Lady 
Medellín, CO
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Playing with eMinis, coming from Options
Posts: 83 since Jun 2015
Thanks Given: 14
Thanks Received: 43

# TS_GapFill
# [email protected]
# Last Update 28 Jan 2010
# Last Update 16 Jan 2019 by Jerry Investor

input marketOpenTime = 0930;
input marketCloseTime = 1615;

def yesterdaysClose = close(period = "DAY" )[1];

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);

Reply With Quote
  #6 (permalink)
 Lady 
Medellín, CO
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Playing with eMinis, coming from Options
Posts: 83 since Jun 2015
Thanks Given: 14
Thanks Received: 43

That code will give you gaps on lower time frames but it does address your 2nd part.

I have not tried to convert it to higher time frames.

Reply With Quote




Last Updated on May 25, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts