input marketOpen = 930;
input marketClose = 1600;
input intraDaySpan = {Default "SameDay" , "OverNight"};
input numberOfDays = 1;
input numberOfYears = 0;
def okToPlot = GetLastDay() - numberOfDays <= GetDay() and GetLastYear() - numberOfYears <= GetYear() ;
def OpenCounter = SecondsFromTime(marketOpen);
def CloseCounter = SecondsTillTime(marketClose);
def MarketHours = if OpenCounter >= 0 and CloseCounter >= 0 then 1 else 0;
def beforeMidnight = OpenCounter >= 0 and CloseCounter <= 0;
def afterMidnight = OpenCounter <= 0 and CloseCounter >= 0 ;
def Today ;
def hideChartBubbles ;
rec DailyHigh ;
rec DailyLow ;
switch (intraDaySpan) {
case "SameDay":
Today = if GetDay() != GetDay()[1] then 1 else 0;
DailyHigh = if MarketHours then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if Today then low else if MarketHours then if low < DailyLow[1] then low else DailyLow[1] else low; hideChartBubbles = MarketHours;
case "OverNight": Today = 0;
DailyHigh = if beforeMidnight or afterMidnight then if high > DailyHigh[1] then high else DailyHigh[1] else high;
DailyLow = if beforeMidnight or afterMidnight then if low < DailyLow[1] then low else DailyLow[1] else low;
hideChartBubbles = beforeMidnight or afterMidnight;
};
def TodaysHigh = if okToPlot and hideChartBubbles then DailyHigh else Double.NaN;
def TodaysLow = if okToPlot and hideChartBubbles then DailyLow else Double.NaN;
#Alert(DailyHigh > DailyHigh[1] and hideChartBubbles, "New High", Alert.BAR, Sound.RING);
#Alert(DailyLow < DailyLow[1] and hideChartBubbles, "New Low", Alert.BAR, Sound.RING);
# use this to scan for new intraday highs
plot scan = DailyHigh > DailyHigh[1] and hideChartBubbles;
# use this to scan for new intraday lows
#plot scan = DailyLow < DailyLow[1] and hideChartBubbles;
you stated:yeah I'm still looking for the code logic to flag a lower study making a new high where price does not. If anyone can help here, would be greatly appreciated!
Thanks for the response, XeoNoX. Unfortunately, you misread what I wrote. I was looking for logic where the lower study makes a new high and the price on the upper chart closes at a price that is NOT the high over the last 'x' bars. A kind of divergence, if you will. Looking for a lower study to potentially show a move up before the price indicates as such.you stated:
" lower study making a new high where price does not. "
"newer high where price does not"
you cant have a newer high price when the price does not go high, thats not possible.
And if you mean when the candle made a new high but the price is not at the high, then that can be simplified by price is not at the high.
since you didnt define lower study, here is the general way you would code it.Thanks for the response, XeoNoX. Unfortunately, you misread what I wrote. I was looking for logic where the lower study makes a new high and the price on the upper chart closes at a price that is NOT the high over the last 'x' bars. A kind of divergence, if you will. Looking for a lower study to potentially show a move up before the price indicates as such.
def study1 = close is less than high within 8 bars;
def study2 = lower studymakes new high;
plot scan = study1 and study2 is true;
i posted a code somewhere on the forums that you can set the time and it would grab the high, low, open. It may had been labeled premarket or aftermarket high low close, but you could change the time frame.Hi there. I'm looking to get the the trading day's (08:30CT to 14:00CT) low, high and close (3 values per day) for a number of Futures contracts as well as selected stocks. Right now, i'm having to do it manually. Is there an easier way to do this on ToS? I can go to the daily chart and get the low, high and close but it appears to include the extended trading timeframe (before 08:30CT and after 14:00CT.) Grateful for your advise/knowhow on this one. Thanks!
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?since you didnt define lower study, here is the general way you would code it.
Code:def study1 = close is less than high within 8 bars; def study2 = lower studymakes new high; plot scan = study1 and study2 is true;
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?
Also, when trying to scan, that 2nd line says it's an invalid statement:
def study2 = RelativeStrength makes new high;
Any ideas? Thanks again, XeoNox!
declare lower;
input Opentime1 = 0930;
input Endtime1 = 1600;
def ActiveTime = if GetLastDay() == GetDay() and SecondsFromTime(Opentime1) >= 0 and SecondsFromTime(Endtime1) < 0 then 1 else 0;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;
def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def study1 = close is less than high within 8 bars;
plot highestrelvolofday = highestall(if GetLastDay() == GetDay() and highestall(relvol) then (relvol) else double.nan);
def hhBar = if relvol==highestrelvolofday then BarNumber() else hhBar[1];
plot scan = hhbar;
RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
RelVol.SetLineWeight(3);
RelVol.DefineColor("Above", GetColor(0));
RelVol.DefineColor("Below", GetColor(2));
RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below"));
plot greenArrow = hhBar;
greenArrow.SetDefaultColor(Color.GREEN);
greenArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
label or lines is fine, i can work with either. is the code you mention the one below from 10:11pm?i posted a code somewhere on the forums that you can set the time and it would grab the high, low, open. It may had been labeled premarket or aftermarket high low close, but you could change the time frame.
you also didn't specify if you were trying to use a label or draw lines... it sounds like you just want a label with the current day high, current day low, and current day close ?
Ha, appreciate the response, but you read Relative Volume where I wrote Relative Strength. Any chance you would be able to take a shot at this? As always, very much appreciated.you didnt specify when relative volume makes a new high, so i assumed you meant in the same day.
the code below rarely triggers, so i left out the first study of new high but price does not. if you want to include the first study simply change
plot greenArrow = hhBar;
to
plot greenArrow = hhBar and study1;
Code:declare lower; input Opentime1 = 0930; input Endtime1 = 1600; def ActiveTime = if GetLastDay() == GetDay() and SecondsFromTime(Opentime1) >= 0 and SecondsFromTime(Endtime1) < 0 then 1 else 0; input length = 60; input numDev = 2.0; input allowNegativeValues = no; def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length); plot RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol); def study1 = close is less than high within 8 bars; plot highestrelvolofday = highestall(if GetLastDay() == GetDay() and highestall(relvol) then (relvol) else double.nan); def hhBar = if relvol==highestrelvolofday then BarNumber() else hhBar[1]; plot scan = hhbar; RelVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM); RelVol.SetLineWeight(3); RelVol.DefineColor("Above", GetColor(0)); RelVol.DefineColor("Below", GetColor(2)); RelVol.AssignValueColor(if RelVol >= numDev then RelVol.Color("Above") else RelVol.Color("Below")); plot greenArrow = hhBar; greenArrow.SetDefaultColor(Color.GREEN); greenArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
There are many stocks that exhibit new RS line highs where price is consolidating (i.e., "not making a new high"), and some do multiple times a year. It's a leading indicator for a stock to make a move up in the near-term. Anyway, I hope you grasp that and don't mind providing the code logic for it! Your willingness to help UTS members ver and over is incredibly admirable...thank you."Relative Strength line lower study to make a new high where price does not,"
new high as defined would mean the Relative strength would never go down and would only record higher numbers (new highs) meaning it would only go up to infinite, therefore your scan theory although possible would never trigger unless it a newly listed asset.
I'm looking for the standard Relative Strength line lower study to make a new high where price does not, but I want to code in an arrow to show where this occurs on the lower study. Any idea what that might look like?
Also, when trying to scan, that 2nd line says it's an invalid statement:
def study2 = RelativeStrength makes new high;
Any ideas? Thanks again, XeoNox!
close is less than high within 8 bars and RelativeStrength()."RS" is greater than RelativeStrength()."RS" from 1 bars ago
def RH = SecondsFromTime(0900) >= 0 && SecondsTillTime(1600) > 0;
def h = if RH then highest(high) else h[1];
def l = if RH then lowest(low) else l[1];
plot hi = h;
hi.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot lo = l;
lo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
def RH = SecondsFromTime(0900) >= 0 && SecondsTillTime(1600) > 0;
def h = if RH then high(period = "Day") else double.nan;
def l = if RH then low(period = "Day") else double.nan;
plot hi = h;
hi.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot lo = l;
lo.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.