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 • 274 days ago #

    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 • 243 days ago #

    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 • 243 days ago #

      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 • 243 days ago #

      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 • 243 days ago #

      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 • 242 days ago #

      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 • 208 days ago #

    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 • 208 days ago #

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

  4. David • 208 days ago #

    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
JM David, Thanks a lot and next week I begin the test of this strategy in real... You have ot...
rejo007 hello david, i'll try it could you tell me wich strategy do you use in real? thanks
David Somogyi Hello, I have a couple of DAX strategies of breakout and mean reversion. I'll try to post...
Thomas007 Is there any way to build something similar for FX? I wonder what would be the replacement f...
Maz I like this
atlante je me demande si prorealtime pourrait etre programee sur fonction lorsquún point cgange de c...
Wilko I'm happy my code snippet inspired some new thoughts! Thanks for the feedback!
CKW Thanks Wilko. I modified your daily strategy to 4H and tested WF on Dow Jon with acceptable ...
Wilko Thanks!
Francesco78 Thank you Juan Salas!, will have a look now
Francesco78 HI Juan, I created this forum where you can share with us your results if you dont mind. By...
Francesco78 how do you define trailingstep and trailingstart?
supertiti Felicidades Laurenzo d'avoir pris le temps pour ce gros travail et en plus dans l'esprit du ...
gatarayihajp Hello,  It's very interesting indicator. Could you explain more about it? Thank a lot
Pietro Fontana Hi Wings, i did not found a forum thread for this interesting system so i post my comment he...
stockdemon The larger than sign (>) means that it will trigger at 54 or later, i.e. also 22:00.
raphaelopilski Hi Wing, nice work!!! question: could you put a trailing stop in it? like: after profit of...
diegofe_2000 cordial saludo NICOLAS , gracias por excelente indicador. ¿ es posible obtenerlo en MT4 ? ...
Nicolas Lo siento, pero no estoy trabajando para ayudar a la gente aquí de forma gratuita para promo...
diegofe_2000 Nicolas , gracias por tu atención. La pregunta era por curiosidad (yo no trabajo ni manejo ...
Tedvin Nice one, thanks a lot Maz :)
victormork Thanks Man!!
MtraderWD40 Many thanks for sharing this, simple but a great indicator. Used it successfully for visual ...
David Balance thanks for sharing this excellent indicator.  Here are some thoughts.  please ad...
supertiti Il manque 2 slash devant len dans le code dur car la variable ne marche pas bonne journée
4 months ago
HerveS_67 Bonjour, A quoi correspondent les données S, M, L ? Hello, What do the data S, M, L?
gabri Excellent job like always!! are you working also on the Barycenter indicator?
Nicolas No but I think you can find a lot of different version of the "center of gravity - COG" indi...
Gennadiy Thank you, very much, Nicolas, for this wonderfull Indicator! I have a question. I have adde...
Gennadiy Here is my code: RETURN long as "long signal", short as "short signal", weightedaverage[MApe...
Gennadiy Here is the link to the image:
Francesco78 Hi Juan Salas and thank you very much for your undeserved compliments. I'm not sure if I un...
Juan Salas Hi Francesco, Yes, this is pretty much the question. The system ask me a number of contract...
Francesco78 ok sounds good, you can put min size = 1 and go for the seasonable breakout too, also you ca...
Raspoutine Hi Nicolas,The results are not identical   ma200 = Arevage(200) //c4 = summation[2...
Magela01 is this ok with AMibroker?
Nicolas Prorealcode is a website about prorealtime trading platform programming, this code will not ...
gabri Kris, let me know which color you want to use. The lines to change are the 22,23,24.
paulon Hi Gabri.  Very interesting indicator.  I changed the colours to if v>=v[1] thenr=0g=255b...
gabri Paulon, you are right, I used the variable b in too many places :) Try to change the follo...