'Get indicators on 1 hour daily time frame in correlation to daily timeframe
In one hour timeframe I am trying to study the four days of daily candles to know the trend to create an indicator on the 1 hour chart if I should make a sale or buy the stock.
How do I get the historical data for the series got from security function for 1D resolution on all four values close, open, high and low.
But for all indexes on the series got from security function I get the same value back.
Below is the code:
//@version=5
indicator("My Script", overlay=true)
indexHighTf = barstate.isrealtime ? 1:0
indexCurrTf = barstate.isrealtime ? 0:1
d_timeframe_Close = request.security(syminfo.tickerid, "D", close[indexHighTf])[indexCurrTf]
d_timeframe_Open = request.security(syminfo.tickerid, "D", open[indexHighTf])[indexCurrTf]
d_timeframe_High = request.security(syminfo.tickerid, "D", high[indexHighTf])[indexCurrTf]
d_timeframe_Low = request.security(syminfo.tickerid, "D", low[indexHighTf])[indexCurrTf]
down_lowest = 0.00
down_id_lowest = 0.00
up_list = array.new_int(0)
up_highest = 0.00
up_id_highest = 0
up_low_of_heighest = 0.00
candle_start = 4
candle_end = 0
sell_alert = 0
if (d_timeframe_Open[candle_start]<d_timeframe_Close[candle_end])
count = 0
for i = candle_end to candle_start
if (d_timeframe_Open[i]<d_timeframe_Close[i])
if (count == 0)
count := count+1
up_highest := d_timeframe_High[i]
if (up_highest <= d_timeframe_High[i])
array.push(up_list, i)
up_highest := d_timeframe_High[i]
up_id_highest := i
up_low_of_heighest := d_timeframe_Low[up_id_highest]
if (open[0] > up_low_of_heighest and close[0] < up_low_of_heighest)
sell_alert := 1
plotshape(sell_alert, style=shape.triangledown, location=location.belowbar, text="Sell")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|