Traducir:"Intelligent Moving Average"
Forums › ProRealTime foro Español › Soporte ProBuilder › Traducir:"Intelligent Moving Average"
- This topic has 6 replies, 2 voices, and was last updated 5 years ago by Nicolas.
Viewing 7 posts - 1 through 7 (of 7 total)
-
-
09/15/2019 at 6:01 PM #107608
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/
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100//@version=2study("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.0feecalc := 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 = blackcol2 = blackcol3 = blackcol4 = blacka1 = 0if kaz>kaz1 and kaz>kaz2 and kaz>kaz3 and kaz>kaz4 and kaz>kaz5col1:=bluecol2:=blackcol3:=nacol4:=naa1 := crossover(s1, s2) ? 1 : crossunder(s1, s2) ? -1 : 0a2 = 0if kaz1>kaz and kaz1>kaz2 and kaz1>kaz3 and kaz1>kaz4 and kaz1>kaz5col1:=bluecol2:=nacol3:=blackcol4:=naa2 := crossover(s1, s3) ? 1 : crossunder(s1, s3) ? -1 : 0a3=0if kaz2>kaz and kaz2>kaz1 and kaz2>kaz3 and kaz2>kaz4 and kaz2>kaz5col1:=bluecol2:=nacol3:=nacol4:=blacka3 := crossover(s1, s4) ? 1 : crossunder(s1, s4) ? -1 : 0a4=0if kaz3>kaz and kaz3>kaz1 and kaz3>kaz2 and kaz3>kaz4 and kaz3>kaz5col1:=nacol2:=bluecol3:=blackcol4:=naa4 := crossover(s2, s3) ? 1 : crossunder(s2, s3) ? -1 : 0a5=0if kaz4>kaz and kaz4>kaz1 and kaz4>kaz2 and kaz4>kaz3 and kaz4>kaz5col1:=nacol2:=bluecol3:=nacol4:=blacka5 := crossover(s2, s4) ? 1 : crossunder(s2, s4) ? -1 : 0a6=0if kaz5>kaz and kaz5>kaz1 and kaz5>kaz2 and kaz5>kaz3 and kaz5>kaz4col1:=nacol2:=nacol3:=bluecol4:=blacka6 := crossover(s3, s4) ? 1 : crossunder(s3, s4) ? -1 : 0plot(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)09/16/2019 at 10:04 AM #10768109/16/2019 at 1:15 PM #10770909/16/2019 at 1:59 PM #107714¿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!
09/16/2019 at 3:13 PM #10774609/21/2019 at 12:23 PM #10811209/23/2019 at 10:23 AM #108219 -
AuthorPosts
Viewing 7 posts - 1 through 7 (of 7 total)
Find exclusive trading pro-tools on
Similar topics: