Mudança do cálculo de ordens de Grid

 
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());

               }

            }

      }

   }

 
Mateus Roman:
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());

               }

            }

      }

   }

Se não sabe programar, tem pessoas capazes na area de freelancer (https://www.mql5.com/pt/job).
Aplicativos de negociação para o MetaTrader 5 por encomenda
Aplicativos de negociação para o MetaTrader 5 por encomenda
  • 2023.03.25
  • www.mql5.com
O maior serviço freelance com desenvolvedores de aplicativos MQL5