Several methods exist for calculating the (P) of a market. Most commonly, it is the arithmetic average of the high (H), low (L), and closing (C) prices of the market in the prior trading period:
P = (H + L + C) / 3.
Sometimes, the average also includes the previous period's or the current period's opening price (O):
P = (O + H + L + C) / 4.
In other cases, traders like to emphasize the closing price, P = (H + L + C + C) / 4, or the current periods opening price, P = (H + L + O + O) / 4.
Support and resistance levels
The first and most significant level of support (S1) and resistance (R1) is obtained by recognition of the upper and the lower halves of the prior trading range, defined by the trading above the (H − P), and below it (P − L). The first resistance on the up-side of the market is given by the lower width of prior trading added to the price and the first support on the down-side is the width of the upper part of the prior trading range below the .
R1 = P + (P − L) = 2×P − L
S1 = P − (H − P) = 2×P − H
Thus, these levels may simply be calculated by subtracting the previous low (L) and high (H) price, respectively, from twice the value:
The second set of resistance (R2) and support (S2) levels are above and below, respectively, the first set. They are simply determined from the full width of the prior trading range (H − L), added to and subtracted from the , respectively:
R2 = P + (H − L)
S2 = P − (H − L)
Commonly a third set is also calculated, again representing another higher (R3) and a yet lower (S3). The method of the second set is continued by doubling the range added and subtracted from the point:
R3 = H + 2×(P − L) = R1 + (H − L)
S3 = L − 2×(H − P) = S1 − (H − L)
This concept is sometimes, albeit rarely, extended to a fourth set in which the tripled value of the trading range is used in the calculation.
Qualitatively, the second and higher levels are always located symmetrically around the , whereas this is not the case for the first levels, unless the happens to divide the prior trading range exactly in half.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.