-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchart-mods.user.js
59 lines (53 loc) · 2.04 KB
/
chart-mods.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// ==UserScript==
// @name Cryptohopper Tradingview Chart Mods
// @namespace https://github.com/markrickert/cryptohopper-dashboard-watchlist
// @version 0.2
// @description Adds a few extra things to the Tradingview charts like average buy rate and indicator on your last buy.
// @author @markrickert
// @homepage https://github.com/markrickert/cryptohopper-dashboard-watchlist
// @updateURL https://github.com/markrickert/cryptohopper-dashboard-watchlist/raw/main/chart-mods.user.js
// @match https://www.cryptohopper.com/chart/chart.php*
// @icon https://www.google.com/s2/favicons?domain=cryptohopper.com
// ==/UserScript==
try {
// Only run this code on the intended page(s) (useful when @required in a parent script)
if (["/chart/chart.php"].includes(window.location.pathname))
(function () {
"use strict";
const buyRate = parseFloat(getParameterByName("buy_rate"));
const buyTime = parseInt(getParameterByName("buy_time"));
const tpRate = getParameterByName("tp_rate");
const slRate = getParameterByName("sl_rate");
function mod_createBuyMoment(buyRate, buyTime) {
widget
.chart()
.createExecutionShape()
.setText("BUY")
.setTextColor("#29c79e")
.setArrowColor("#29c79e")
.setArrowSpacing(5)
.setArrowHeight(10)
.setDirection("buy")
.setTime(buyTime)
.setPrice(parseFloat(buyRate));
}
function mod_createPositionLine(buyRate, tpRate, slRate) {
createPositionLine("Avg Cost", buyRate, 0, tpRate, slRate);
}
function initChartMods() {
widget.onChartReady(function () {
if (buyRate && widget) {
mod_createPositionLine(buyRate, tpRate, slRate);
mod_createBuyMoment(buyRate, buyTime);
}
});
}
window.onload = function (e) {
initChartMods();
};
})();
} catch (err) {
console.log(
`Error in script chart-mods.user.js: ${err.name}: ${err.message}`
);
}