Determine a fixed, defined period / value, Pine Script - return-value

How can I set a defined value.
In backtesting, the bars are processed from back to front. Is it possible in Pine Script that, for example, a certain function is always carried out on the last 3rd bar.
for example:
IF 3rd bar from the front THEN x: = x + 1

You can do whatever you want at any bar you want: you just need to specify your function within an if block where the condition must be true for the given bar you target.
if ( this_bar_is_the_bar_i_want_to_target )
// ... do stuff like x+1 etc...
Now you might ask "How to get ante-last bar ?". Basically, you can't because "ante-last bar" is relative and infinite. Meaning, on a 1 hour timeframe, at 11:00, the ante-last bar will be 10:00, but then at 12:00, the ante-last bar is not 10:00 anymore, it now is 11:00... and this is infinite.
Now, that being said, "ante-last bar" is dynamic, so it will always be changing after each new candle. So the correct approach would be to actually isolate the "current last bar" and from THIS last bar, try to work your calculations on the previous one. In that case, it would be something like that:
if (barstate.islast)
// ... do stuff with close[1] or high[1] or low[1] or open[1] ...
That means that you can isolate the last bar DYNAMICALLY (it will be another bar for each new candle in the chart), and from there you can call previous bar, or bar from 3 bars back, ...

Related

How to display sheet(s) on dashboard using navigation?

I'm creating a dashboard on Tableau and I want to have a set of navigation buttons that correspond with the sheets I've created. When a button is clicked I want the corresponding sheet to be displayed on my dashboard instead of navigating to the sheet itself. I want all of the sheets to be displayed in the same place on my dashboard. For example, If button 1 is clicked I want sheet 1 to be displayed on my dashboard. If button 2 is clicked I want sheet 2 to be displayed on the dashboard in the same place. I'm new to Tableau and would appreciate any help with this!
The easiest way to achieve this is using parameters.
As a first step you need to creat a parameter with a list of values matching the number of worksheet, like: Worksheet 1, Worksheet 2, etc...
Then you have to create N calculated fields in order to check if the "actual" worksheet is the one "selected in the parameter", using "ok" and "ko" as results for your filters, keeping just "ok".
The formula could be something like this (assuming you're doing the CF for the 1st worksheet, and the other ones differ just for the value):
if parameter = 'Worksheet 1' then 'ok' else 'ko' end
Doing so, all you're worksheets will present data just one at a time because all of them but the one matching the valus in parameter will be blank.
Then you can create your dashboard putting a vertical (horizontal as well if you like) container in it which will be the the "place" where you'll drag all your worksheets.
Be sure to NOT modify the spacing and height of them; just le tableau handle that for you, otherwise the trick won't work.
Once you're finished you will end up having a container with N worsheets in it, with just one of them dysplayed at once.
Once you'll become familiar with parametr actions, you will no longer need to have the parameter displayed on the dashboard (show parameter) because using a worksheet connected to the parameter values you will be able to decide the value of the parameter via click on your additional worksheet acting like a series of button (woeksheet 1, worksheet 2, etc...)

Pine Script - Tradingview -Need Delayed a Sequence of Triggers to happen not on the same bar in order to execute

Still new to Pine Script. Writing a bollinger band script and I need two triggers, where one trigger needs to happen 1st (close price crosses upper band) and set a variable to true and does not change until the 2 second trigger (exits me from trade) which is when price crosses middle band then will execute and close out trade.
The triggers won't be happening on the same bar.
I think I'm looking for the right variable that I can set true and retains its value through multiple bars until I change it. Like I said I'm new and looking for quick answer.
You can declare a variable for this purpose with the var keyword. It will hold it's value across bars until you modify it.
var bool upperBandCrossed = false
bool exitCond = false
if open < upperBB and close > upperBB
upperBandCrossed := true
if open > basis and close < basis and upperBandCrossed
exitCond := true
upperBandCrossed := false

How to add custom created column in github project boards's progress bar?

I created a project board in GitHub using default Kanaban. I've added my own column, but it isn't reflected in the project progress bar. Only To-Do, In-Progress & Done are reflected and it is bugging me out. Is there a way to reflect the new columns in the project bar too? Thanks.
( For context purpose: The progress bar is the one with project's name and shows the columns relative status with respect to the number of cards in the columns. White -> Todo, Purple -> In Progress, Green -> Done. )
https://help.github.com/articles/about-project-boards
I tried fiddling around automation properties of the columns (I didn't work as I expected). In project properties, I've unchecked & again checked the show progress bar column. But it is still showing the original three columns and not the new ones.
expected:
progress-bar -> x-done / y-in progress / z - custom / ... / a-to-do
actual:
progress-bar -> x-done / y-in progress / z-to do
According to my fiddling with the GitHub project board, the progress bar shows the (sum of the) amount of items in columns marked with an automation preset (To do, In progress, Done).
Columns with automation preset "None" are not shown in the progress bar.
I don't think you are able to add more presets to create your expected progress bar x-done / y-in progress/ z-custom / ... / a-to-do. At least not yet, although I checked 2 years after the question was posted.
You can, however, definitely do something like x-done / y-in progress + z-custom / a-to-do by setting the custom column's automation preset to "In progress".
To elaborate on #hilipati's answer: no, GitHub only takes into account "To do", "In progress", and "Done" columns. However, if you set the column's automation to one of the above presets, it will count. So, for example, you can split the "In progress" column into two columns -- one for new PRs and another for reviewed PRs, and both will count towards the "In progress" (purple) section of the progress bar.

tableau change dimension to attr(dimension) in dashboard

In a worksheet, if I have a dimension as second dimension in a row label I can "collapse" that dimension with ATTR() by selecting Attribute in the menu:
However, this menu is only available on the worksheet view. How do I enable the user to accomplish this switch on the dashboard?
Create a boolean valued parameter, call it say Should Expand. You can choose readable aliases, such as "Expand" for True and "Collapse" for False.
Show your parameter control and customize the look as desired
Create a calculated, call it, say Collapsable Foo, where Foo should really be the name of your true second dimension. Define it as
if [Should Expand] then [Foo] end
Make sure Collasable Foo is a dimension and use it as desired, presumably in place of Foo. You can edit the aliases for Collapsable Foo to set Null to a single blank to improve the way text appears when collapsed.

Crystal Reports Legends

Is there a way to force a Bar Chart legend in Crystal Report 11.5 to display its objects in a particular order?
For Example, say I am reporting on the consumption of "Bananas" and "Apples" by State. The Bar Chart should display the percentage of people who eat these fruits by county (Percent Bar Chart). The "Apples" percentage always displays on top of the bar chart and the "Bananas" on the bottom. The legend for this graph also displays the "Apple" color first, then the "Banana" color. However, if the "Banana" percentage is 0% the legend displays the "Banana" color first on the legend. This creates a inconsistent report (with plenty of complaints).
I would like the "Banana" color to always display second in the legend. Hope I didn't confuse anyone and any ideas would be helpful.
Try this instead:
1. Right-click to go into the Chart Expert. Go into the Data tab.
2. If it isn't already set to it, set the grouping method thingy on the top right to On Change of
3. Click Order, then Specified Order
4. There are 2 new tabs: Specified Order and Others. Use the first to decide which groups go first and the second to decide what to do with the rest.
Since you're specifying the order of your groups in the chart, Crystal won't try to auto-decide which ones go first. Step 2 may be an issue for your chart depending on how you set it up. In that case, I suggest making a new chart from scratch.
I can't call myself an expert. I hope this helps.
I think I was able to replicate your issue. It is a little strange, but I was able to bypass the issue by changing the chart to one of the other 2 bar chart types ("Stacked Bar Chart" or a "Side-By-Side Bar Chart"). I'd recommend using one of those, or perhaps even a pie chart.