♥ 0 |
Hey Pete, I need helping modding some code below. How do I lock the bubble plot so it only shows from the 9:30 am candle to the 9:45 am candle. After 9:45 if the price keeps making a new high, I don’t want this script to record or any new values Right now its plotting all day. Thanks
def dailyOpen = open(period = “DAY”); def afterOpen = secondsFromTime(930) >= 0; def isToday = GetDay() == GetLastDay();
def rthHigh = if isToday and afterOpen and high > rthHigh[1] then high else rthHigh[1]; plot plotHigh = HighestAll(rthHigh); plotHigh.Hide();
#percent change from open to current bar def openPctChange = Round(((high – dailyOpen) / dailyOpen) * 100, 2);
#count the number of times the high of day is reached def highReached = isToday and afterOpen and high == plotHigh; def highCount = if highReached then highCount[1] + 1 else highCount[1];
AddChartBubble(highReached, high, openPctChange + “%”, if highCount > 1 and openPctChange > 60 then Color.RED else Color.YELLOW, yes);
Marked as spam
|
Private answer
I can point you in the right direction and we'll let you see if you can incorporate this into your code to get the job done:
On a 1 min chart, this will give you a variable named targetTimeSpan that is true for every bar within your specified time span. Each bar on the chart is marked with the start time. So on a 1 min chart we need to decrement the endTime input by 1 minute. If you apply to some other time frame you will need to adjust the user input named "endTime" to match the time stamp on the last bar you want included in the computations. If you want a variable that will be true on the very first bar of this time span you can add the following to the code above:
These two variables should give you the tools needed to compute the remainder of your study. HINT: Create a custom chart study using those lines of code and add plot this on a lower subgraph to see how they display their true/false values in graphical form. Here is the code, set to plot those two variable on a lower subgraph:
For the AddChartBubble() statement the first parameter sets the "time condition". Details here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddChartBubble So if you wanted a chart bubble to display only on candles which fall within your selected time frame you would add the following line of code to the section of code I provided above:
And if you wanted to include another requirement to that "time condition" so that the chart bubble only plots on the candles which fall within the selected time span AND only on those candles in which your variable named "highReached" is true:
Marked as spam
|
Please log in to post questions.