MARTINGALA

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #99288 quote
    CHUTI
    Participant
    New

    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.

    #99290 quote
    robertogozzi
    Moderator
    Master

    >> 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! <<

    Insert-PRT-Code-1.png Insert-PRT-Code-1.png
    #99293 quote
    CHUTI
    Participant
    New
    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
    
    #99294 quote
    Juan Salas
    Participant
    Master

    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

    #99302 quote
    CHUTI
    Participant
    New

    Gracias Juan.

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

MARTINGALA


ProOrder: Trading Automático y Backtesting

New Reply
Author
author-avatar
CHUTI @chuti Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by CHUTI
6 years, 9 months ago.

Topic Details
Forum: ProOrder: Trading Automático y Backtesting
Language: Spanish
Started: 05/23/2019
Status: Active
Attachments: 1 files
Logo Logo
Loading...