after market & pre market high low lines help

shih90

Member
VIP
I need help to display HL LINES of after & pre Market but it displays only today frame time . Thank You
 
Maybe this will help...

BnS91rXt7RSgA84ERxvH6J2eKufZgIWWXimoBKVAYHGuSkb34AqiHaVEA681vDFWkTo2bi8EcHMqOkg9CXfktheSLKT8K2Tjfyq4aQjFsJtZV2ApAYpKBV1B6S2ajzZmF2yAZ3CXpsP7RH4oT5ajixA



#PostAndRegularTradingStudy
Code:
#PostAndRegularTradingStudy


def activerth = RegularTradingStart(GetYYYYMMDD()) - GetTime() < 0 and RegularTradingEnd(GetYYYYMMDD()) - GetTime() > 0;
input bubble = yes;
DefineGlobalColor("RTHOPEN", Color.white);
DefineGlobalColor("RTHCLOSE", Color.GRAY);
DefineGlobalColor("RTHLOW", Color.orange);
DefineGlobalColor("RTHHIGH", Color.light_green);
DefineGlobalColor("AFTERRTHHIGH", Color.GREEN);
DefineGlobalColor("AFTERRTHLOW", Color.RED);



def h = high;
def l = low;
def o = open;
def c = close ;
def bar = BarNumber();
def RTHOpen = if activerth and !activerth[1]  then o else  RTHOpen[1];
def RTHClose = if !activerth and activerth[1]  then c else  RTHClose[1];

plot rtho = RTHOpen ;
 rtho.SetPaintingStrategy(PaintingStrategy.POINTS );
 rtho.SetDefaultColor(GlobalColor("RTHOPEN"));

plot rthc =   RTHClose;
 rthc.SetPaintingStrategy(PaintingStrategy.POINTS );
 rthc.SetDefaultColor(GlobalColor("RTHCLOSE"));

def RTHLow = if activerth and !activerth[1] then l
 else if activerth and l < RTHLow[1] then l else RTHLow[1];

def pRTHLow = if activerth <> activerth[1] then RTHLow[1] else pRTHLow[1];

def RTHhigh = if activerth and !activerth[1] then h
 else if activerth and h > RTHhigh[1] then h else RTHhigh[1];

def pRTHhigh = if activerth <> activerth[1] then RTHhigh[1] else pRTHhigh[1];
plot ll = if !activerth then RTHLow
else if activerth then pRTHLow else double.nan;
 ll.SetPaintingStrategy(PaintingStrategy.Squares);
 ll.SetDefaultColor(GlobalColor("RTHLOW"));

def PLValue = if !IsNaN(ll) then ll else PLValue[1];
def PLBarOrigin = if !IsNaN(ll) then bar else PLBarOrigin[1];
addchartbubble(bubble and if Bar == HighestAll(PLBarOrigin) then PLBarOrigin else Double.NaN, PLValue,"PrevRTH,Low",GlobalColor("RTHLOW"));

plot hh = if  !activerth then RTHhigh  else if activerth  then pRTHhigh else double.nan;
 hh.SetPaintingStrategy(PaintingStrategy.Squares);
 hh.SetDefaultColor(GlobalColor("RTHHIGH"));

def PHBarOrigin = if !IsNaN(hh) then bar else PHBarOrigin[1];
def PHValue = if !IsNaN(hh) then hh else PHValue[1];
addchartbubble(bubble and if Bar == HighestAll(PHBarOrigin) then PHBarOrigin else Double.NaN, PHValue,"PrevRTH,High",GlobalColor("RTHHIGH"));

def aRTHhigh = if !activerth and activerth[1] then h
 else if !activerth and h > aRTHhigh[1] then h
 else aRTHhigh[1];

def aRTHLow = if !activerth and activerth[1] then l 
else if !activerth and l < aRTHLow[1] then l
else aRTHLow[1];

plot ahh = if  activerth  then aRTHhigh else double.nan;
 ahh.SetPaintingStrategy(PaintingStrategy.POINTS );
 ahh.SetDefaultColor(GlobalColor("AFTERRTHHIGH")); 
def APHBarOrigin = if !IsNaN(ahh) then bar else APHBarOrigin[1];
def APHValue = if !IsNaN(Ahh) then Ahh else APHValue[1];
addchartbubble(bubble and if Bar == HighestAll(APHBarOrigin) then APHBarOrigin else Double.NaN, APHValue,"PreRTH,High",GlobalColor("AFTERRTHHIGH"));


plot all = if activerth then aRTHLow else double.nan;
 all.SetPaintingStrategy(PaintingStrategy.POINTS);
 all.SetDefaultColor(GlobalColor("AFTERRTHLOW"));

def APLBarOrigin = if !IsNaN(aLL) then bar else APLBarOrigin[1];
def APLValue = if !IsNaN(aLL) then aLL else APLValue[1];
addchartbubble(bubble and if Bar == HighestAll(APLBarOrigin) then APLBarOrigin else Double.NaN, APLValue,"PreRTH,Low",GlobalColor("AFTERRTHLOW"));



script ExtendLine {
    input value = close;
    def bar = BarNumber();
    def slope;
    def lastValue;
    def lastBar;
    plot Line;

    if !IsNaN(value) {
        slope = value - value[1];
        lastValue = value;
        lastBar = bar;
        Line = Double.NaN;
    } else {
        slope = slope[1];
        lastValue = lastValue[1];
        lastBar = lastBar[1];
        Line = (bar - lastBar) * slope + lastValue;
    }
}


plot llX = ExtendLine(pRTHLow);
llX.setDefaultColor(Color.orange);
llX.SetLineWeight(2);
llX.SetStyle(Curve.SHORT_DASH);


plot llXx = ExtendLine(RTHLow);
llXx.setDefaultColor(Color.light_red);
llXx.SetLineWeight(2);
llXx.SetStyle(Curve.SHORT_DASH);
def llxxBarOrigin = if !IsNaN(llxx) then bar else llxxBarOrigin[1];
def llxxValue = if !IsNaN(llxx) then llxx else llxxValue[1];
addchartbubble(bubble and if Bar == HighestAll(llxxBarOrigin) then llxxBarOrigin else Double.NaN, llxxValue," RTH,Low",GlobalColor("RTHLOW"));

plot hhX = ExtendLine(pRTHhigh);
hhX.setDefaultColor(Color.LIGHT_green);
hhX.SetLineWeight(2);
hhX.SetStyle(Curve.SHORT_DASH);

plot hhXx = ExtendLine(RTHhigh);
hhXx.setDefaultColor(Color.LIGHT_green);
hhXx.SetLineWeight(2);
hhXx.SetStyle(Curve.SHORT_DASH);

def hhxxBarOrigin = if !IsNaN(hhxx) then bar else hhxxBarOrigin[1];
def hhxxValue = if !IsNaN(hhxx) then hhxx else hhxxValue[1];
addchartbubble(bubble and if Bar == HighestAll(hhxxBarOrigin) then hhxxBarOrigin else Double.NaN, hhxxValue," RTH,High",GlobalColor("RTHHIGH"));



plot AllX = ExtendLine(all);
AllX.setDefaultColor(Color.pink);
AllX.SetLineWeight(2);
AllX.SetStyle(Curve.SHORT_DASH);

plot AhhX = ExtendLine(ahh);
AhhX.setDefaultColor(Color.dark_green);
AhhX.SetLineWeight(2);
AhhX.SetStyle(Curve.SHORT_DASH);
 
Last edited:
I need help to display HL LINES of after & pre Market but it displays only today frame time . Thank You

Here is another method with just the after & pre Market HLs, with optional, movable bubbles and an option to show today's only

Screenshot 2024-02-28 070832.png
Code:
#After_PreMarket_HL_TimeRange_using_ProfileHL

input showtodayonly = no;

input afterbegin = 1600;
input afterend   = 2359;

input pricePerRowHeightMode = {AUTOMATIC, default TICKSIZE};
def height;
switch (pricePerRowHeightMode) {
case AUTOMATIC:
    height = PricePerRow.AUTOMATIC;
case TICKSIZE:
    height = PricePerRow.TICKSIZE;
}

def afterrth  = if isnan(close) then afterrth[1] else SecondsFromTime(afterbegin) >= 0 and SecondsTillTime(afterend) > 0;
def aftercond = afterrth != afterrth[1];

profile aftervol = VolumeProfile("startNewProfile" = aftercond and secondstilltime(afterend)>=0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


profile aftervol1 = VolumeProfile("startNewProfile" = aftercond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


def afterhProfile = if IsNaN(aftervol.GetHighest()) then afterhProfile[1] else aftervol1.GetHighest();
def afterlProfile = if IsNaN(aftervol.GetLowest())  then afterlProfile[1] else aftervol1.GetLowest();
def afteruprof    = if !afterrth or IsNaN(close) then afteruprof[1] else afterhProfile;
def afterlprof    = if !afterrth or IsNaN(close) then afterlprof[1] else afterlProfile;

plot afterHigh =  if showtodayonly and getday()!=getlastday() then double.nan else afteruprof;
plot afterLow  =  if showtodayonly and getday()!=getlastday() then double.nan else afterlprof;

afterHigh.SetDefaultColor(Color.GREEN);
afterLow.SetDefaultColor(Color.RED);
afterHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
afterLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);


#HL_TimeRange_using_ProfileHL

input prebegin = 0400;
input preend   = 0929;

def prerth  = if isnan(close) then prerth[1] else SecondsFromTime(prebegin) >= 0 and SecondsTillTime(preend) > 0;
def precond = prerth != prerth[1];

profile prevol = VolumeProfile("startNewProfile" = precond and secondstilltime(preend)>=0, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


profile prevol1 = VolumeProfile("startNewProfile" = precond, "onExpansion" = no, "numberOfProfiles" = 1000, pricePerRow = height);


def prehProfile = if IsNaN(prevol.GetHighest()) then prehProfile[1] else prevol1.GetHighest();
def prelProfile = if IsNaN(prevol.GetLowest())  then prelProfile[1] else prevol1.GetLowest();
def preuprof    = if !prerth or IsNaN(close) then preuprof[1] else prehProfile;
def prelprof    = if !prerth or IsNaN(close) then prelprof[1] else prelProfile;

plot preHigh = if showtodayonly and getday()!=getlastday() then double.nan else preuprof;
plot preLow  = if showtodayonly and getday()!=getlastday() then double.nan else prelprof;

preHigh.SetDefaultColor(Color.GREEN);
preLow.SetDefaultColor(Color.RED);
preHigh.SetPaintingStrategy(PaintingStrategy.POINTS);
preLow.SetPaintingStrategy(PaintingStrategy.POINTS);

input bubble = yes;
input bubblemover = 2;
def   mover = bubble and IsNaN(close[bubblemover]) and !IsNaN(close[bubblemover + 1]);

#After
AddChartBubble(bubble and secondsfromTime(1600)[bubblemover-1]==0, afterHigh[bubblemover],  "AH: " + AsText(afterHigh[bubblemover]), afterHigh.TakeValueColor());
AddChartBubble(bubble and secondsfromTime(1600)[bubblemover-1]==0, afterlow[bubblemover],  "AL: " + AsText(afterlow[bubblemover]), afterlow.TakeValueColor());

AddChartBubble(bubble and mover, afterHigh[bubblemover], "AH: " + AsText(afterHigh[bubblemover]),  afterHigh.TakeValueColor());
AddChartBubble(bubble and mover, afterlow[bubblemover],  "AL: " + AsText(afterlow[bubblemover]),  afterlow.TakeValueColor());

#Pre
AddChartBubble(bubble and !IsNaN(close) and getday()[bubblemover]!=getday()[bubblemover-1], preHigh[bubblemover],  "PH: " + AsText(preHigh[bubblemover]), preHigh.TakeValueColor());
AddChartBubble(bubble and !IsNaN(close) and getday()[bubblemover]!=getday()[bubblemover-1], prelow[bubblemover],  "PL: " + AsText(prelow[bubblemover]), prelow.TakeValueColor());

AddChartBubble(bubble and mover, preHigh[bubblemover], "PH: " + AsText(preHigh[bubblemover]),  preHigh.TakeValueColor());
AddChartBubble(bubble and mover, prelow[bubblemover],  "PL: " + AsText(prelow[bubblemover]),  prelow.TakeValueColor());

#
 
I need help to display HL LINES of after & pre Market but it displays only today frame time . Thank You
what are hl lines?
what is 'it' ? ...but it displays... what study have you tried? post it.

spell it out what you want.
when do you want to see lines?
do you want,
lines at the highest and lowest prices of 6:30am to 9:30am,
and another set of highest & lowest lines, during 4p to 8pm ?


@Ramisegal can you explain what those lines are ? i have no idea
 
what are hl lines?
what is 'it' ? ...but it displays... what study have you tried? post it.

spell it out what you want.
when do you want to see lines?
do you want,
lines at the highest and lowest prices of 6:30am to 9:30am,
and another set of highest & lowest lines, during 4p to 8pm ?


@Ramisegal can you explain what those lines are ? i have no idea
I will add bubble help to the script but your first clue to the lines are the global color declarations. Trading hours open close highest high lowest low extended into after hours and the after hours highest high and low extended into the regular trading hours.
 
what are hl lines?
what is 'it' ? ...but it displays... what study have you tried? post it.

spell it out what you want.
when do you want to see lines?
do you want,
lines at the highest and lowest prices of 6:30am to 9:30am,
and another set of highest & lowest lines, during 4p to 8pm ?


@Ramisegal can you explain what those lines are ? i have no idea

1710482479167.png


Modified code with the bubbles...

Code:
#PostAndRegularTradingStudy
 
def activerth = RegularTradingStart(GetYYYYMMDD()) - GetTime() < 0 and RegularTradingEnd(GetYYYYMMDD()) - GetTime() > 0;
input bubble = yes;
DefineGlobalColor("RTHOPEN", Color.white);
DefineGlobalColor("RTHCLOSE", Color.GRAY);
DefineGlobalColor("RTHLOW", Color.orange);
DefineGlobalColor("RTHHIGH", Color.light_green);
DefineGlobalColor("AFTERRTHHIGH", Color.GREEN);
DefineGlobalColor("AFTERRTHLOW", Color.RED);
DefineGlobalColor("HIGH", Color.dark_GREEN);
DefineGlobalColor("LOW", Color.dark_red);


def h = high; 
def l = low; 
def o = open;
def c = close ;
def bar = BarNumber();
def RTHOpen = if activerth and !activerth[1]  then o else  RTHOpen[1];
def RTHClose = if !activerth and activerth[1]  then c else  RTHClose[1];

plot rtho = RTHOpen ; 
 rtho.SetPaintingStrategy(PaintingStrategy.POINTS ); 
 rtho.SetDefaultColor(GlobalColor("RTHOPEN")); 
addchartbubble(bubble and rtho==rtho[1] and isNaN(close[2]) and !isNaN(close[3]), rtho,"Open",GlobalColor("RTHOPEN"));

plot rthc =   RTHClose; 
 rthc.SetPaintingStrategy(PaintingStrategy.POINTS ); 
 rthc.SetDefaultColor(GlobalColor("RTHCLOSE")); 
addchartbubble(bubble and rthc==rthc[1] and isNaN(close[3]) and !isNaN(close[4]), rthc,"Close",GlobalColor("RTHCLOSE"));



def RTHLow = if activerth and !activerth[1] then l 
 else if activerth and l < RTHLow[1] then l else RTHLow[1]; 

def pRTHLow = if activerth <> activerth[1] then RTHLow[1] else pRTHLow[1];

def RTHhigh = if activerth and !activerth[1] then h 
 else if activerth and h > RTHhigh[1] then h else RTHhigh[1]; 

def pRTHhigh = if activerth <> activerth[1] then RTHhigh[1] else pRTHhigh[1];


plot ll = if !activerth then RTHLow 
else if activerth then pRTHLow else double.nan; 
 ll.SetPaintingStrategy(PaintingStrategy.Squares); 
 ll.SetDefaultColor(GlobalColor("RTHLOW"));

def PLValue = if !IsNaN(ll) then ll else PLValue[1];
def PLBarOrigin = if !IsNaN(ll) then bar else PLBarOrigin[1];

addchartbubble(bubble and if Bar == HighestAll(PLBarOrigin) then PLBarOrigin else Double.NaN, PLValue,"PrevRTH,Low",GlobalColor("RTHLOW"));

plot hh = if  !activerth then RTHhigh  else if activerth  then pRTHhigh else double.nan; 
 hh.SetPaintingStrategy(PaintingStrategy.Squares); 
 hh.SetDefaultColor(GlobalColor("RTHHIGH")); 

def PHBarOrigin = if !IsNaN(hh) then bar else PHBarOrigin[1];
def PHValue = if !IsNaN(hh) then hh else PHValue[1];

addchartbubble(bubble and if Bar == HighestAll(PHBarOrigin) then PHBarOrigin else Double.NaN, PHValue,"PrevRTH,High",GlobalColor("RTHHIGH"));


def aRTHhigh = if !activerth and activerth[1] then h 
 else if !activerth and h > aRTHhigh[1] then h 
 else aRTHhigh[1];

def aRTHLow = if !activerth and activerth[1] then l  
else if !activerth and l < aRTHLow[1] then l
else aRTHLow[1];

def paRTHhigh = if activerth <> activerth[1] then aRTHhigh[1] else paRTHhigh[1];
def paRTHLow = if activerth <> activerth[1] then aRTHLow[1] else paRTHLow[1];

plot ahh = if  activerth  then aRTHhigh else if !activerth then paRTHhigh else double.nan; 
 ahh.SetPaintingStrategy(PaintingStrategy.POINTS ); 
 ahh.SetDefaultColor(GlobalColor("AFTERRTHHIGH"));  
def APHBarOrigin = if !IsNaN(ahh) then bar else APHBarOrigin[1];
def APHValue = if !IsNaN(Ahh) then Ahh else APHValue[1];
addchartbubble(bubble and if Bar == HighestAll(APHBarOrigin) then APHBarOrigin else Double.NaN, APHValue,"PreRTH,High",GlobalColor("AFTERRTHHIGH"));


plot all = if activerth then aRTHLow else if !activerth then paRTHLow else double.nan; 
 all.SetPaintingStrategy(PaintingStrategy.POINTS); 
 all.SetDefaultColor(GlobalColor("AFTERRTHLOW")); 

def APLBarOrigin = if !IsNaN(aLL) then bar else APLBarOrigin[1];
def APLValue = if !IsNaN(aLL) then aLL else APLValue[1];
addchartbubble(bubble and if Bar == HighestAll(APLBarOrigin) then APLBarOrigin else Double.NaN, APLValue,"PreRTH,Low",GlobalColor("AFTERRTHLOW"));


plot _ll  =  highestAll(if isNaN(close[-1]) 
                               then if activerth then  RTHLow else aRTHLow
else double.nan); 
 _ll.SetStyle(Curve.SHORT_DASH); 
 _ll.SetDefaultColor(GlobalColor("LOW"));
addchartbubble(bubble and _ll==_ll[1] and isNaN(close[4]) and !isNaN(close[5]), _ll,"Lowest",GlobalColor("LOW"));

plot _hh = highestAll(if isNaN(close[-1]) 
                               then if activerth then  RTHhigh else aRTHhigh
                               else Double.NaN);
 _hh.SetStyle(Curve.SHORT_DASH);
 _hh.SetDefaultColor(GlobalColor("HIGH")); 

addchartbubble(bubble and _hh==_hh[1] and isNaN(close[4]) and !isNaN(close[5]), _hh,"Highest",GlobalColor("HIGH"));
 

Attachments

  • 1709149146595.png
    1709149146595.png
    259.9 KB · Views: 173
  • 1710482455544.png
    1710482455544.png
    320.2 KB · Views: 125
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
292 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top