Robô long-short por cointegração intraday.

MQL5 专家

指定

Preciso de um robô que opere três pares de ativos ao mesmo tempo (x = PETR4, y = PETR3), (x = BBDC3, y = BBDC4), (x = ITUB3, y = ITUB4).


user inputs:

a_PETR, a_BBDC, a_ITUB  // float (coeficiente angular)

b_PETR, b_BBDC, b_ITUB // float (coeficiente linear)

linha_superior_positiva_PETR,  linha_superior_positiva_BBDC,  linha_superior_positiva_ITUB // float

linha_superior_negativa_PETR,  linha_superior_negativa_BBDC,  linha_superior_negativa_ITUB  // float

linha_superior_stop_PETR,  linha_superior_stop_BBDC,  linha_superior_stop_ITUB, // float

linha_inferior_positiva_PETR,  linha_inferior_positiva_BBDC, linha_inferior_positiva_ITUB  // float

linha_inferior_negativa_PETR,  linha_inferior_negativa_BBDC,  linha_inferior_negativa_ITUB // float

linha_inferior_stop_PETR,  linha_inferior_stop_BBDC,  linha_inferior_stop_ITUB // float

lote_PETR3, lote_PETR4, lote_BBDC3, lote_BBDC4 ,  lote_ITUB3, lote_ITUB4 // int

horário_inícnio // string

horário_fim // string


Lógica do EA:

se (linha_inferior_negativa< PETR3.CLOSE[0] - (a_PETR * PETR4.CLOSE[0] + b_PETR) < linha_inferior_positiva E estiver dentro do horário determinado) {

compra = (PETR3.CLOSE[0], lote_PETR3)

vende =   (PETR4.CLOSE[0], lote_PETR4)

encerra operação quando ( PETR3.CLOSE[] - (a_PETR * PETR4.CLOSE[] + b_PETR) > 0 OU horário chega ao fim OU 

PETR3.CLOSE[] - (a_PETR * PETR4.CLOSE[] + b_PETR)< linha_inferior_stop_PETR )

}

se(linha_superior_negativa< PETR3.CLOSE[0] - (a_PETR * PETR4.CLOSE[0] + b_PETR) < linha_superior_positiva E estiver dentro do horário determinado) {

compra =  (PETR4.CLOSE[0], lote_PETR4)

vende = (PETR3.CLOSE[0], lote_PETR3)

encerra operação quando  (PETR3.CLOSE[] - (a_PETR * PETR4.CLOSE[] + b_PETR) < 0 OU horário chega ao fim OU

PETR3.CLOSE[] - (a_PETR * PETR4.CLOSE[] + b_PETR) > linha_superior_stop_PETR) }


se (linha_inferior_negativa< BBDC4.CLOSE[0] - (a_BBDC * BBDC3.CLOSE[0] + b_BBDC) < linha_inferior_positiva E estiver dentro do horário determinado) {

compra = (BBDC4.CLOSE[0], lote_BBDC4)

vende =   (BBDC3.CLOSE[0], lote_BBDC3)

encerra operação quando ( BBDC4.CLOSE[] - (a_BBDC * BBDC3.CLOSE[] + b_BBDC) > 0 OU horário chega ao fim OU 

BBDC4.CLOSE[] - (a_BBDC * BBDC3.CLOSE[] + b_BBDC)< linha_inferior_stop_PETR )

}

se (linha_superior_negativa< BBDC4.CLOSE[0] - (a_BBDC * BBDC3.CLOSE[0] + b_BBDC) < linha_superior_positiva E estiver dentro do horário determinado) {

compra = (BBDC3.CLOSE[0], lote_BBDC3)

vende =   (BBDC4.CLOSE[0], lote_BBDC4)

encerra operação quando ( BBDC4.CLOSE[] - (a_BBDC * BBDC3.CLOSE[] + b_BBDC) < 0 OU horário chega ao fim OU 

BBDC4.CLOSE[] - (a_BBDC * BBDC3.CLOSE[] + b_BBDC) >  linha_superior_stop_PETR )

}


se (linha_inferior_negativa< ITUB4.CLOSE[0] - (a_ITUB * ITUB3.CLOSE[0] + b_ITUB) < linha_inferior_positiva E estiver dentro do horário determinado) {

compra = (ITUB4.CLOSE[0], lote_ITUB4)

vende =   (ITUB3.CLOSE[0], lote_ITUB3)

encerra operação quando ( ITUB4.CLOSE[] - (a_ITUB * ITUB3.CLOSE[] + b_ITUB ) > 0 OU horário chega ao fim OU 

ITUB4.CLOSE[] - (a_ITUB * ITUB3.CLOSE[] + b_ITUB)< linha_inferior_stop_ITUB )

}

se (linha_superior_negativa< ITUB4.CLOSE[0] - (a_ITUB * ITUB3.CLOSE[0] + b_ITUB) < linha_superior_positiva E estiver dentro do horário determinado) {

compra = (ITUB3.CLOSE[0], lote_ITUB3)

vende =   (ITUB4.CLOSE[0], lote_ITUB4)

encerra operação quando ( ITUB4.CLOSE[] - (a_ITUB * ITUB3.CLOSE[] + b_ITUB ) < 0 OU horário chega ao fim OU 

ITUB4.CLOSE[] - (a_ITUB * ITUB3.CLOSE[] + b_ITUB) > linha_superior_stop_ITUB )

}



反馈

1
开发者 1
等级
(11)
项目
17
59%
仲裁
2
0% / 100%
逾期
2
12%
空闲
2
开发者 2
等级
(3)
项目
4
0%
仲裁
8
13% / 88%
逾期
1
25%
空闲
相似订单
Virtual timeframe Algorithm that simulates a 30-second candle, based on ticks (ask and bid tick prices), called a virtual timeframe, that is, a time frame that exists only within the algorithm (internally) calculating the moving averages. This 30-second average do not need to appear on the chart. Strategy: 200 moving average trading signal: After the last trading price (if available) is equal (it will be necessary to

项目信息

预算
30 - 60 USD
开发人员
27 - 54 USD
截止日期
 10 天