I am new to Pine Script but hoping to get some assistance with two if
statements and based on the outcome I need to plot a flat line for the week (Monday to Friday), the following week the Marker (see below) should re-calculate.
pLevel = (prevHighHTF + prevLowHTF + prevCloseHTF) / 3
r1Level = (pLevel - prevLowHTF) + pLevel
s1Level = pLevel - (prevHighHTF - pLevel)
//Marker Calculations
// Close above Pro_High on Friday
if prevCloseHTF[1] > r1Level[1]
Marker = r1Level - ((r1Level - prevCloseHTF) * 0.55)
//Close Below Pro_Low on Friday
if prevCloseHTF[1] < s1Level
Marker = ((prevCloseHTF - s1Level) * .55) + s1Level
Using this code, How can I plot the Marker on Monday as a single line and recalculated the following week?
You have to initialize the variable in the global scope first and then re-assign the value using the :=
operator. Here is the example:
var float Marker = na
//Marker Calculations
// Close above Pro_High on Friday
if prevCloseHTF[1] > r1Level[1]
Marker := r1Level - ((r1Level - prevCloseHTF) * 0.55)
//Close Below Pro_Low on Friday
if prevCloseHTF[1] < s1Level
Marker := ((prevCloseHTF - s1Level) * .55) + s1Level
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.