$ADD High/ Low Daily plots

timetraveler

New member
VIP
Hello,

Can anyone help with this script?

What I'm trying to do is plot the Daily high for the $ADD as the Green Dashed Line on top and the Red line at the Low. The problem I'm having (seen in the attached photo) is that the High and Low is being plotted for the entire time frame that the chart displays. I'm trying to have the High/ Low plots start fresh each day, in other words: still be able to view multiple days at once but have the plots positioned for the High and Low of EACH day.

I really appreciate the help.

Here is my code following the image:




2023 11 14.jpg


input openingRangeStartTimeEST = 0930;

input openingRangeEndTimeEST = 1600;

input EndTimeEST = 1600;

plot info = open(symbol = "$ADD");

info.SetLineWeight(2);
info.SetPaintingStrategy(PaintingStrategy.LINE);
info.AssignValueColor(if info > info[1] then Color.DARK_GREEN


else if


info < info[1]


then Color.RED


else CreateColor(75, 75, 75));



def ADD = GetSymbol() == "$ADD";

def today = GetDay() != GetDay()[-1];

def percent = Round (info / 2800) * 100;

def high = HighestAll(info);

def low = LowestAll(info);

def openingRange = if SecondsTillTime(openingRangeStartTimeEST) <= 0 and SecondsTillTime(openingRangeEndTimeEST) >= 0 then 1 else 0;

def openingRangeHigh = if SecondsTillTime(openingRangeStartTimeEST) == 0 then high else if openingRange and high > openingRangeHigh[1] then high else openingRangeHigh[1];

def openingRangeLow = if SecondsTillTime(openingRangeStartTimeEST) == 0 then low else if openingRange and low < openingRangeLow[1] then low else openingRangeLow[1];

def StartTimeEST = openingRangeStartTimeEST;
def Range = if SecondsTillTime(StartTimeEST) <= 0 and SecondsTillTime(EndTimeEST) >= 0 then 1 else 0;

plot HighExtension = if Range then openingRangeHigh else Double.NaN;
plot LowExtension = if Range then openingRangeLow else Double.NaN;

HighExtension.SetStyle(Curve.LONG_DASH);
HighExtension.SetLineWeight(1);
HighExtension.AssignValueColor( Color.GREEN);
LowExtension.SetStyle(Curve.LONG_DASH);
LowExtension.SetLineWeight(1);
LowExtension.AssignValueColor( Color.RED);
 
Solution
UPDATE:

Seems to be working now:


declare lower;


input symbol = "$ADD";


def nan = Double.NaN;
def o = open(symbol = symbol);
def c = close(symbol = symbol);
def h = High(symbol = symbol, period = AggregationPeriod.DAY) ;
def l = low(symbol = symbol, period = AggregationPeriod.DAY) ;

AddChart(high = if c > o then h else nan,
low = if c > o then l else nan,
close = if c > o then c else nan,
open = if c > o then o else nan,
ChartType.LINE, Color.GREEN);
AddChart(high = if c < o then h else nan,
low = if c < o then l else nan,
open = if c < o then o else nan,
close = if c < o then c else nan,
ChartType.LINE, Color.RED);
AddChart(high = if c == o then h else nan,
low = if c == o then l else nan,
open = if c == o then o else nan,
close...
This is where you're telling the script to get the highest high and lowest low on the chart.

Code:
def high = HighestAll(info);

def low = LowestAll(info);

Based on what you've described you want, this is all you need if you put it only on the $ADD chart.

Code:
plot dayHigh = high(period=aggregationperiod.day);
plot dayLow = low(period=aggregationperiod.day);

It looks like from your code you're aware of how to assign colors to your plots, so, if you follow that with these two lines, you should accomplish what you're looking for.

I have a personal preference toward keeping parameters for a plot close to the plot.

Ex.:


Code:
plot dayHigh.......;
dayHigh.setdefaultcolor(....);
dayHigh.setstyle(....);

Hope this helps!
 
I still need to assign the symbol: $ADD first. This is a lower chart. The top chart uses a different symbol ( /MES) so the High and Lows are being determined by a different symbol.

Is it possible to assign $ADD in the code first so that High and Low are not based on the /MES ?
 
UPDATE:

Seems to be working now:


declare lower;


input symbol = "$ADD";


def nan = Double.NaN;
def o = open(symbol = symbol);
def c = close(symbol = symbol);
def h = High(symbol = symbol, period = AggregationPeriod.DAY) ;
def l = low(symbol = symbol, period = AggregationPeriod.DAY) ;

AddChart(high = if c > o then h else nan,
low = if c > o then l else nan,
close = if c > o then c else nan,
open = if c > o then o else nan,
ChartType.LINE, Color.GREEN);
AddChart(high = if c < o then h else nan,
low = if c < o then l else nan,
open = if c < o then o else nan,
close = if c < o then c else nan,
ChartType.LINE, Color.RED);
AddChart(high = if c == o then h else nan,
low = if c == o then l else nan,
open = if c == o then o else nan,
close = if c == o then c else nan,
ChartType.LINE, Color.GRAY);

plot h1 = h;

h1.SetStyle(Curve.LONG_DASH);
h1.SetLineWeight(1);
h1.AssignValueColor( Color.GREEN);

plot l1 = l;

l1.SetStyle(Curve.LONG_DASH);
l1.SetLineWeight(1);
l1.AssignValueColor( Color.RED);
 
Solution
This is a lower chart. The top chart uses a different symbol ( /MES) so the High and Lows are being determined by a different symbol.

Did you know that you can turn the price plot off in the chart settings?

(I'm really not trying to drag this on - I've had scenarios like yours previously and utilizing this helped a good bit)

Because of following the image below, the $ADD "chart" shown here is actually two lower windows but the $ADD price chart is not there because it has been toggled off by the setting shown in the first image below.


1700143580867.png


1700143807371.png
 

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
419 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