Simple moving average block diagram

I am reading https://decibel.ni.com/content/docs/DOC-5041
and since I only have access to LabVIEW 6.1, I am interested in the block diagram JPG.
Unfortunately, I am getting an error when I click on the JPG.
Can someone help me out by posting it?
Solved!
Go to Solution.

This seems like very clumsy code. For example if you later want to average more or fewer elements, you would basically need to rewrite the code from scratch. It is not scalable! Why would you need six diagam constants (DBL zero)? All you need is one and branch the wire. Why would you wire N of the FOR loop when autoindexing over the array? This is very crude beginner code that will only teach you bad habits.
If you don't have access to the "ptbypt mean", you can make your own. Here is an old example (see lower part of code. The ptbypt version above it is just used to show that it gives the same result)
Try to implement it. To change the number of points to average, all you need to do is change a single integer. Since the mean does not care about the order of elements in the buffer, all you need is replace the oldest with the newest at each iteration, no need for rotating or shifting, etc.
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Determining simple moving average based upon duration

    Here is the link to the image of the spreadsheet that I am developing: http://dl.dropbox.com/u/13788011/Spreadsheet%20Image%2001.jpg
    This spreadsheet will allow me to track my ongoing progress on my favorite disc golf course. Column F (30 Day SMA*) is the column that needs a formula that I can't figure out how to write.
    What I want to do:
    I want each cell in column F to show the average score (derived from column B) for all dates played between that date (column A, same row as the F-cell) and any score from within the previous 30 days.
    I have been reading various materials so far, but none of these sources address this particular desire of mine, and -- as that I am still learning Numbers '09 -- this formula is too convoluted for me to figure out. Any help would be greatly appreciated.
    Thanks,
    Kris
    PS - I know of the moving average feature available in Numbers' charts, but I am desiring an actual number within the table.
    *SMA = Simple Moving Average

    kris,
    Thank you for the star. Glad to hear that the solution worked for you.
    Yes, the formulas are nice and compact in Numbers when you use the column and row shortcuts.
    All the ...IFS formulas are pretty powerful for setting conditions. The learning threshold is placing those darn quotes and ampersands in the right places for the comparison operators.
    Good luck,
    Jerry

  • Exponential Moving Average - EMA - in PowerPivot

    Hello All
    We´re having a challenge trying to put the [20] (trading days) Exponential Moving Average (EMA) in our data model in PowerPivot.
    Here is the EMA formula and sample spreadsheet:
    http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages
    Pasted the formula here for convenience:
    SMA (simple moving average): [10] period sum / [10]
    Multiplier: 2 / ([Time period] + 1) )
    EMA: {Close - EMA(previous day)} x multiplier + EMA(previous day).
    Sample spreadsheet
    http://stockcharts.com/school/data/media/chart_school/technical_indicators_and_overlays/moving_averages/cs-movavg.xls
    In our model the fact table have these columns:
    Symbol Date Open High Low Close Volume
    And in the Calendar table we´ve identified the trading days (Calendar[TradingDayNumber]) as 1 so we can count them back.
    We want the EMA calculated field in a pivot table like this
    Filter context: a date selected on Calendar[FullDate]
    Row context: FactTable[Symbol]
    Values: FactTable[Close]
        FactTable[EMA 20D] >> Missing
    So far we got these calculated fields:
    Period
    =20
    Ema Multiplier
    =2 / ([Period] + 1)
    Average 20D CLOSE
    =IF([Sum of CLOSE]=BLANK(),BLANK(),(CALCULATE(AVERAGE(FactTable[CLOSE]),FILTER(ALL(Calendar),Calendar[TradingDayNumber]<=MAX(Calendar[TradingDayNumber]) && Calendar[TradingDayNumber]>MAX(Calendar[TradingDayNumber])-[Period]))))
    But it looks like the EMA formula contains a self reference from previous values, and it also starts from a SMA (Average 20D CLOSE) value.
    How can we do it?
    Thanks in advance. I highly appreciate your support.

    Nico,
    Is this still an issue?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Moving average forecast does not work correctly

    Hello,
    I have a forecast model with the strategy moving average 6 months. When I checked the forecast values in the planning book, I recognized that there is a mismatch with the calculation of the forecast:
    There is a drift of 2 months when showing the values in the appendant buckets. The first bucket which is filled with forecast values (bucket: current month + 1) contains the moving average value from month - 8 until month - 2.
    Example: forecast value for Feb 12 is calculated as follows:
    (Nov 11 + Oct 11 + Sep 11 + Aug 11 + Jul 11 + Jun 11) / 6
    It is the same procedure for all other following months.
    The right calculation should be as follows:
    (Jan 12 + Dez 11 + Nov 11 + Oct 11 + Sep 11 + Aug 11) / 6
    I checked several settings in the activity and job creation and in the setting of the forecast profiles. I expected that an offset of 2 months is set, but there is nothing.
    So, I do not know how to explain this system behaviour....
    Hope anybody can help!
    Thanks and kind regards
    Heinz

    Hello Heinz,
    The only place to check is the forecast profile. Let me assume that you are not talking with reference to SPP. Also, that the period indicator in your master profile is Months. So, this would mean that you have maintained forecast profile as follows:
    You need to cross-check that the offset in the section history horizon of the master profile should have value +1, since you are running the forecasting during January, and you want January history to be considered in average calculation. Periods in history horizon should be 6.
    Similarly, in the forecast horizon in the master profile, you should have an offset of +1, since you are running the forecast in Jan, but you want the forecast to happen from the month of Feb onwards.
    Also, check in the univariate profile tab that you are checking for the right KF for history values, when you look in the planning view. 
    There is nothing more to standard forecasting apart from few things like 'like profile' or 'phase-in, phase-out' profile. Other option for changes is some custom logic, but it doesn't seem that there is a need for it if calculation is for simple moving average.
    So, if the above points don't explain your situation, then better to raise OSS for SAP, to see if there could be some bug.
    Thanks - Pawan

  • SSRS 2008 Column Chart with Calculated Series (moving average) "formula error - there are not enough data points for the period" error

    I have a simple column chart grouping on 1 value on the category axis.  For simplicity's sake, we are plotting $ amounts grouping by Month on the category axis.  I right click on the data series and choose "Add calculated series...".  I choose moving average.  I want to move the average over at least 2 periods.
    When I run the report, I get the error "Formula error - there are not enough data points for the period".  The way the report is, I never have a guaranteed number of categories (there could be one or there could be 5).  When there is 2 or more, the chart renders fine, however, when there is only 1 value, instead of suppressing the moving average line, I get that error and the chart shows nothing.
    I don't think this is entirely acceptable for our end users.  At a minimum, I would think the moving average line would be suppressed instead of hiding the entire chart.  Does anyone know of any workarounds or do I have to enter another ms. connect bug/design consideration.
    Thank you,
    Dan

    I was having the same error while trying to plot a moving average across 7 days. The work around I found was rather simple.
    If you right click your report in the solution explorer and select "View Code" it will give you the underlying XML of the report. Find the entry for the value of your calculated series and enter a formula to dynamically create your periods.
    <ChartFormulaParameter Name="Period">
                      <Value>=IIf(Count(Fields!Calls.Value) >= 7 ,7, (Count(Fields!Calls.Value)))</Value>
    </ChartFormulaParameter>
    What I'm doing here is getting the row count of records returned in the chart. If the returned rows are greater than or equal to 7 (The amount of days I want the average) it will set the points to 7. If not, it will set the number to the amount of returned rows. So far this has worked great. I'm probably going to add more code to handle no records returned although in my case that shouldn't happen but, you never know.
    A side note:
    If you open the calculated series properties in the designer, you will notice the number of periods is set to "0". If you change this it will overwrite your custom formula in the XML.

  • In block diagram connecting wire getting blur while saving the VI in LabVIEW 2009

    Hello,
    I am using Labview 2009, And while I am saving  a simple VI connecting wires are getting blurry. What could be the problem?? Is it affect my program while running?
    Solved!
    Go to Solution.

    Go into Tools>>Options, select the Block Diagram page and find the section called Constant Folding. If the CF for wires check box is checked, then this is most likely the reason. You can uncheck the check box and it won't affect the way your code runs.
    If this isn't the case, you should upload an image of what it looks like.
    Try to take over the world!

  • Moving average price variance in Invoice verification

    Hello,
    I set in sys that the moving average of price variance will be check in tolerance of x% (lower & upper limit) BUT the system ignore it , when I save an Invoice (MIRO) with price that change the moving average price for more than X% the invoice was saved with no W/E massage . I set all massages that seams to be relevant with E but nothing was happened .
    What is the way to set the system that in Invoice verification stage it will check the moving average price variance and give an alert or will not let the invoice to be post ???
    Best Regards
    Idit

    Hi,
    You can block Invoices using transaction code OMC0
    (a) Use Tolerancy Key VP for your company code
    (b) Fill-up Lower and Upper check tolerance limit %
    When a stock posting line is created as a result of an invoice item, the system calculates the new moving average price that results from the posting. It compares the percentage variance of the new moving average price to the old price using the percentage tolerance limits defined.
    Bye,
    Muralidhara

  • Saved block diagram wont open

    I am a new labview user so this may be obvious, but I have a problem nonetheless:
    I have drawn a simple program and saved it but when I open it again, only the front panel opens and not the block diagram as well, which I wish to edit. I am openning labview on the same machine, same version etc. what do I need to do to get this working properly?
    Thanks to anyone for their help

    Hi Dougonlabview,
    Just press Ctrl+E. This will bring you to the diagram. Pressing Ctrl+E again will bring the front panel back on top.
    Regards,
    Mathieu Steiner, Test System Engineer, Safran Engineering
    CLD, ISTQB

  • How do I create a SCOM 2012 MP calling PowerShell to calculate a moving average of an event log event count?

    I'm tasked to create a SCOM Monitor MP that needs to be deployed on different servers where it needs to count events in the eventlog and trigger an alert.
    Before it is suggested that counting an absolute arithmetic difference is enough and offering links to such solutions, there is a "gotcha!" :
    There might be one server, Server A,  that gets, say, 1000 events per hour, an increase of 100+ should trigger the alert.
    On Server B, only gets 100 events per hour, and an increase of 10+ should also trigger the alert.
    Therefore: You *can't* use an absolute diference, but *must* use a percentage difference.
    It gets more challenging as there is another "gotcha":
    Actually what should trigger the alert is a rate increase of events that falls outside of  two Standard Deviations of a Moving Average. The best example is the stock market: Your stock price moves up and down daily, but also steadily moves up due to
    inflation over the years. You want a monitor that will alert you when the stock price goes above or below two standard deviations from the *moving average*.
    I know how to call a PowerShell script from a SCOM Monitor, but I don't know how to get SCOM and PowerShell to "remember" prevous sampling's counts, because Monitors are state-less (e.g. "memoryless") .
    Since SCOM, I'm told, can monitor any process state over time, I'm surprised that I don't see any support for statistical time-series analysis .
    Any help would be appreciated.

    Hi,
    beyond advanced topic! That's what I like.
    First, very good description, these are almost functional specifications!
    I would also chose PowerShell.
    Some time ago we did a similar situation - where
    it was necessary to take into account the previous
    situation|state.
    We resolve this in a way that the states|values was
    stored in the dedicated text file. So, at each new interval we collect new samples, read previous samples, calculate required values, stored this new calculated values, if required create property bag and trigger alert.
    This is of course high level view. But in general the entire process is done in PS script.
    Recently, I found that
    the xml files and PS scripts bring
    a lot of flexibility. Especially in building custom
    diagnostics.
    And there is no need to care about distribution of this files,
    they may be included in the MP.
    So SCOM infrastructure take care of this. 
    One piece of advice: First decide
    whether you need only alert
    or you want to steer|change health. The first case
    is simpler - you need rule. The second is more complex - you need monitor!
    But of course the main part is PS script.
    Regards,
    Ivan

  • How to find icon position of currently executed VI on caller's block diagram

    Dear forum,
    I currently try to use a LabVIEV VI as a simple sequencer: Several (very slow) actions have to execute one after another. Each action is represented by a Sub-VI, some actions are executed several times. My task is to visualize the currently executed Sub-VI somehow.
    My first intention (simply manipulate the icon of the currently running VI with "VI Icon.Get as Image Data" / "VI Icon.Set from Image Data" invoke nodes) failed, because this changes the icon of ALL instances of this VI; if you use the same VI several times, the icons of all these VI are changed (see here: http://forums.ni.com/t5/LabVIEW/How-to-change-animate-icon-of-currently-running-VI/m-p/3120754/highl...
    My current approach is to use an image of the block diagram (with "VI: Block Diagram: Get Image Scaled" invoke method) within a picture control of the front panel and to work within this control. But for this I need to know the position of the icon of the currently executed VI. I know that I can evaluate Bounds and Position via the GObj properties, but how do I find the currently running VI (note that a VI may reside several times on the block diagram, so the name of the VI is not unique)? IMHO the simpliest way would be if a VI could find its icon on the caller's block diagram itself when executed...
    It's clear that this position is not the position on the picture yet, but this conversion is a small piece of work...
    Regards,
    cpschnuffel
    Solved!
    Go to Solution.

    Yamaeda wrote:
    Run it in highlight mode, done.
    Sure if you don't mind having functional checks taking hours instead of minutes...okay maybe that is exagerating for a simple VI like this, but it would increase cycle time.  Honestly I think the best solution would be to use the helper VI that was mentiond before, which keeps track of what VI is running.  You can of course use scripting to get the block diagram image, but there isn't a good way to know what exact VI is running using VI server.  Here are a few discussions.
    https://lavag.org/topic/16660-how-to-get-actual-vi-execution-state/
    https://decibel.ni.com/content/thread/18687
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Moving average price and standard price

    Dear All,
      Its simple question can any one explains me what is the difference between moving average price and standard price and how the posting will happen with these two price controls and what will get updated.

    Dear Tiru,
    There are two types of price control as below:
    a)Moving Average Price (MAP):
    -If PO and or Invoice price was differ from material master record, the difference was posting
    to stock account. Therefore the valuation price will change.
    b) Difference between a PO price or invoice price and the material master are posted to price
    difference account(PRD). As a result, the price in material master remain same.
    Example:
    Material Master Record:
    Total Qty: 10, Total Value 20, Price 2
    Scenario:
    PO: 10pcs at 2.50 EUR/PC
    Good receipt 10 pc
    Invoice 10 pc at 2.50 eur/pc
    a) MAP:
    Posting:
    Stock Account GR 25 +
    GR/IR Clearing    GR  25 -, IR 25 +
    Vendor Account  IR 25 -
    New Material Master ,Result:
    Total Qty = 20
    Total value = 45
    Price = 2.25
    b) Standard Price:
    Posting:
    Stock Account  GR 20 +
    GR/IR Clearing    GR  25 -, IR 25 +
    Vendor Account  IR 25 -
    Price difference Account(PRD)  GR 5 +
    New Material Master ,Result:
    Total Qty = 20
    Total value = 40
    Price = 2.00
    Hope this help.
    Loke Foong

  • Copy Standard Cost to Moving Average Price

    Dear All,
    We are maintaining the materials with price control as Standard Price and moving average price is updated and used only for statistical purpose.
    I have a requirement of copying the standard price to moving average price field just after the standard costs have been released.
    We have used CK40N to complete the calculation and release of standard costs.
    Please let me know which SAP standard transaction can be used for the purpose.
    Regards,
    Manish Gupta

    Hi
    Whats the need to copy std price to moving price?
    I dont think there is any such t code to copy it.. But a weird work around is, if u r on ECC 6.0, you can change the price control from S to V and again V to S.. In this process, your price will get copied from S to V
    However, not a recommended way of doing... If you do, you shud do this at a shot and blocking all others users
    Regards
    Ajay M

  • Probe windows disappear on Block Diagram

    Hi all,
    I came across an odd issue yesterday using the probes in Labview 2011. When I attach a probe to a wire and leave the probes inside the probe window they seem to work fine, however as soon as I launch the probes as separate windows, then click the title bar to move it to a convinient place they seem to disapear from the block diagram. Once this happens the probes no longer function and simply retain the values they had before they removed themselves.
    I have attached a couple of images to show what I mean:
    probe-window.jpg shows everything working as normal with the values in each probe acquired correctly.
    separate-window.jpg shows what happens when I launch the probe windows and try and move them. They disappear from the BD and no longer function as probes.
    Not a major issue I know but one I find very annoying as I like to move the windows to meaningful positions to clearly tell me which wire the values are coming from on the BD. I couldn't find anything similar on the forum so I don't know if I'm the only one with this problem, but it definitely did used to work!
    Any ideas?
    Attachments:
    probe-window.jpg ‏81 KB
    separate-window.jpg ‏98 KB

    I can't replicate the condition. Have you tried to run a repair on your LabVIEW installation?
    By the way, there is a much simpler way (and more scalable) approach to accomplishing what you are trying to do:
    Attachments:
    string to array.png ‏18 KB

  • From string to block diagram

    Hi,
    I need to know how you can translate a string, a formula, to the block diagram. So for instance, if you have G=5+3*lnW, how can you translate the ln to the ln in the block diagram. The formula isn't fixed so I can't make a hard code.
    Thanks in advance
    KF_ 

    You would need to write a parser that would evaluate the equation entered. If you use RPN this is fairly easy to do. RPN is nice since it lends itself well to using a stack for processing the equation and you will always be dealing no more than the top two elements of the stack. Your evaluation routine would be in a loop that would parse the equation and invoke the proper case in a simple state machine. You will need to use a shift register to store the variables, operations and intermediate results as you parse the equation. You would need a case for each operation you will support.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • Terminal images for arrays on block diagram

    I had always know that the thickness of the wire is representative of the size of the array on the block diagram (Thin wire, scalar, thicker wires, larger dimension arrays)
    I never noticed before that the terminal on the block diagram contained the [ ] symbols to indicate it is an array.  But also, the larger the dimension of the array, the thicker the brackets are, up to about 5-D.  (Probably because I rarely need a 3-D array, and large than isn't any practical, logical reason for a 4-D or larger array.)
    However, looking at the image of the terminal, the shaded area containing the outgoing or incoming triangle actually obscures one bracket or the other.
    While I wouldn't want the terminal to get any larger (which is why I don't like the icon view, it is way too large), it seems like the terminal should show both the opening and closing brackets to indicate an array rather than obscuring one.
    Any comments?
    Message Edited by Ravens Fan on 08-22-2009 12:59 AM
    Attachments:
    Example_VI_BD.png ‏3 KB

    Definitely keep the arrows. They are what tell me the direction of the terminals.
    As I was saying in another post, there is nothing intuitive about the thick border/thin border differences to tell whether the terminal is a source or sink. I like that they are a bit different, but if you put them side by side with no wires and no arrows, I couldn't tell you which was which.
    As for array size, as Christian says, if I want to know the type/dimensions of the array, I'll use context help. I just thought it was interesting (and I had never noticed it before) that the array size was encoded in the image as well.
    I myself wouldn't mind if the terminal grew 2 or 4 pixels wider, but I can completely understand how it would bother a lot of people.
    I think in the current image, too much is obscured by the arrow and its background, even for the scalar type. Actually, why is there a light background behind the arrow at all. That is the real source of the problem. Eliminate the background, and move the arrow over to the edge, and you can see everything without extra shading and without causing the terminal to grow.
    See below:
    1. Terminal size maintained.
    2. Direction arrow maintained, just slightly moved.
    3. Goofy shaded background removed.
    Message Edited by Ravens Fan on 08-22-2009 09:48 PM
    Attachments:
    terminals3.png ‏5 KB

Maybe you are looking for