Simple Moving Average Crossing Areas

v10.3
Simple Moving Average Crossing Areas

Hi all,

I create and indicator that highlighted the moment previous to a crossing SMA and the moment afterwards. What is called “Golden Cross” and “Death Cross”

The indicator is very simple but an be very usefully for an automatic strategy. Because it shows in real time the moment where is inevitable the crossing of two Simple Moving Average and the moment afterwards.

How it can be used? well I can imagine an strategy using it as a filter for Higher Time Frame or multi crossing of SMA in different time frame.

Hope you like it.

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. Kris75 • 12/03/2018 #

    Hi Leo

    Line 2 period = 100 // => period002 right ?

  2. Leo • 12/03/2018 #

    Yeah. Inputs are period001 and period002. Strange… I think the post were edited. Anyway

  3. Carlos Garcia • 12/03/2018 #

    i think must check the code

  4. Leo • 12/03/2018 #

    Period001 and period002 are the inputs of the variables. When I update the code the fisrt two lines where not there. so you can delete them or directly import the ITF file.

  5. Leo • 12/03/2018 #

    By the way I create a very interesting strategy that look very nice even in walkforward test ( just tested in AUD/USD in 5min timeframe)

    DEFPARAM PRELOADBARS=1000

    //Period001= //from 10 to 40 step 10
    //Period002= //from 120 to 300 step 30
    //Period003= //from 10 to 40 step 10
    //Period004= //from 120 to 300 step 30
    //Pentry= // from 7 to 28 step 7
    //Kp= //from 1 to 2 step 0.5

    WMA001=weightedaverage[period001](close)
    WwMA001=weightedaverage[period001](WMA001)
    SMA002=average[period002](close)

    //Crossing areas definiton
    CrossingBULL1=0
    IF WMA001 > SMA002 and WwMA001 < SMA002 then
    CrossingBULL1=1
    ENDIF
    CrossingBEAR1=0
    IF WMA001 SMA002 then
    CrossingBEAR1=1
    ENDIF

    timeframe(1 hour, default)
    //Crossing areas definiton
    WMA003=weightedaverage[period003](close)
    WwMA003=weightedaverage[period003](WMA003)
    SMA004=average[period004](close)
    CrossingBULL2=0
    IF WMA003 > SMA004 and WwMA003 < SMA004 then
    CrossingBULL2=1
    ENDIF
    CrossingBEAR2=0
    IF WMA003 SMA004 then
    CrossingBEAR2=1
    ENDIF

    timeframe(default)

    ONCE PXentry=round(0.6*Pentry)
    highest1=highest[Pentry](high)
    IF highest1 = highest1[PXentry] then
    Re1=highest1
    ENDIF
    IF high > Re1 then
    Re1=high
    ENDIF
    lowest1=lowest[Pentry](low)
    IF lowest1 = lowest1[PXentry] then
    S1=lowest1
    ENDIF
    If low 3 and hour<22 and DayOfWeek<=5 then
    // Bedingungen zum Einstieg in Long-Positionen
    IF NOT LongOnMarket AND CrossingBULL1=1 and CrossingBULL2=1 THEN
    stoploss=(close – S1)/pipsize +2*pipsize
    BUY 1 CONTRACTS AT MARKET
    SET STOP PLOSS stoploss
    SET TARGET PPROFIT Kp*stoploss
    ENDIF

    // Bedingungen zum Ausstieg von Long-Positionen
    If LongOnMarket AND CrossingBEAR1=1 THEN
    SELL AT MARKET
    ENDIF

    // Bedingungen zum Einstieg in Short-Positionen
    IF NOT ShortOnMarket AND CrossingBEAR1=1 and CrossingBEAR2=1 THEN
    stoploss=(Re1-close)/pipsize + 2*pipsize
    SELLSHORT 1 CONTRACTS AT MARKET
    SET STOP PLOSS stoploss
    SET TARGET PPROFIT Kp*stoploss
    ENDIF

    // Bedingungen zum Ausstieg aus Short-Positionen
    IF ShortOnMarket AND CrossingBULL1=1 THEN
    EXITSHORT AT MARKET
    ENDIF

    ENDIF

  6. Stenozar • 12/03/2018 #

    Hi Leo, can you explain how the strategy works? I don’t know how to program and so it’s not easy for me to understand it by reading the code. THANKS!

  7. Leo • 12/03/2018 #

    Two SMA are crossing in a time frame (5min) while another 2 SMA are crossing in a higher Time Frame (1hour) stop loss is set to next support resistace.

  8. Stenozar • 12/03/2018 #

    Thanks Leo!

  9. Madrosat • 12/03/2018 #

    Hi Leo
    something is missing in the strategy above because it does not work at all as it is

  10. Leo • 12/03/2018 #

    I don’t know, I just copy paste the strategy. The optimisation of the values I wrote them in the code: line 3 to 8

    • bertrandpinoy • 12/03/2018 #

      hello Leo I’m spending time on your strategy code. do you agree to try to include this code (see ITF file) and try to make it work. I don’t know how to do it alone yet. thank you. it is surely necessary to remove MMperiode from my code too …

  11. bertrandpinoy • 12/03/2018 #

    //version a: ajout filtre MM

    defparam cumulateorders=false

    // — paramètres
    taille = 1 //taille de contrat pour les prises de position
    active3Bougies = 1 //active ou non une suite de 3 bougies consécutives cul plate ou non (1 = OUI / 0 = NON)
    culPlat = 100 //cul plat en pourcentage (taille de la meche en % de taille global)
    MMperiode = 20 //période de la moyenne mobile (filtre pour prises de position)
    // — fin des paramètres

    avg = average[MMperiode](close)
    xClose = (open+high+low+close)/4
    IF BarIndex=0 THEN
    xOpen = open
    xHigh = high
    xLow = low
    ELSe
    xOpen = (xOpen[1] + xClose[1])/2
    xHigh = Max(Max(high, xOpen), xClose)
    xLow = Min(Min(low, xOpen), xClose)
    ENDIF
    irange = xhigh-xlow

    red = xclose<xopen and ((xhigh-xopen)/irange)xopen and ((xopen-xlow)/irange)<=(100-culplat)/100

    if active3Bougies then
    redcons = summation[3](red)=3
    greencons = summation[3](green)=3
    else
    redcons = red
    greencons = green
    endif

    if not onmarket and redcons and xcloseavg then
    buy taille contract at market
    endif

    //graph (xhigh-xopen)/irange
    //graph greencons coloured(0,255,0)

avatar
Register or

Likes

avatar avatar avatar avatar
Related users ' posts
RakeshPoluri I have a question about the bands on the candles. Is it bollinger bands or something else?
Nicolas I think that's 2 Bollinger Bands
Emperor.it "style(line,2)" C'è una guida ai parametri che si possono modificare ? Tipo stile della lin...
IV Mcm https://www.prorealcode.com/programming-with-prorealtime/
fazel53 How do i attach this indicator to my mt5 platform?
Nicolas You can't! All indicators here are for ProRealTime trading platform: https://www.prorealtime...
Nicolas c'est exactement ce que je fais entre les lignes 58 et 64 pour pouvoir tracer la ligne complète
Italo Fabian Nicolas, Ces matrices sont-elles des vecteurs unidimensionnels ou multidimensionnels? Depu...
Denis Bonjour Nicolas et RicLg, Merci Nicolas pour cet indicateur intéressant et merci RicLg pour...
Nicolas Il faut l'ajouter sur le prix avec l'icône de la clé situé en haut à gauche du graphique du ...
jerome777 merci de ta réponse
jerome777 bonjour c est bon il fonctionne parfaitement merci beaucoup
Ciccarelli Franco Per lasciare che la strategia venga eseguita (dopo aver importato il file): Basta eliminare...
JADINVEST Hello Jan, hello everyone, Thanks Jan for this strategy! Since 2020, have any of you found a...
Alessandro Furlani Hi Ian, hope you still use PRT and so you can read this post. I have tested a lot your work ...
FXmike hey my friends, thank you for this great code. my problem is he make no trade open. backtest...
FXmike Can i put a Action that my start contract is smaller than 1 ? 0.3 or 0.5 ? In wich Position...
phoentzs I wrote the code for M15 back then and also variants in H1 and M1. Everything works so far....
Alps007 Hi Nicolas. Happy New Year. Can you please program me several MACD divergence screeners ...
Arlei Zanin Hello Nicolas, would it be possible to convert the Cloud to Pascal language? Thank you.
ashee i want it in MT4
Marie-Eve Vergoz Bonsoir - Voici l'erreur qui est signalée lorsque je souhaite utiliser cet indicateur : il...
Vonasi Sure that is possible. I will code it and make a post in the English ProBuilder forum and pu...
Vonasi Vama v2 with Hull moving average included can be found here: https://www.prorealcode.com/top...
JMat45 Thank you, Vonasi.
HeikinAshi https://www.prorealcode.com/topic/ssl-channel/
jobswaps oyes aste uno de soportes y recistencias
jobswaps eso lo necesitamos
Nicolas
6 years ago
LRMA
LRMA
0
Indicators
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 ...
winnie37 yes. "No ground breaking math here, but I am finding very useful and some algo based on it i...
Jan Wind Also interesting to know what does not work, which set up you use, saves me investigating ! ...
winnie37 i just set the proorder like this: buy when 50/100/200 phase >0 and sell when under 0, go...
robertogozzi It surely CHANGES even when currently outside time range, as the lookback periods change as ...
SkippyTrader Thanks Roberto, but shouldnt the values in the outside time range not be different? As it sh...
robertogozzi Actually it is a constant (I tested them on a 1-hour TF, 9am to 5pm) and outside that time r...
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...
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...

Top