Moving Average Daily

Moving Average Daily

At this stage ProRealtime doesn’t have multi timeframe capabilities. However one easy possibility is to use the moving average of the daily timeframe with the options of DOpen, DHigh, DLow, DClose and that’s what this indicator enables you to do. You can select the number of periods ie. Days: number of periods/days (please note there’s a limit depending on the timeframe you use this on and there’s a difference between PRT and IG data periods) open/high/low/close, etc… If you are going to use this in a live trading account you will need to set: DEFPARAM Preloadbars = Here is the table of how much Preloadbars you will need depending how many periods you want to look back.  The column max days shows the maximum of what you can set Preload to.

As an example of you are using a 10 minute timeframe the maximum DEFPARAM Preloadbars = 5000 // maximum is 5000 and this is equal to the moving average of 35 days.

DEFPARAM Preloadbars =
60 24 5000
Minutes bars per hour bars per day max days
1 60 1440 3
5 12 288 17
10 6 144 35
15 4 96 52
30 2 48 104
60 1 24 208

You should find this indicator useful if you are trading mean reversion system and want to make an entry a timeframe less than the daily while using the daily moving average as the mean.

REMINDER: if you want the indicator to appear in the Price section of the chart, you must add it by clicking on the spanner icon on the little Price tab in the Price window.

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Nicolas • 12/20/2016 #

    Thanks a lot, a lot of people will find it useful!
    About customclose of the daily OHLC, you could have compute them this way: (totalprice for instance)
    LMA = ((DOpen(i)+DHigh(i)+DLow(i)+DClose(i))/4) + LMA

  2. David • 12/20/2016 #

    Unfortunately the PRT is unreliable. 
    I made a simple 7 day moving average crosses over 30 day moving average but Pro Realtime opens position even though there’s no cross over.
    I tried to provide a screenshot but I keeping getting a HTTP error.

    • Nicolas • 12/20/2016 #

      Did you change trading hours or weekends data of the tested instruments? Calculate the daily moving average like the author do it in this code means a lot of preloaded bars, did you adapt this parameter correctly? 

    • David • 12/20/2016 #

      Nicolas, I wrote the code and I have DEFPARAM Preloadbars = 3000 on m60 so that’s plenty of preloadbars.
      As far as I know I didn’t change the weekend data of FX. But the drawn moving average lines do not cross many times but the position open and they should not open. So no one else is having this issue?
      I am running the Demo of 10.3 via IG so maybe that’s having an issue?

    • Nicolas • 12/20/2016 #

      How do you call this indicator in you trading strategy code? Did you make a CALL? Have you tried to GRAPH the returned variables of the indicators while backtesting?

    • David • 12/20/2016 #

      I’m using the call function. I checked again and it seems okay now on Demo and Live testing. Luckily I took a screen shot otherwise I wouldn’t believe that there was an entry issue as per my initial comment. 

  3. David • 12/20/2016 #

    Nicolas I’ve looked at it again and there’s a problem. 
    As an example here’s a simple cross over system and you can see the entry and exit is not at the cross over. It’s even worse if you use <> for the daily moving averages for the BUY. I made 2 instances of the indicator and Call the indicators Moving Average Daily with DHigh and DLow. I’m still having HTTP error when trying to upload a screen shot. Here’s a screenshot 
    I look forward to hearing what results you have Nicolas. 
    // Definition of code parameters
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated

    // Conditions to enter long positions
    indicator1 = CALL \"Moving Average Daily HIGH\"[14]
    indicator2 = CALL \"Moving Average Daily LOW\"[50]
    c1 = (indicator1 CROSSES OVER indicator2)

    IF c1 THEN

    // Conditions to exit long positions
    indicator3 = CALL \"Moving Average Daily HIGH\"[14]
    indicator4 = CALL \"Moving Average Daily LOW\"[50]
    c2 = (indicator3 CROSSES UNDER indicator4)

    IF c2 THEN


    • Nicolas • 12/20/2016 #

      You’ll need to preload bars to get the good calculations of you indicators. I did not test it myself though. 

  4. David • 12/20/2016 #

    Nicolas I tried DEFPARAM Preloadbars = 5000
    And still the same drawn output of entries/exits not at the drawn Cross Over  around 2 days earlier than the drawn Cross Over /Cross Under. 

Register or


avatar avatar avatar avatar avatar
Related users ' posts
Stenozar Thanks Leo!
Madrosat Hi Leo something is missing in the strategy above because it does not work at all as it is
Leo I don't know, I just copy paste the strategy. The optimisation of the values I wrote them in...
osupero Buenisimo Sr Nicolas, seria posible que sólo marcara por encima o por debajo de una media mo...
Nicolas Alpha transparency from 0 to 255.
ehtsham Hi, Sir can you tell me how to put this code in indicator plz
Jan Wind Ehtsham, all you need to do is change the code in line 18 and line 20 (see the code above...
Nicolas Yes, that's how it goes when using loops..
JosephFelix Hi, Could I please have help with adding these indicators 'on price'? Every indicator that I...
Nicolas Just add it on price by clicking the wrench on the left upper side of the price chart.
abd78 @Vonasi I saw that you did some work on seasonality, I wondered if you wanted to go here and...
Vonasi Sorry - my understanding of Italian is zero so if I watch the video I won't understand it I'...
Tradingrob Hi Nicolas, when i upload this indicator in my list and use it as indicator. I get a totally...
Nicolas Apply it on the price chart. The indicator plot just one single line. There are two in the...
tradingpro salve io faccio spread trading e volevo sapere come impostare un profitto da chiudere in a...
Nicolas Per favore non fare domande generali, non correlate al post. Usa invece il forum.
Gianluca Hello Nicolas, my prt become stuck when i load the indicator, is there any problem with it?
m-zeter Has anyone found a solution for Sofitech? Would it be possible to draw two lines? An upper l...
m-zeter Hm, i dont know exactly why, but I think, that the indicator needs lots of power. I need als...
Appsoluxions Hi Nicolas, do you have the MT4 version of the indicator? I am not sure if these kind of que...
Nicolas Hi, don't have one sorry. But you can still ask for private coding through our programming s...
Appsoluxions Cool. Thanks for the response.
Nicolas Yes, this could be easily programmed with the assisted creation tool.
Karthick S Hi Nicolas, Can you please share MT4 version of this? Cheers
Nicolas No. This website is only dedicated to ProRealTime programming :)
odin here is my code c1 = ExponentialAverage[3](close) c2 = ExponentialAverage[5](close) c3 ...
juanj HI Odin Can you also kindly provide the code for the 'Short Term Trader Squezze' indicato...
odin this is the short term Trader squezze indicator. short term Trader in Trouble and squezze is...
Rafa And the PriceMAPeriod? aren´t the same?
Nicolas The PriceMAPeriod is the period to make the average of all the last X medianprice found.
Rafa Thanks a lot Nicolás. Have a nice day
apachx Hi. Please, describe the algorithm in words. I want to understand how it works, but for now...