Pinescripts Study Error : Calculation takes too long to execute - pine-script-v5

I am computing a value for each bar using 100-day Fixed Volume Profile data.
The indicator works fine for bar index <500.
Calculation execution time hit the study error as the bar index increased.
Any pointers on the approach to overcome this issue? Thanks.

Related

The simulation model time slows down in virtual mode

I am currently building a model on a manufacture process line and the simulation was running fine without errors. Suddenly when I entered in virtual mode to run quickly the simulation, the model started to slow down although the step is high. I am trying to identify where the issue is but nothing is working. At a certain time , the simulation just stops while the step is still running.
This is a picture of the pallete, maybe the experiment is causing this.
You created an infinite loop, this can be triggered by various things in your model.
Likely, you have a ' while' loop not finishing, could also be a condition-based transition.
You need to find this yourself, though. 3 options:
(easy): Check the model logic yourself and find the problem
(easy): nudge yourself to where it stops with traceln commands (see where they stop showing, getting you closer to the culprit)
(harder): Use a profiler (google "AnyLogic profiling" or similar if you are not familiar)
Benjamin is correct, you have created an infinite loop. Click on the "Events" tab in the developer panel and see which events are scheduled to occur at about the time that your model slows down to 0 days/sec. You can also pay attention to the "Step: " counter at the bottom of the developer panel and see where the step count spikes - e.g., if your model has roughly 10k steps per day, and suddenly starts climbing to 400k steps around 25.99 days, you can pay attention to which things are happening in your logic at that time and narrow down where the infinite loop is created. traceln will also help immensely

How to know time remaining until Anylogic Model is executed

Is there any way one can know the time remaining until Anylogic model completes it's execution in real time using traceln.
I am trying to trigger an anylogic model jar file using vba & want to show a progress bar displaying the Progress of experiment & time remaining until model execution is completed.
I think you want to know the real time that the model execution will take and us that to show a progress bar.
Felipe showed how to calculate the simulation time based on starttime and endtime set in the sim experiment and the current simulation time.
I don't think there is an easy way to do what you want. based on trial and error you could insert some traceln inside your model and use that to time the progress bar. Though it would change based on your inputs. Even the progress bars you see on microsoft apps / installations are not too accurate so thats never easy.
double remaingTimeSeconds=getEngine().getStopTime(SECOND)-time(SECOND);
traceln(remaingTimeSeconds);
in a more general way, if your model doesnt start at t=0, then you can do the following to get the remaing progress:
double totalSimTimeSeconds=getEngine().getStopTime(SECOND)-getEngine().getStartTime(SECOND);
double timeSinceStartSeconds=time(SECOND)-getEngine().getStartTime(SECOND);
double remaingingTimeSeconds=totalSimTimeSeconds-timeSinceStartSeconds;
double fractionRemaining=remaingingTimeSeconds/totalSimTimeSeconds;
traceln(fractionRemaining*100+"%");

Is there a way to force the output of a Stat panel in Grafana to only show values in days

I'm building a Grafana dashboard with some Stat panels that show average, minimum, and maximum time values (see below) for specific fields in my database. I'm storing the data in seconds and setting the value's units to seconds after which the panel displays the time in weeks, days, hours, etc. For the sake of consistency, I would like everything to be shown in days but I haven't been able to find a way to force units for the output value. If it's possible to do this, could someone please point me to some docs, or something that could show me which configurations to make in my panels?
So far, I've tried (without success):
Configure each panel to use units of days
The result of this was that everything showed up in years, etc.
Configure each panel to create a new field by performing a binary calculation where I converted from seconds to days and then I updated the units to be days
The result was that the values were not changed at all -> instead of showing X days, or whatever, it just showed the value in seconds without the units. I'm not sure what I messed up there, but it didn’t change anything.
I found this link that discusses setting a time range for queries
This didn’t end up being useful for what I was trying to do because it was actually geared towards changing the query to a specific date range rather than the output.
I looked through the transformations documentation, stat panel documentation, and a few other panel documentation pages in an effort to see if there was any information on how to do it but I was unable to find anything on forcing the output value to use a specific unit.
Edit:
So I kept messing around with the dashboard and got a solution that works - i.e. it's a "good-enough" solution (see below) - but, now, I'm curious if it's possible to show the units along with the value without it converting it to some other unit. Does anyone have any ideas about this?
One thing to note is that the data for this image is different than the data for the previous one so I'm expecting an inexact conversion to days.
You can use a custom unit. It is a bit tricky to enter the unit in the UI because of the automatic selection but if you enter i.e. "days" (without the quotes) in the Unit field ans instead of leving the field with tab or mouse click use the scrollbar of the combobox and select the last entry "Custom Unit: days".
Hope it helps. And for the record: I am using Garafana 7.1.4

Quick Measure Error: "Only Power BI-provided date hierarchies are supported"

I am attempting to create a rolling average quick measure using time intelligence. When I drop my DATE variable into the Date field I get the error message "Only Power BI-provided date hierarchies are supported".
How do I fix this? I've tried to use the solution posted here but it is not working for me. My date column is also formatted as date/time. I appreciate any help.
I was able to resolve this issue.
The quick measures feature only works on very simple data models ( a single table). Doesn't scale to well.
The easiest method is to create the moving average measure yourself using DAX. No limitations that way. Quick measure is just a way to generate DAX code through the GUI.
See this guide: https://www.daxpatterns.com/statistical-patterns/#moving-average or https://powerpivotpro.com/2013/07/moving-averages-sums-etc/

Google Sheet IMPORTHTML VERY Slow?

I have a spreadsheet that acquires some table data using the IMPORTHTML function, and for the first two days I was using it (refreshing twice daily) things were going fine. As of this morning, it is absolutely crawling. Went from taking ~15 seconds to load 30 rows to taking ~10 minutes. Can somebody lend aid on this?
Example formula:
=IMPORTHTML(
"http://www.muthead.com/16/players/prices/1508-markus-wheaton/playstation-4","table",2
)
As mentioned, the first couple of days it was able to refresh and process a list of 30 without any pauses. Now I get the 'Executing script' message for about ten minutes before it begins to do anything, and I haven't touched the source code since origin. I'm not sure what contributes to the performance of the IMPORTHTML statement...
I've run into similar loading issues when using IMPORTHTML, IMPORTDATA, etc. The best solution I've found is to write a trigger that will edit your formula so it is forced to refresh every hour or so.
Open up the script editor and put this in. Change 'A1' with the cell your IMPORTHTML function is in, and change foo to the URL you're trying to import.
function refreshData() {
var range = SpreadsheetApp.getActiveSpreadsheet().getRange('A1');
range.clear();
range.setFormula('=IMPORTHTML(foo)');
}
Then go to Edit > Current Project Trigger > Add Trigger, and set a refresh interval.
Hope this helps.