How do I show only last crossover? - pine-script-v4

I have an indicator which does crossovers and cross unders. It's displayed as a background color.
Currently it displays all crosses.
With what pinescript can I edit it, so it will only show the last one?
Thank you very much!

Use show_last parameter:
//#version=5
indicator("My Script", overlay=true)
sma = ta.sma(close, 14)
cond = ta.cross(close, sma)
bgcolor(cond ? color.teal : na, show_last=1)

Related

Plotly Dash Hovertemplate for charts

I would like to modify the format of my Hoverinfo in Plotly Dash:
Im working with plotly and not plotly express for some reasons.
My Code:
fig.add_trace(go.Bar(x = summe2[monat_week], y = summe2['Umsatz'], name='Umsatz', offsetgroup = 1, marker_color = 'blue'), secondary_y = False)
fig.update_traces(hovertemplate = "Umsatz:%{y:20,.2f}'+ 'X%{monat_week}: %{x}", secondary_y=False)
At the beginning when i hovered on on my chart it displayed 100K instead of 100,000
With hovertemplate = "Umsatz<:%{y:.2f} I fixed it and now im getting 100000.00 as intended but I have no clue how to set an group delimiter 3 that im getting the 100000.00 displayed
like 100,000.00. I found an older post from here but its not working from me
Link: Plotly: How to format numeric yaxis and hover text?
I Wrote the code for the formatting as in the previous link but nothing changed and maybe you could tell me if i can change the formatting to EU like 100.000,00 instead of 100,000.00
via Dash fig.update_traces(hovertemplate = 'Umsatz: %{y: 20,.2f}') should work to display it like 100,000.00 but there is no difference to
%{y: .2f} Display: 100000.00
Thank you in advance
Greetings LittleStudent

SSRS Pie chart hide 0 Value

SQL Server 2012 - SSRS Questions
I currently have a Pie chart that shows the number of deliveries as a percentage on whether they are late, on time or early. What I am trying to do is use an Expression in the Chart Series Labels "Visible" property to hide the label if it is 0 on the chat. Of note in the table this value is returned as 0.00 I have tried using various SWITCH and IFF Statements to do this but nothing seems to work and its likely I am getting the syntax wrong, can anyone help?
Table Values
TotalIssued Early Late OnTime EarlyPerc LatePerc OnTimePerc
6, 0, 4, 2, 0.00, 66.67, 33.33,
=SWITCH(
(First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!LatePerc.Value, "EstimatesIssued") = 0),false,
(First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0),false,
true)
Thanks
Try:
=SWITCH(
First(Fields!EarlyPerc.Value, "EstimatesIssued") = 0,false,
First(Fields!LatePerc.Value, "EstimatesIssued") = 0,false,
First(Fields!OnTimePerc.Value, "EstimatesIssued") = 0,false,
true,true)
UPDATE:
If you have one field per percentage and your dataset returns one row always, you have to select each serie in the ChartData window and press F4 to see properties window.
In properties window set for EarlyPerc Visible property:
=IIF(Fields!EarlyPerc.Value=0,False,True)
And so on for the next two series you have (LatePerc and OnTimePerc).
Let me know if this helps.

Just trying to understand some code

and good evening,
i have just come across the following code:
void showButtons(boolean mode)
{
int state = (mode) ? View.VISIBLE : View.GONE;
l.btn1.setVisibility(state);
l.btn2.setVisibility(state);
l.btn3.setVisibility(state);
l.btn4.setVisibility(state);
}
and i not sure how this works exactly, will be grateful for any explanation, thanks in advance. (specially the int state line).
The function sets the Visibility of btn1, btn2, btn3, and btn4 (probably buttons) to VISIBLE or GONE depending on input.
showButtons(true); sets Visibility VISIBLE.
showButtons(false); sets Visibility GONE.
The top line, int state = (mode) ? View.VISIBLE : View.GONE; sets the value state to View.VISIBLE if mode is true, or View.GONE if mode is false.
It uses an operator called the "conditional operator", which is a little like an if...then...else. It works like:
variable = test_value ? answer_if_test_true : answer_if_test_false;

GNUPLOT: How to use a function to decide the plot style

I have lots of series to draw in 1 plot. I want to decide the plot style/type according to the number of a series. Here is the example code of what I am aiming for:
title(i)=value(sprintf("title%i",i))
title1='x'
title2='x^2'
title3='x^3'
...
with(i)=value(sprintf("with%i",i))
with1='lines'
with2='points'
with3='boxes'
...
plot for [i=1:100] '-' title title(i) with with(i)
I have test the title() function works. But the with function does not work correctly.
Can you help me fix the code?
Or do you think there are other ways to achieve what I am aiming for?
It's possible to build a string of a plot command and then run this string:
p="plot x linewidth 1"
do for [i=1:10]{
p=p.sprintf(", x+%d linewidth %d", i, i+1)
}
print p
eval(p)
The output of the print command is:
plot x linewidth 1, x+1 linewidth 2, x+2 linewidth 3, ...
and this is the resulting plot:
Depending on what you finally want, this might be something for you:
do for [i=1:10]{
p=p.(i==1 ? "'myData.csv' with lines" : "")
p=p.(i==2 ? "'myData.csv' with steps" : "")
...
}
However, this looks pretty ugly.

get specific value from parameter

I have a multi-valued parameter TimeMonthOfYear(from cube) that contains January Februrary...December.
I want to set a default value showing current month using MonthName(Month(Today)) (I tried it and it didn't work) when running report...
If I do this [Time].[Month Of Year].&[October] it works! October is selected in dropdown after previous dropdown (Year) was selected.
I don't want to do it the "hard coded" way...I have tried
[Time].[Month Of Year].&[MonthName(Month(Today))] and
="[Time].[Month Of Year].&["&MonthName(Month(Today))&"]" without luck
Any help is very much appreciated!
Yup :) Well it's now working with may be a not so nice solution but will work for now with the help of vb code. in standard value I have ="[Time].[Month Of Year].&[" + Code.SetMonth() + "]" and custom code Function SetMonth() As String Dim x as STRING x =CStr(MonthName(Month(Today))) 'CStr not needed I think If x = "januari" Then x = "January" ElseIf x = "februari" Then x = "February" ... End If Return(x) End Function That is giving me the current month after selecting value in year drop-down :)