Traducir:"Intelligent Moving Average"

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #107608 quote
    Fr7
    Participant
    Master

    Hola Nicolás,

    A ver si es tan amable de traducir este código interesante.

    Para 4 promedios móviles simples, el script prueba cada combinación para obtener la máxima rentabilidad y encuentra el mejor par.

    Lo encontré aquí:https://es.tradingview.com/script/aT9ck5ua/

    //@version=2
    study("Intelligent Moving Average", overlay = true)
    src = input(close, title="Source")
    len1 = input(8, title = "SMA 1 length", minval=1)
    len2 = input(13, title = "SMA 2 length", minval=1)
    len3 = input(21, title = "SMA 3 length", minval=1)
    len4 = input(34, title = "SMA 4 length", minval=1)
    srcprofit = input(ohlc4, title="Source for Profit Calculation")
    fee = input(0.1, title="Fee (0.1 means %0.1=>0.001)", type=float, minval=0.0001)
    s1 = sma(src, len1)
    s2 = sma(src, len2)
    s3 = sma(src, len3)
    s4 = sma(src, len4)
    
    feecalc =0.0
    feecalc := 1 - (fee / 100)
    
    // yuk => profit
    // kaz => total profit (without fee)
    yuk = crossover(s1, s2) or crossunder(s1, s2)? srcprofit : yuk[1]
    kaz = nz(kaz[1]) + (crossunder(s1, s2) ? (yuk - yuk[1]) - (yuk[1]*feecalc) : (crossover(s1, s2) ? (yuk[1] - yuk) - (yuk*feecalc) : 0))
    
    yuk1 = crossover(s1, s3) or crossunder(s1, s3)? srcprofit : yuk1[1]
    kaz1 = nz(kaz1[1]) + (crossunder(s1, s3) ? (yuk1 - yuk1[1]) - (yuk1[1]*feecalc) : (crossover(s1, s3) ? (yuk1[1] - yuk1) - (yuk1*feecalc) : 0))
    
    yuk2 = crossover(s1, s4) or crossunder(s1, s4)? srcprofit : yuk2[1]
    kaz2 = nz(kaz2[1]) + (crossunder(s1, s4) ? (yuk2 - yuk2[1]) - (yuk2[1]*feecalc) : (crossover(s1, s4) ? (yuk2[1] - yuk2) - (yuk2*feecalc) : 0))
    
    yuk3 = crossover(s2, s3) or crossunder(s2, s3)? srcprofit : yuk3[1]
    kaz3 = nz(kaz3[1]) + (crossunder(s2, s3) ? (yuk3 - yuk3[1]) - (yuk3[1]*feecalc) : (crossover(s2, s3) ? (yuk3[1] - yuk3) - (yuk3*feecalc) : 0))
    
    yuk4 = crossover(s2, s4) or crossunder(s2, s4)? srcprofit : yuk4[1]
    kaz4 = nz(kaz4[1]) + (crossunder(s2, s4) ? (yuk4 - yuk4[1]) - (yuk4[1]*feecalc) : (crossover(s2, s4) ? (yuk4[1] - yuk4) - (yuk4*feecalc) : 0))
    
    yuk5 = crossover(s3, s4) or crossunder(s3, s4)? srcprofit : yuk5[1]
    kaz5 = nz(kaz5[1]) + (crossunder(s3, s4) ? (yuk5 - yuk5[1]) - (yuk5[1]*feecalc) : (crossover(s3, s4) ? (yuk5[1] - yuk5) - (yuk5*feecalc) : 0))
    
    col1 = black
    col2 = black
    col3 = black
    col4 = black
    
    a1 = 0
    if kaz>kaz1 and kaz>kaz2 and kaz>kaz3 and kaz>kaz4 and kaz>kaz5
        col1:=blue
        col2:=black
        col3:=na
        col4:=na
        a1 := crossover(s1, s2) ? 1 : crossunder(s1, s2) ? -1 : 0
    
    a2 = 0
    if kaz1>kaz and kaz1>kaz2 and kaz1>kaz3 and kaz1>kaz4 and kaz1>kaz5
        col1:=blue
        col2:=na
        col3:=black
        col4:=na
        a2 := crossover(s1, s3) ? 1 : crossunder(s1, s3) ? -1 : 0
    
    a3=0
    if kaz2>kaz and kaz2>kaz1 and kaz2>kaz3 and kaz2>kaz4 and kaz2>kaz5
        col1:=blue
        col2:=na
        col3:=na
        col4:=black
        a3 := crossover(s1, s4) ? 1 : crossunder(s1, s4) ? -1 : 0
    
    a4=0
    if kaz3>kaz and kaz3>kaz1 and kaz3>kaz2 and kaz3>kaz4 and kaz3>kaz5
        col1:=na
        col2:=blue
        col3:=black
        col4:=na
        a4 := crossover(s2, s3) ? 1 : crossunder(s2, s3) ? -1 : 0
    
    a5=0
    if kaz4>kaz and kaz4>kaz1 and kaz4>kaz2 and kaz4>kaz3 and kaz4>kaz5
        col1:=na
        col2:=blue
        col3:=na
        col4:=black
        a5 := crossover(s2, s4) ? 1 : crossunder(s2, s4) ? -1 : 0
    
    a6=0
    if kaz5>kaz and kaz5>kaz1 and kaz5>kaz2 and kaz5>kaz3 and kaz5>kaz4
        col1:=na
        col2:=na
        col3:=blue
        col4:=black
        a6 := crossover(s3, s4) ? 1 : crossunder(s3, s4) ? -1 : 0
    
    plot(s1, color=col1, linewidth = 2)
    plot(s2, color=col2, linewidth = 2)
    plot(s3, color=col3, linewidth = 2)
    plot(s4, color=col4, linewidth = 2)
    plotarrow(a1)
    plotarrow(a2)
    plotarrow(a3)
    plotarrow(a4)
    plotarrow(a5)
    plotarrow(a6)
    
    #107681 quote
    Nicolas
    Keymaster
    Master

    No hay captura de pantalla? ¿No estás acostumbrado a pedir la conversión después de tantas solicitudes que hiciste?

    #107709 quote
    Fr7
    Participant
    Master

    Es cierto, disculpe Nicolás………..

    #107714 quote
    Nicolas
    Keymaster
    Master

    ¿Entendiste cómo funciona? Es solo un contador de ganancias / pérdidas de un par de cruces de promedios móviles. ¿Lo encuentras valioso? ❓ ¡Porque ya podemos hacerlo (y mejor con muchas más funciones) en un backtest y optimizador!

    #107746 quote
    Fr7
    Participant
    Master

    De acuerdo Nicolas.Estaría bien realizar un backtest y optimizador.El backtest tendría varios tipos diferentes de media adaptables y las cambiaría automáticamente en cuanto detectara pérdidas(esa es la idea).

    #108112 quote
    Fr7
    Participant
    Master

    ¿Nicolas podría darme un ejemplo del sistema?GRACIAS

    #108219 quote
    Nicolas
    Keymaster
    Master

    Simplemente abra la creación asistida y haga un promedio móvil básico cruzando el sistema por encima / debajo y listo 🙂 Agregue el punto y escriba en la ventana de la sección del optimizador.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Traducir:"Intelligent Moving Average"


Soporte ProBuilder

New Reply
Author
author-avatar
Fr7 @fr7 Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Nicolas
6 years, 4 months ago.

Topic Details
Forum: Soporte ProBuilder
Language: Spanish
Started: 09/15/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...