Close
Skip to content

Tutorial 86 | Calculate exponential moving average using PriceSeriesProvider

In this tutorial I demonstrate how to plot an exponential moving average from a 30 minute price series provider (PriceSeriesProvider) on a 5 minute chart.

The biggest challenge with this sort of calculation is that the EasyLanguage indicator is applied to the lower time frame and hence runs on every 5 minute bar, however we actually only want to perform the exponential moving average calculation at the end of each 30 minute bar. Another issue is that the historical plot behaves differently from the real time plot.

tutorial86-tradestation-workspace
The image shows the tutorial 86 program applied to a 5 minute GBPUSD chart. A 30 minute GBPUSD is plotted as data 2. Exponential moving averages are plotted based on both the price series provider and data 2. In this image I also plot Close of Data2 and PSP.Close[0] from the PriceSeries Provider. CLICK on the image to enlarge it.
In the video below I demonstrate how to create the historical plot and how this causes a miscalculation for the real time plot. I then demonstrate how this can be corrected.

The program plots the ‘real time’ exponential average a different color from the historically calculated exponential moving average. I have also plotted the same exponential moving average calculated using data 2 set up as 30 minute GBPUSD bars.

To create a price series provider, I drag the PriceSeriesProvider from the tool box onto my program workspace. I do some initial setup using the properties tab. I then copy the code from the ‘designer generated code’ and copy it into the program and make some adjustments.

Gold Pass members can copy and paste the tutorial program created in the videos below.

Video explanation | How to calculate an exponential moving average using a price series provider | Part 1

Video explanation | Part 2

If you are are a Gold Pass member I have included a copy of this demonstration program below, make sure you are logged in to see the following content:

This content is for members only.

In the video above, the program is applied to symbol GBPUSD.

tutorial 86 w real time plot
In this image the yellow lines are the exponential moving average that have developed in real time. The blue lines show the exponential moving average calculated historically.
tutorial 86 after refresh
This image shows the same screen after the chart has been refreshed.

THESE INDICATORS, SHOW ME STUDIES, STRATEGIES AND OTHER PROGRAMS HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES.

TO THE BEST OF MARKPLEX CORPORATION’S KNOWLEDGE, ALL OF THE INFORMATION ON THIS PAGE IS CORRECT, AND IT IS PROVIDED IN THE HOPE THAT IT WILL BE USEFUL. HOWEVER, MARKPLEX CORPORATION ASSUMES NO LIABILITY FOR ANY DAMAGES, DIRECT OR OTHERWISE, RESULTING FROM THE USE OF THIS INFORMATION AND/OR PROGRAM(S) DESCRIBED, AND NO WARRANTY IS MADE REGARDING ITS ACCURACY OR COMPLETENESS. USE OF THIS INFORMATION AND/OR PROGRAMS DESCRIBED IS AT YOUR OWN RISK.

ANY EASYLANGUAGE OR POWERLANGUAGE TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (AND PARTS THEREOF) AND ASSOCIATED TECHNIQUES REFERRED TO, INCLUDED IN OR ATTACHED TO THIS TUTORIAL OR PROGRAM DESCRIPTION ARE EXAMPLES ONLY, AND HAVE BEEN INCLUDED SOLELY FOR EDUCATIONAL PURPOSES. MARKPLEX CORPORATION. DOES NOT RECOMMEND THAT YOU USE ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS (OR ANY PARTS THEREOF) OR TECHNIQUES. THE USE OF ANY SUCH TRADING STRATEGIES, SIGNALS, STUDIES, INDICATORS, SHOWME STUDIES, PAINTBAR STUDIES, PROBABILITYMAP STUDIES, ACTIVITYBAR STUDIES, FUNCTIONS AND TECHNIQUES DOES NOT GUARANTEE THAT YOU WILL MAKE PROFITS, INCREASE PROFITS, OR MINIMIZE LOSSES.