Bots open multiple orders

 
Hello i guys i have this cross function that check if price cross high bollinger bands:

bool hiCrossTL()
  {
  
      double TestMin_1 = iOpen(_Symbol, PERIOD_CURRENT, 1);
      double TestMin_0 = iOpen_Symbol, PERIOD_CURRENT, 0);

      

      if(TestMin_1 < TLBuffer[1] && TestMin_0 > TLBuffer[0]) 
      return true;
      
      return false;
  }

on the same candle the bot opens tons of multiple order when the function return true
if (hiCrossTL() ) 
   {
                    fSell();
         }     

i want it open a single order everytime the price cross the band but i tried everything the bot keep opening for every tick      


<a href="https://ibb.co/NL7Dn2k"><img src="https://i.ibb.co/THrjqMn/Immagine.png" alt="Immagine" border="0"></a>

Immagine hosted at ImgBB
Immagine hosted at ImgBB
  • ibb.co
Immagine Immagine ospitata in ImgBB
 
Giovanni “okayflame”:
  • You must share code using the 'Code' button or Alt+S.

 
Miguel Angel Vico Alba #:
  • You must share code using the 'Code' button or Alt+S.

Ok i edited Can you solve my problem also ?
 
Giovanni “okayflame” #Ok i edited Can you solve my problem also ?

Here I am sure they can help you: https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2023.04.01
  • www.mql5.com
The largest freelance service with MQL5 application developers
 

1) You have to count your open orders. And only open orders for example if you count = 0.

2) If you want to open multiple orders you could place them only on new bar.

 
  1. Your code
          if(TestMin_1 < TLBuffer[1] && TestMin_0 > TLBuffer[0]) 
          return true;
          
          return false;
    Simplified
          return TestMin_1 < TLBuffer[1] && TestMin_0 > TLBuffer[0];
  2. Amira J Brand #: 2) If you want to open multiple orders you could place them only on new bar.

    Or Act on a change of signal.
              Too many orders - MQL4 programming forum #1 (2017)

Reason: