Range Calculation from Custom High To Low


Category:
0
0

Hi Pete,

I am looking for a study which just show only a label on chart. The label should be displaying the difference between the high and low from Input time high to input time low so I should have two inputs- (1) Input time high (2) input time low. For example if my input time high is 9:30 Am and high of the candle is 24079 and my input time low is 230 pm and low of the candle is 23759 then label should display the difference between 24079 and 23759 which is 320.

I hope I am being clear on the requirement.

Thank you,

Shaishav

Marked as spam
Posted by (Questions: 49, Answers: 62)
Asked on May 9, 2020 7:54 pm
99 views
0
Private answer

Before we can even approach a solution we need to explain how bars on the chart are marked with date/time data in Thinkorswim. The time assigned to each bar is the start time. So if you have a user input value of 930 it will pick up the candled that started trading at 9:30. So if that candled is on a 15 min chart, that candle closes at 9:44:59.

The next item we need to tackle is how the value in the label will change as new bars are added to the chart. Before 9:30 the label will display the range from the previous day. After 9:30 and before 14:30 today, the label will display the range from yesterday's low at 14:30 to today's high at 9:30. Only after the 14:30 bar from today has completed with the label switch to display the range from today's 9:30 high to today's 14:30 low. Is this the behavior you expected? If not, the solution is far more complex than you can imagine.

 

Edit: After getting clarification on this request in the comment section below I have a solution:

input timeOfHigh = 930;
input timeOfLow = 1430;
rec targetHigh = if SecondsTillTime(timeOfHigh) == 0 then high else targetHigh[1];
rec targetLow = if SecondsTillTime(timeOfLow) == 0 then low else targetLow[1];
AddLabel(yes, Concat("Range: ", targetHigh - targetLow), Color.WHITE);

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on May 10, 2020 9:41 am
0
I expect that behavior and I know the limitation on different time frames. For example I used 14:30 time but I will be using smaller range in practice. So I am fine with the solution you will provide.
( at May 10, 2020 12:24 pm)
0
I have updated my answer to include the solution you requested.
( at May 10, 2020 1:49 pm)
0
Thank you so much. God bless you for all this help you are doing.
( at May 12, 2020 7:26 pm)