Time Range Moving Averages (Simple-Exponential-Weighted): TRSMA – TREMA – TRWMA

Time Range Moving Averages (Simple-Exponential-Weighted): TRSMA – TREMA – TRWMA

Following a request by user discovery2005 (https://www.prorealcode.com/topic/media-mobile-a-tempo/) on the italiam forum, I coded these 3 MA’s to limit calculations to the desired time range, without being affected by data outside that same range.

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?

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

  1. Jan Wind • 05/22/2019 #

    Good evening Roberto,

    I do not understand Italian, so I could not read the background.
    Why coding the EMA’s for a certain time within a day, as you can also adjust the graph for trading hours at Options –> Platform Options at Trading Hours ?
    I would think it slows down the rebuilding of a graph when you would have more then 1.000 bars

    KR Jan

  2. robertogozzi • 05/22/2019 #

    Results, while matching when it’s SMA compared to TRSMA, are different in the case of WMA and EMA even when using the same custom hours.
    So, since it was requested on the forum, this must be the reason of its possible use.

  3. Khaled • 05/22/2019 #

    Hi Jan and Roberto, I agree, if you adapt properly the Trading Hours in Plateforme Settings, you are not supposed to calculate Indicators “manually” (I mean using coding).
    But, how would you do if, for example, you want to calculate the average volume intraday, updated at the end of each 5 min candle? the SMA[n](Volume) doesn’t do the job and you need to update the “n” manually if you’re scalping.
    Besides, if you look at IG Markets DAX CFD on 24th Dec. 2020, on a 5 min TF, you can see price changes but Volume always 0, so if you want the SMA[20](Volume) on a 5 min TF, you will get one day of zero volumes included in the SMA.
    (For some reason, I cannot add a graph with posting a reply to an exsiting post)

  4. SkippyTrader • 05/22/2019 #

    Does the EMA calculation have an issue? I can see that on the chart it keeps moving in the non-trade hours range: instead of a straight line between close of yesterday and open of today.

    Would it more correct as such to change the ‘Line 15’ ? To something like:

    IF (opentime >= StartTime and opentime<=EndTime) THEN

    TREMA = close

    endif

    ?

  5. robertogozzi • 05/22/2019 #

    It surely CHANGES even when currently outside time range, as the lookback periods change as well, thus making past calculations different each time.

    • SkippyTrader • 05/22/2019 #

      Thanks Roberto, but shouldnt the values in the outside time range not be different? As it should be the same at whatever the values were at “EndTime” until the next “Starttime” of which then the values calculate on the Bar[1] values which are whatever yesterdays Endtime values were, right? The time outside time range should be a constant = EndTime values ? The lookback period shouldnt be changing outside the time neither, as say Bar[1] at any time between opentime>Endtime and opentime<StartTime should be the EndTime's bar, and thus a lookback period of [14] at any time outside of the market should be the same lookback period of 14 bars before the EndTime ?

      Or have i confused myself on using this to calculate on only trading time range bars?

  6. robertogozzi • 05/22/2019 #

    Actually it is a constant (I tested them on a 1-hour TF, 9am to 5pm) and outside that time range it’s flat.

avatar
Register or

Likes

avatar avatar avatar
Related users ' posts
manchokcity can we have it in mql4 platform? or how or which platform do we use it?
camporan I don't use MetaTrader so I won't be able to do the translation myself. Sorry!
Alexander9 This can for amibroker ? . Thanks
Alberto Aguilera Hi! Thanks for your strategy Anyone can check it with 200 bars?
TempusFugit Hi, this simple system for DOW and only shorts has worked quite well, maybe because of its q...
phoentzs Unfortunately, I never pursued this strategy further. Maybe I should take a look with what ...
funkystuff Salut Balmora, Ton indicateur est plutôt intéressant :) Penses-tu qu'il soit possible de l'...
brian gilbert Hello, can you explain to me what are "pipsize" and "ATAN"? What functions do they have and ...
Bodaris Bonjour, Je suis débutant 1 mois :p pipsize ressemble à la fonction pointsize et ATAN...
darbes Hi How does it go on live ? JC
antonio73 Balmora74, io vedo che funziona anche su timeframe ad 1 minuto con piccole ottimizzazioni, t...
Juananantoniorodriguez hola buenas, a este sistema automático, Cómo se le podría poner un stoploss de beneficio sim...
Leo I don't know, I just copy paste the strategy. The optimisation of the values I wrote them in...
bertrandpinoy hello Leo I'm spending time on your strategy code. do you agree to try to include this code ...
bertrandpinoy //version a: ajout filtre MM defparam cumulateorders=false // --- paramètres taille =...
capgros Bonjour @Nicolas, Thanks a lot for this tool, it is very useful for me. I would like to s...
Hans63 Would you add the possibility to color also the Heikin Ashi and bar chart?
Nicolas That's possible, please open a new topic in the indicator forum explaining what you need exa...
DimKar Dear sir , thank you very much for sharing !!!! it is awesome ...!!! Please can you tell me...
Nicolas Change line 62 with: drawcandle(flup,fldn,flup,fldn) coloured(169,169,169,80) bordercolor(16...
DimKar Thank you very much from Greece sir , have a nice day ....!!!! Really i do not have words...
ottimo Thank you Nicolas, great indicator, N. 1
tikigai Merci Nicolas! First Happy new Year 2020. Very good indicator BUT (yes the french "oui, m...
Nicolas Whats prorealtime version? Did you try in version prior to v11? indicator's call and loop ca...
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.
Nicolas Apply it on the price chart. The indicator plot just one single line. There are two in the...
jamesoc Hi Nicolas, do you happen to know if there is an indicator that can be applied to charts, to...
gustavobp Buenos dias Nicolas, al agregar tu indicador no me reconoce la variable Price ni en la linea...
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.
Bard Incredible, that is the clearest depiction of the trend I've ever seen Nicolas. (I just chan...
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.
rama I want to use this indicator in trading system, it says zig zag is obsolete and not supported
Nicolas Right, due to its repainting behavior, the zigzag is not allowed in automated trading with r...
rama I noticed it changes as time progress, I am 7 as the average, how many period it wont chang...
Gordon101 Hi when I added your Guppy indicator to my chart it went below the chart beside the oscilla...
Nicolas Add it on the price by using the wrench located on the left upper side of your price chart.
Gordon101 Thanks Nicolas, worked a treat.
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
ak5hay2 Works like crazy on bitcoin. Use different timeframes. Thanks a lot Doc!!!
richyowen Hi, great code thanks. Very new to this forum. Is there a way to add a 100point target on an...
lisamitch50 Morning all, Just backtested on quite a few instruments, worked well on backtesting, but tel...
swapping merci gabri, on va le mettre à l'essai ;)

Top