Alguém poderia me ajudar a mudar o cálculo do grid para que somado a pontuação negativa das duas ordens do conjunto, abrir as ordens de grid?
//+------------------------------------------------------------------+
//| Grid |
//+------------------------------------------------------------------+
double preco_prin = 0, preco_cor = 0;
for(int i = 0; i < OrdersTotal(); i ++) {
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderMagicNumber() != conjunto.magic)continue;
if(OrderSymbol() != conjunto.symbol_a)continue;
preco_prin = OrderOpenPrice();
}
for(int i = 0; i < OrdersTotal(); i ++) {
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderMagicNumber() != conjunto.magic)continue;
if(OrderSymbol() != conjunto.symbol_b)continue;
preco_cor = OrderOpenPrice();
}
if(atg == YES && ativa_trade == YES) {
if(total_operacoes <= mog) {
double ask_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_ASK);
double bid_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_BID);
double bid_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_BID);
double ask_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_ASK);
double point_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_POINT);
double point_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_POINT);
if(buy >= 1)
if((ask_prin + dg * point_prin < preco_prin) || (bid_cor - dg * point_cor > preco_cor )) {
retorno = OrderSend(conjunto.symbol_b, OP_SELL, lote_operacoes, bid_cor, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrRed);
retorno = OrderSend(conjunto.symbol_a, OP_BUY, lote_operacoes, ask_prin, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrBlue);
if(retorno < 0)
Print("Falha ao abrir grid, erro ", GetLastError());
}
if(sell >= 1 )
if((bid_prin - dg * point_prin > preco_prin) || (ask_cor + dg * point_cor < preco_cor)) {
retorno = OrderSend(conjunto.symbol_a, OP_SELL, lote_operacoes, bid_prin, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrRed);
retorno = OrderSend(conjunto.symbol_b, OP_BUY, lote_operacoes, ask_cor, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrBlue);
if(retorno < 0) {
Print("Falha ao abrir grid, erro ", GetLastError());
}
}
}
}

- 2023.03.25
- www.mql5.com

- Aplicativos de negociação gratuitos
- 8 000+ sinais para cópia
- Notícias econômicas para análise dos mercados financeiros
Você concorda com a política do site e com os termos de uso
//+------------------------------------------------------------------+
//| Grid |
//+------------------------------------------------------------------+
double preco_prin = 0, preco_cor = 0;
for(int i = 0; i < OrdersTotal(); i ++) {
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderMagicNumber() != conjunto.magic)continue;
if(OrderSymbol() != conjunto.symbol_a)continue;
preco_prin = OrderOpenPrice();
}
for(int i = 0; i < OrdersTotal(); i ++) {
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
if(OrderMagicNumber() != conjunto.magic)continue;
if(OrderSymbol() != conjunto.symbol_b)continue;
preco_cor = OrderOpenPrice();
}
if(atg == YES && ativa_trade == YES) {
if(total_operacoes <= mog) {
double ask_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_ASK);
double bid_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_BID);
double bid_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_BID);
double ask_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_ASK);
double point_prin = SymbolInfoDouble(conjunto.symbol_a, SYMBOL_POINT);
double point_cor = SymbolInfoDouble(conjunto.symbol_b, SYMBOL_POINT);
if(buy >= 1)
if((ask_prin + dg * point_prin < preco_prin) || (bid_cor - dg * point_cor > preco_cor )) {
retorno = OrderSend(conjunto.symbol_b, OP_SELL, lote_operacoes, bid_cor, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrRed);
retorno = OrderSend(conjunto.symbol_a, OP_BUY, lote_operacoes, ask_prin, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrBlue);
if(retorno < 0)
Print("Falha ao abrir grid, erro ", GetLastError());
}
if(sell >= 1 )
if((bid_prin - dg * point_prin > preco_prin) || (ask_cor + dg * point_cor < preco_cor)) {
retorno = OrderSend(conjunto.symbol_a, OP_SELL, lote_operacoes, bid_prin, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrRed);
retorno = OrderSend(conjunto.symbol_b, OP_BUY, lote_operacoes, ask_cor, 50, 0, 0, "Grid " + IntegerToString(conjunto.magic), conjunto.magic, 0, clrBlue);
if(retorno < 0) {
Print("Falha ao abrir grid, erro ", GetLastError());
}
}
}
}