TradingView
kaleboraciy
2020년 6월 2일 오전 6시 43분
How to detect last bar of day
BITMEX:XBTUSD.P
15
Bitcoin / US Dollar Perpetual Inverse Swap Contract
BitMEX
설명
⋅
2020년 6월 2일 오전 6시 43분
Simple way how to detect last bar of day and close all positions
UPD: day end can be different for yours because stocks market use another timezone
Trend Analysis
daytrade
gap
gaps
코멘트
yalla-yalla-habibi
⋅
2021년 5월 3일 오전 5시 20분
I needed something a little different, but this snippet pointed me into the right direction, thanks!
What I was looking for was to detect the candle previous to the last.
last_bar = timenow - time_close < 1000 * 60 * 60 * 24
kaleboraciy
⋅
2021년 5월 4일 오후 2시 17분
@yalla-yalla-habibi
, good :)
endeavorzhao
⋅
2023년 4월 6일 오전 8시 54분
cool
HanDollarian
⋅
2021년 5월 21일 오전 7시 39분
cool stuff mate, thanks!
kaleboraciy
⋅
2020년 6월 2일 오전 7시 6분
UPD: if you use strategy.close so it closes on open of new day
del = time_close[1] - time_close[2]
last_bar = timestamp(year, month, dayofmonth + 1, 0, 0, 0) == time_close + del
strategy.close(id, when = last_bar)
this code closes on open last bar
더보기
What I was looking for was to detect the candle previous to the last.
last_bar = timenow - time_close < 1000 * 60 * 60 * 24