Created
May 2, 2023 15:07
-
-
Save episage/0293682a0f33d2da7e43be3edcf3f52a to your computer and use it in GitHub Desktop.
Create Horizontal Ray in TradingView from browser console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createHorizontalRay(epoch, price) { | |
window.c = window.TradingViewApi.activeChart(); | |
// Ht | |
window.ht = window.c._chartWidget.paneWidgets()[0]; | |
// l = chart undo model | |
window.chartModel = window.c._chartWidget._model | |
var point = {index: epochToCandleIndex(epoch), price: price}; | |
var linetool = 'LineToolHorzRay'; | |
window.chartModel.createLineTool({ | |
pane: window.ht.state(), | |
point, | |
linetool, | |
}); | |
function epochToCandleIndex(epoch) { | |
var chartModel = window.chartModel; | |
var coord = chartModel.timeScale().timeToCoordinate(epoch) | |
return chartModel.timeScale().coordinateToIndex(coord) | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createHorizontalRay(1680447654, 1.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment