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 日