Get session-time (start and close time) of main chart series in pinescript - charts

I am currently trying to write up a script in Pine Script for TradingView, and am having difficulties getting the session (the start and close times) of the current displayed main chart series.
e.g for Nikkei225, the session would be 8:45am - 5:30am (UTC+9)
I am using this to make a Ku-Chart which resets every day on the close time of the main chart series.
Also having difficulty drawing a vertical line at this close time.
Any help would be appreciated :)

See the How To Show Vertical Lines script by allanster.

Related

Replace default chart in Pine Script while using overlay=true

Is it possible to replace/make invisible the default chart using Pine Script? As an example, the default chart always shows candles. I would like to write an indicator (using overlay=true) to erase (or make invisible) the default candle chart and replace it by just plotting the close values (e.g., plot(close)). This is just a simple example to illustrate what I want to do and where I'm getting stuck. Thanks in advance.
That's something I've needed in the past too, but unfortunately there's currently no Pine Script command available that allows for the manipulation of the visibility of the symbol on the chart.
It can be partially done, by making the body of the candle the same as the background color, but that still leaves the candle wicks and border intact.
barcolor(chart.bg_color)
Unfortunatly, there's no command to do the same for wickcolor and bordercolor.
Another approach could be to plot a new bar over the existing bars, with body, wicks and border all in the background color.
However, that will not work either - not even when you use explicit_plot_zorder=true - because the z-index of the chart symbol is always seems to be higher.
//#version=5
indicator("My script", explicit_plot_zorder=true, overlay=true)
plotcandle(open, high, low, close, "hideCandle", chart.bg_color, chart.bg_color, bordercolor=chart.bg_color)
So, in short, no solution for this yet.

Tableau add trend line to discrete data?

I have run into this more times then I like, and I think it will continuously haunt me. I am creating reports/dashboards that report monthly or yearly or weekly data. The dates come in with just the last day of the period. For example, now I am working 2019 monthly report that is a bar chart with a trend line. Took me about 15 minutes to make in excel. However, we are trying to move everything into Tableau for dashboards. Trend line is always grayed out when using discrete dates and sometimes when using continuous dates. The dates are in the format DD/MM/YYYY so I can convert them as continuous but that skews the spacing on the X-Axis. I have messed around to get it to work but it takes time. I am shocked that this very basic thing does not work when Excel has been able to do it for a very long time. Does anyone know of a good work around? I have tried calculated the trend line myself, but do not see how I can add in the y=mx+B line that is generated. I am debating creating a data set just for this, but that seems long and hard way for something that I would have expected out of the box. Below is some basic data, in Excel it takes about 1 minutes to create a line chart, click (+) add trend line and your done.
I was not able to deal with the skew of the X-Axis very well but playing with the date it started and setting the major tick marks to monthly got me close. Looking at the picture below you will see the tick marks are not in the center of the bars but close. As for the trend line, I added a Dual axis on the same data that was the sum of all shown fields with no division by the parts (this is a stack mark bar chart). Since this is a basic line chart with continuous dates, a trend line is a simple click. I then removed the Tick Markets and set the opacity to 0% making the line invisible. I did not change the trend line so now that is all you can see. Seems like a long and hard way to do it, but it works. (UPDATE) Better fix, NEVER USE EOM always use First of Month.

I need to sign every week on a diagram in my Power BI report

I've created a bar chart where I have values on axis Y and weeks on axis X. I want to sign every week on this chart. The problem is that I have weeks with no data and I still want to show this blank weeks. But I can't make it to start from first week,it automatically start from first not blank week.I tried to play with continuous and categorical type of data on axis X but it didn't help. I've already chosen option "show elements without data". But it still doesn't look like a want.
For best understanding I'll show you what I have and desired result.
Now it looks
this way and this way
But I want that it look
this way
Thank you for any useful tips.

Could Matlab use system time as X axis value?

I have a 3D camera that could give Matlab information about the distance of an object in real time after the command distance=function1(Device)(I have omit this function since it is not important here).
I would like to make a program that shows the object moving when time changes.
I have already succeeded in using:
t1=clock;
while......(in a loop)
distance(i)=step(Device);
t2=clock;
times(i)=etime(t2,t1);
plot(times,distance);
end
to show the object moving. However, the X axis in this figure is the comparative time, which means the x axis begins with 0 seconds and ends with (t2-t1) seconds .
Now I try to find a way to change the X axis to the absolute time or the cpu time.
Like the following picture:
I'd like to change the comparative time(in black fonts) to the absolute system time (in red fonts).
I have try ' datetick' but it doesn't work properly?
Is there any way to do this?
The following creates a string out of the clock, plots distance, then attempts to change the labels based on the text strings each iteration. I tested a simple instance of it in MATLAB.
while ... (in a loop)
distance(i)=step(Device);
t2=clock;
tint = int8(t2(4:6)))
stamp{i} = strcat(int2str(tint(1)),':',int2str(tint(2)),':',int2str(tint(3)))
plot(distance)
set(gca,'XTick',1:i,'XTickLabel',stamp)
end
As far as getting the AM and PM to show, well, you'll have to do some extra witchcraft but it should be possible, based on the clock values. Then just append AM or PM into the stamp{i} assignation.
Hint, if t2(4) > 12 you are looking at PM. Else, AM.
One limitation with this is that the more iterations you do, the more crowded your X-Axis is going to become.

building scrolling window with Matlab GUI

I am new with the matlab GUI and I am having a problem with creating a window with scrolling.
The problem is as follow:
Lets say I have 100 lines (every line is compounds from several edit text and check box).
I need that all those 100 lines, will be inside that window - obviously the window is not large enough for all those lines and making the window bigger is not an option - so the trivial solution is scrolling up and down the window and watch all those 100 lines (lets say that the window without scrolling is large enough for 8 lines).
When I tried dynamically to insert more than 8 lines inside that window (normalized panel), the new rows makes the rest (older) lines be really small.
So my question is how can I build "compound" line in a GUI in similarity with strings in "list box"?