Reputation: 121
For Loop issue to print 2 horizontal lines as per formula.
WHEN THE SECURITY, PRICE/CLOSE VALUE CHANGES, THE OLD LINES MUST BE DELETED AUTOMATICALLY AND REPLACED WITH NEW LINES AS PER MENTIONED FORMULA
//@version=4
study("g", overlay=true)
float g_90 = 0
float g_90_1 = 0
for g_90 = 0 to 1000000 // 1000000 can be any infinite number
g_90_1 = g_90 + 1 // second variable is 1 value above previous variable g_90
g_90_return = 4*(g_90*g_90) + 7*(g_90) + 4 //assign a variable g_90_return; to the formula1 = 4*(g_90*g_90) + 7*(g_90) + 4 to plot a horizontal line
g_90_1_return = 4*(g_90_1*g_90_1) + 7*(g_90_1) + 4 //assign a variable g_90_1_return; to the formula2 = 4*(g_90_1*g_90_1) + 7*(g_90_1) + 4 with second variable to plot another horizontal line
if( (g_90_return < close) and ( g_90_1_return > close) ) // if close > formula1 and close < formula2, draw both the hroizontal lines; as long as price is contained within them
hline(g_90_return , color = color.blue, linewidth= 4)
hline(g_90_1_return , color = color.blue, linewidth= 4)
else
g_90 := g_90 + 1 // run loop again with incremental value
Upvotes: 1
Views: 758
Reputation: 8789
hline()
can't be used in for
loops. You could use line.new()
.
Upvotes: 1