Hedge + reinicio no dia seguinte

 
Por favor, peço humildemente a comunidade, como realçar o HEDGE e automatizar o reinicio no dia seguinte apos bater a meta estabelecida, tudo ja escrito mas nao acontece ao virar do novo dia,,, nao da erro retorno, nafa de errado, mas nao acontece....peço ajuda. Segue trechos:
void OnTick()
  {
   if (TimeDay(TimeCurrent()) != LastTradingDay) {
        // É um novo dia de negociação, redefina a variável stopTrading para permitir a negociação
        stopTrading = false;
        LastTradingDay = TimeDay(TimeCurrent());
    }
   double BuyPrice = BuyPric();
   double SellPrice = SellPric();
//+------------------------------------------------------------------+
   Lot = NormalizeDouble(AccountBalance() / 100 * Percentual_Risco_de_seu_Capital / (MarketInfo(Symbol(), MODE_TICKVALUE) * 100 * D), 2);
   if(Lot < MarketInfo(Symbol(), MODE_MINLOT))
      Lot = MarketInfo(Symbol(), MODE_MINLOT);
//+------------------------------------------------------------------+
   for(int i = ObjectsTotal() - 1; i >= 0; i--)
     {
      PricBuyLine = ObjectGetDouble(0, "LineBuy", OBJPROP_PRICE);
      PricSellLine = ObjectGetDouble(0, "LineSell", OBJPROP_PRICE);
     }
   if(Ask + Distancia_pontos_Entrada * D * Point < PricBuyLine)
     {HLineMove("LineBuy", Ask + Distancia_pontos_Entrada * D * Point);}
   if(Bid - Distancia_pontos_Entrada * D * Point > PricSellLine)
     {HLineMove("LineSell", Bid - Distancia_pontos_Entrada * D * Point);}
   if(Ask < PricSellLine && Bid - Distancia_pontos_Entrada * D * Point > PricBuyLine)
     {HLineMove("LineBuy", Ask + Distancia_pontos_Entrada * D * Point);}
   if(Bid > PricBuyLine && Ask + Distancia_pontos_Entrada * D * Point < PricSellLine)
     {HLineMove("LineSell", Bid - Distancia_pontos_Entrada * D * Point);}
   if(TimeHour(TimeCurrent()) >= Ligar_Hr_MT4 && TimeHour(TimeCurrent()) < Desligar_Hr_MT4)
   if (!stopTrading && TimeHour(TimeCurrent()) >= Ligar_Hr_MT4 && TimeHour(TimeCurrent()) < Desligar_Hr_MT4) {
      if(Open[0] > Close[0] && Ask <= PricSellLine && LastType() != OP_SELL && Count(-1) == 0)
        {
         r = OrderSend(Symbol(), OP_SELL, Lot, Bid, 10, 0, 0, comment, Numero_MAgico, 0, clrRed);
         HLineMove("LineBuy", Ask + Distancia_pontos_Entrada * D * Point);
        }
      if(Open[0] < Close[0] && Bid >= PricBuyLine && LastType() != OP_BUY && Count(-1) == 0)
        {
         r = OrderSend(Symbol(), OP_BUY, Lot, Ask, 10, 0, 0, comment, Numero_MAgico, 0, clrGreen);
         HLineMove("LineSell", Bid - Distancia_pontos_Entrada * D * Point);
        }
     }
   NewLot = Lot * (MathPow(Multiplicador_Lote, Count(-1)));
   if(Open[0] > Close[0] && Ask <= PricSellLine && Count(OP_SELL) > 0 && Bid - Step * D * Point > SellPric())
     {
      r = OrderSend(Symbol(), OP_SELL, NewLot, Bid, 10, 0, 0, comment, Numero_MAgico, 0, clrRed);
      HLineMove("LineBuy", Ask + Distancia_pontos_Entrada * D * Point);
     }
   if(Open[0] < Close[0] && Bid >= PricBuyLine && Count(OP_BUY) > 0 && Ask + Step * D * Point < BuyPric())
     {
      r = OrderSend(Symbol(), OP_BUY, NewLot, Ask, 10, 0, 0, comment, Numero_MAgico, 0, clrGreen);
      HLineMove("LineSell", Bid - Distancia_pontos_Entrada * D * Point);
     }
//---
   NewProfProc = Profit(-1) / (AccountBalance() / 100);
// Calcula a porcentagem de lucro em relação ao saldo inicial
   double currentProfitPercent = (AccountBalance() - InitialBalance) / InitialBalance * 100.0;

    if (currentProfitPercent >= Seu_Lucro_do_Dia && !stopTrading) {
        Comment("Meta de lucro atingida. Negociação suspensa até amanhã.");
        stopTrading = true;  // Desabilitar as operações
        LastTradingDay = TimeDay(TimeCurrent());
    }
    if (TimeDay(TimeCurrent()) != LastTradingDay) {
        // É um novo dia de negociação, redefina a variável stopTrading para permitir a negociação
        stopTrading = false;
        LastTradingDay = TimeDay(TimeCurrent());
    }
// Verificação do percentual de lucro por entrada
   if(tradingEnabled && NewProfProc >= Percentual_seu_Saldo_Lucro_Por_Entrada)
     {
      CloseMinus(-1);
      ClosePlus(-1);
     }
   if(tradingEnabled)
     {
      for(int i = 0; i < OrdersTotal(); i++)
        {
         if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
           {
            double orderProfit = OrderProfit();
            double orderOpenPrice = OrderOpenPrice();
            double currentPrice = MarketInfo(OrderSymbol(), MODE_BID);
            // Verifica se a ordem está em lucro
            //if (orderProfit > 0)
              {
               //double profitThreshold = Percentual_seu_Saldo_Lucro_Por_Entrada * 1; // 60% do lucro desejado
               // Verifica se o lucro atingiu 60% do lucro desejado
               //if (orderProfit >= profitThreshold)
                 {
                  //double priceReversalThreshold = orderOpenPrice * 0.01;// 1% de reversão
                  // Verifica se houve uma reversão de 60%
                  // if (currentPrice <= orderOpenPrice - priceReversalThreshold)
                    {
                     // Feche a ordem
                     // Feche a ordem
                     //bool closeResult = OrderClose(OrderTicket(), OrderLots(), currentPrice, clrNONE);
                     //if (closeResult)
                       {
                        Print("Ordem fechada com sucesso!");
                       }
                     //else
                       {
                        // Print("Erro ao fechar a ordem: ", GetLastError());
                       }
                    }
                 }
              }
           }
        }
     }
   string profitText;
   if(currentProfitPercent >= 0)
     {
      profitText = "Neste momento você está " + DoubleToStr(currentProfitPercent, 2) + "% de lucro";
     }
   else
     {
      profitText = "Neste momento você está -" + DoubleToStr(MathAbs(currentProfitPercent), 2) + "% de prejuízo";
     }
   ObjectSetText(ProfitLabel, profitText, 12, "Arial", Lime);
   ObjectSetInteger(0, ProfitLabel, OBJPROP_CORNER, 0);
   ObjectSetInteger(0, ProfitLabel, OBJPROP_XDISTANCE, 990);
   ObjectSetInteger(0, ProfitLabel, OBJPROP_YDISTANCE, 570);
//+------------------------------------------------------------------+
   if(NewProfProc >= Percentual_seu_Saldo_Lucro_Por_Entrada)
     { {CloseMinus(-1); ClosePlus(-1);}}
//+------------------------------------------------------------------+
   if(Info)
 
Paulo Iço: Por favor, peço humildemente a comunidade, como realçar o HEDGE e automatizar o reinicio no dia seguinte apos bater a meta estabelecida, tudo ja escrito mas nao acontece ao virar do novo dia,,, nao da erro retorno, nafa de errado, mas nao acontece....peço ajuda. Segue trechos:

Esse codigo foi voce que fez? Poderia nos mostrar as dependencias dele? Como que vamos "adivinhar" o que umas funções fazem? Provavelmente seu erro esta na TimeDay(), seja la o que ela estiver fazendo...

EDIT: Segundo ponto pra que criar uma stopTrading e uma tradingEnabled? Faça so com uma variavel essa checagem.