He encontrado en ProRealCode este sistema de trading para operar con cortos:
defparam cumulateorders = true
// indicators
EMA3 = exponentialaverage[3]
EMA10 = exponentialaverage[10]
if barindex>1 then
haopen=(haopen[1]+haclose[1])/2
haclose=(open+close+low+high)/4
endif
// first order (EMA cross)
if not shortonmarket and EMA3 crosses under EMA10 then
SELLSHORT 1 SHARE AT MARKET
endif
// close position with bullish EMA cross only if we are in profit and we are not already averaging down (1 position only)
if countofposition=-1 and haclose<tradeprice and EMA3 crosses over EMA10 then
EXITSHORT AT MARKET
endif
// averaging down
if shortonmarket and haopen>haclose and haopen[1]<haclose[1] and haclose>tradeprice then
SELLSHORT 1 SHARE AT MARKET
endif
// monitor the average price of whole orders and close them accordingly
if shortonmarket and haclose<positionprice and countofposition<-1 then
EXITSHORT AT MARKET
endif
Necesito que el sistema de trading sea para operar con largos, necesito ayuda porque no lo he conseguido modificar.
Gracias de antemano.
>> Para claridad de los mensajes en los foros de ProRealCode, por favor utilice el botón “código de inserción PRT ( insert PRT code)” para separar el texto de la parte de código! ¡Gracias! <<
defparam cumulateorders = true
// indicators
EMA3 = exponentialaverage[3]
EMA10 = exponentialaverage[10]
if barindex>1 then
haopen=(haopen[1]+haclose[1])/2
haclose=(open+close+low+high)/4
endif
// first order (EMA cross)
if not shortonmarket and EMA3 crosses under EMA10 then
SELLSHORT 1 SHARE AT MARKET
endif
// close position with bullish EMA cross only if we are in profit and we are not already averaging down (1 position only)
if countofposition=-1 and haclose<tradeprice and EMA3 crosses over EMA10 then
EXITSHORT AT MARKET
endif
// averaging down
if shortonmarket and haopen>haclose and haopen[1]<haclose[1] and haclose>tradeprice then
SELLSHORT 1 SHARE AT MARKET
endif
// monitor the average price of whole orders and close them accordingly
if shortonmarket and haclose<positionprice and countofposition<-1 then
EXITSHORT AT MARKET
endif
Hola Chuti,
En principio, este código es de PROMEDIO A LA BAJA, no de MARTINGALA. No es problema, la diferencia en este código reside en que el promedio a la baja, compra en corto (1 contrato), siempre que hay un cambio de “color” a cortos en la vela Heiken Ashi, y casi siempre logra recuperarse, aunque si te te pilla una tendencia alcista de semanas o meses, puede liquidar tu cuenta. La Martingala clásica, es una repetición binaria donde en cada entrada el numero de contratos se multiplica de forma exponencial (1, 2, 4, 8, 16, 32, 64…). También te liquida la cuenta en menos de nada.
En cuanto al cambio para entrar en largos, sin problema. Te adjunto el código:
defparam cumulateorders = true
// indicators
EMA3 = exponentialaverage[3]
EMA10 = exponentialaverage[10]
if barindex>1 then
haopen=(haopen[1]+haclose[1])/2
haclose=(open+close+low+high)/4
endif
// first order (EMA cross)
if not longonmarket and EMA3 crosses over EMA10 then
BUY 1 SHARE AT MARKET
endif
// close position with bearish EMA cross only if we are in profit and we are not already averaging UP (1 position only)
if countofposition=1 and haclose>tradeprice and EMA3 crosses under EMA10 then
SELL AT MARKET
endif
// averaging UP
if longonmarket and haopen<haclose and haopen[1]>haclose[1] and haclose<tradeprice then
BUY 1 SHARE AT MARKET
endif
// monitor the average price of whole orders and close them accordingly
if longonmarket and haclose>positionprice and countofposition>1 then
SELL AT MARKET
endif
Por favor, comprueba que funciona como debe, comprando al alza como dice el código. En caso contrario, dímelo y lo corregimos.
Un saludo y bienvenido a la comunidad.
Juan