[ARQUIVO]Qualquer pergunta de novato, para não desorganizar o fórum. Profissionais, não passem por ela. Não posso ir a lugar nenhum sem você - 5. - página 46

 

Se você conhece a função para calcular o saldo total de perda de posições FECHADAS por SL e o saldo total de operações lucrativas OPEN, escreva.

O cálculo do saldo de perdas deve começar a partir do último valor máximo de depósito

 

Boa tarde!!! Minha função é jurar com quarenta palavrões - obviamente eu não sabia muito, e também esqueci como inventar

void  SELL { double Price1_SELL= (Bid-Dist*Point) ; double TP1_SELL=Price1_SELL-TP*Point; double SL1_SELL=Price1_SELL+SL*Point;
   
   double  Price2_SELL= (Price1_SELL -Dist*Point) ;double   TP2_SELL=Price2_SELL-TP*Point;double   SL2_SELL=Price2_SELL+SL*Point;
   
   double  Price3_SELL=(Price2_SELL -Dist*Point) ; double  TP3_SELL=Price3_SELL-TP*Point; double  SL3_SELL=Price3_SELL+SL*Point;
   
   double  Price4_SELL= (Price3_SELL -Dist*Point) ; double  TP4_SELL=Price4_SELL-TP*Point; double  SL4_SELL=Price4_SELL+SL*Point;
   
   double  Price5_SELL= (Price4_SELL -Dist*Point) ;double   TP5_SELL=Price5_SELL-TP*Point; double  SL5_SELL=Price5_SELL+SL*Point;}
 
Dimka-novitsek:

Boa tarde!!! Minha função é jurar com quarenta palavrões - obviamente eu não sabia muito, e também esqueci como inventar


Diman! Boa noite! Você precisa descansar, não para uma função, mas para algumas besteiras que você escreveu...

 
Por isso eu disse que não me lembro. Vou terminá-lo. Encomendas. O que há de errado com o compilador?
 
Dimka-novitsek:
Estou lhe dizendo, não me lembro. Vou escrevê-lo. Encomendas. Do que o compilador não gosta?

Não é assim que os f-i's são escritos. Leia o livro didático.

 
Obrigado!!! Leitura.
 
А. Os grampos não eram suficientes para ela!
 

Olá, meu Conselheiro Especialista coloca paradas pendentes. Ao verificar no testador apenas SELL_STOP está funcionando, em vez de BUY_STOP uma ordem de erro Enviar erro/ Abertura de erro Ordem de compra:130 aparece.

extern int TrailingStop=30;
//-----------------------------------------------------------------------------------------------+
for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELLSTOP &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                  {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green);
                     return(0);
                    }
              }
           }
         else // go to short position
           {
            // check for trailing stop
            if(TrailingStop>0)  
              {                 
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                    {
                     OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
                     return(0);
                    }
              }
           }
        }
     }

   
   return(0);

Ajude-me a encontrar a razão!

 

A razão é uma falta de lógica!

for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()<=OP_SELLSTOP &&   // check for opened position 
         OrderSymbol()==Symbol())  // check for symbol
        {
         if(OrderType()==OP_BUY)   // long position is opened
           {
Como entender? Se CELLSTOP, o que o BAI tem a ver com isso?
 
Twilight:

Como posso saber se as últimas ordens 1-2-3 estavam perdendo?

E em geral, como posso saber qual foi a última encomenda?


Recentemente escrevi uma função que, no caso da última ordem perdida, devolve o tipo desta ordem. Em outras palavras, se fHistory() == 0, a última ordem perdida foi Buy, fHistory() == 1, a última ordem perdida foi Sell. Se quisermos rastrear as ordens lucrativas, então mude o sinal na linha assim: if(OrderProfit() > 0 ).

//+----------------------------------------------------------------------------+
// Прибыльно или убыточно закрылся последний ордер, и возврат типа такого ордера
int fHistory(){
  for(int i=OrdersHistoryTotal(); i >= 0; i--){              // Выборка в истории
     if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true){   // Если есть следующий в истории
        if(OrderMagicNumber()!=magN) continue;               // Ордера не нашего эксперта
        if(OrderProfit() < 0 ) return (OrderType());         // Если убыток по посл.ордеру вернем тип ордера
     }
  }
  return(-1);
}

A variável magN é a ordem mágica declarada globalmente.

Razão: