dailyBars inds extended+ gui tick inds disable button

This commit is contained in:
David Brazda
2024-01-09 15:11:56 +01:00
parent a7df38c61b
commit cd461c701e
3 changed files with 78 additions and 8 deletions

View File

@ -152,7 +152,8 @@ def init(state: StrategyState):
time_to = state.bt.bp_from
#TBD pridat i hour data - pro pocitani RSI na hodine
#TBD NASLEDUJICI SEKCE BUDE PREDELANA, ABY UMOZNOVALA LIBOVOLNE ROZLISENI
#INDIKATORY SE BUDOU TAKE BRAT Z KONFIGURACE
#get 30 days (history_datetime_from musí být alespoň -2 aby to bralo i vcerejsek)
#history_datetime_from = time_to - timedelta(days=40)
#get previous market day
@ -217,6 +218,24 @@ def init(state: StrategyState):
state.dailyBars["volume_sma_divergence"] = normalized_divergence.tolist()
state.dailyBars["volume_sma"] = volume_sma.tolist()
#vwap_cum and divergence
volume_np = np.array(state.dailyBars["volume"])
close_np = np.array(state.dailyBars["close"])
high_np = np.array(state.dailyBars["high"])
low_np = np.array(state.dailyBars["low"])
vwap_cum_np = np.cumsum(((high_np + low_np + close_np) / 3) * volume_np) / np.cumsum(volume_np)
state.dailyBars["vwap_cum"] = vwap_cum_np.tolist()
normalized_divergence = (close_np - vwap_cum_np) / (close_np + vwap_cum_np)
#divergence close ceny a cumulativniho vwapu
state.dailyBars["div_vwap_cum"] = normalized_divergence.tolist()
#creates log returns for open, close, high and lows
open_np = np.array(state.dailyBars["open"])
state.dailyBars["open_log_return"] = np.log(open_np[1:] / open_np[:-1]).tolist()
state.dailyBars["close_log_return"] = np.log(close_np[1:] / close_np[:-1]).tolist()
state.dailyBars["high_log_return"] = np.log(high_np[1:] / high_np[:-1]).tolist()
state.dailyBars["low_log_return"] = np.log(low_np[1:] / low_np[:-1]).tolist()
#printanyway("daily bars FILLED", state.dailyBars)
#zatim ukladame do extData - pro instant indicatory a gui
state.extData["dailyBars"] = state.dailyBars

View File

@ -443,7 +443,7 @@ function chart_indicators(data, visible, offset) {
//start
//console.log(key)
//get configuation of indicator to display
conf = get_ind_config(key)
conf = get_ind_config(key, index)
//pokud neni v configuraci - zobrazujeme defaultne

View File

@ -206,11 +206,25 @@ function initialize_statusheader() {
}
//pokud neni v configuraci vracime default
function get_ind_config(indName) {
//pokud neni v configuraci vracime default, pro tickbased (1) vracime embed false pokud je globalni ()
function get_ind_config(indName, tick_based = 0) {
//def settings
def = {name: "ema", titlevisible: false, embed: true, display: true, priceScaleId: "middle", lastValueVisible: false}
//WORKAROUND to DISABLE TICK INDS - skip config
var hideTickIndicators = localStorage.getItem('hideTickIndicators');
console.log("jsme v IND CONFIG. hodnota hideTickIndicators =",hideTickIndicators)
//pokud jde tick_based a mam v local storage nastaveno hideTickInds pak nastavuju embed na false - coz nezobrazi tickindikatory
if ((tick_based == 1) && hideTickIndicators && hideTickIndicators == "true") {
def.embed = false
console.log("pro",indName,"vracime embed false")
return def
}
//END WORKAROUND
if (indConfig == null) {
indConfig = get_from_config("indConfig", indConfig_default)
}
@ -599,6 +613,27 @@ function toggleVolume() {
}
}
//togle profit line
function toggleTick() {
const elem = document.getElementById("tickToggle");
if (elem.classList.contains("switcher-active-item")) {
localStorage.setItem('hideTickIndicators', 'false');
}
else {
localStorage.setItem('hideTickIndicators', 'true');
}
elem.classList.toggle("switcher-active-item");
//toggle repaint - click on change resolution
var activeButton = document.querySelector('#changeResolution .switcher-active-item');
// Click the button programmatically
if (activeButton) {
activeButton.click();
}
}
//togle profit line
function mrkLineToggle() {
vis = true;
@ -744,6 +779,22 @@ function populate_indicator_buttons(def) {
});
funcButtonElement.appendChild(itemEl);
//button pro disable tickIndicatoru
var itemEl = document.createElement('button');
itemEl.innerText = "ticks off"
itemEl.classList.add('switcher-item');
var hideTickIndicators = localStorage.getItem('hideTickIndicators');
console.log("init button, hodnota hideTickIndicators", hideTickIndicators)
if (hideTickIndicators && hideTickIndicators == "true") {
itemEl.classList.add('switcher-active-item');
}
itemEl.style.color = "#99912b"
itemEl.id = "tickToggle"
itemEl.addEventListener('click', function(e) {
toggleTick();
});
funcButtonElement.appendChild(itemEl);
// //button pro toggle markeru nakupu/prodeju
var itemEl = document.createElement('button');
itemEl.innerText = "mrk"
@ -807,7 +858,7 @@ function populate_indicator_buttons(def) {
function createSimpleSwitcher(items, activeItem, activeItemChangedCallback, data) {
var switcherElement = document.createElement('div');
switcherElement.classList.add('switcher');
switcherElement.id = "changeResolution"
var intervalElements = items.map(function(item) {
var itemEl = document.createElement('button');
itemEl.innerText = item;
@ -821,9 +872,9 @@ function createSimpleSwitcher(items, activeItem, activeItemChangedCallback, data
});
function onItemClicked(item) {
if (item === activeItem) {
return;
}
// if (item === activeItem) {
// return;
// }
intervalElements.forEach(function(element, index) {
element.classList.toggle('switcher-active-item', items[index] === item);