lots multiplier problems

 
//Lots Multiplier-------------------------------

int OrdHistory=OrdersHistoryTotal();
int ProfCount=0, LosCount=0;   

{for(int x=Bistory;x>=1;x--)
{
if(OrderSelect(OrdHistory-x,SELECT_BY_POS,MODE_HISTORY) && OrderStopLoss()>=0)LosCount++;
if(OrderSelect(OrdHistory-x,SELECT_BY_POS,MODE_HISTORY) && OrderStopLoss() <0)ProfCount++;
}}

//Sell-------------------------------------------------------------------------------------------

if(ProfCount > 1)
   {
   for(int x=Bistory;x>=1;x--)
   
    if(OrderMagicNumber()==InpMagicShort)
    {
     OrderClose(ticket_SS2 , LotsMultiplier, OrderOpenPrice(), 0, clrNONE);
    }  
 int ticket_SS1 =   OrderSend( Symbol(), OP_SELLSTOP, Lots, rangeHigh, 0, rangeLow, OrderTakeProfit(), InpTradeComment, InpMagicShort ); 
   }

if(LosCount > 1) 
  {
   for(int x=Bistory;x>=1;x--)
   
    if(OrderMagicNumber()==InpMagicShort)
    {
     OrderClose( ticket_SS1 , Lots, OrderOpenPrice(), 0, clrNONE);
    } 
 int ticket_SS2 =  OrderSend( Symbol(), OP_SELLSTOP, LotsMultiplier, rangeHigh, 0, rangeLow, OrderTakeProfit(), InpTradeComment, InpMagicShort );  
  }
  
//Buy---------------------------------------------------------------------------------------------

if(ProfCount > 1)
   {
   for(int x=Bistory;x>=1;x--)
   
    if (OrderMagicNumber()==InpMagicLong)
    {
      OrderClose(ticket_BS2 , LotsMultiplier, OrderOpenPrice(), 0, clrNONE);
    }  
   int ticket_BS1 = OrderSend( Symbol(), OP_BUYSTOP, Lots, rangeLow, 0, rangeHigh, OrderTakeProfit(), InpTradeComment, InpMagicLong ); 
   }
if(LosCount > 1) 
  {
   for(int x=Bistory;x>=1;x--)
   
    if(OrderMagicNumber()==InpMagicLong)
    {
     OrderClose(ticket_BS1 , Lots, OrderOpenPrice(), 0, clrNONE);
    } 
 int ticket_BS2 = OrderSend( Symbol(), OP_BUYSTOP, LotsMultiplier, rangeLow, 0, rangeHigh, OrderTakeProfit(), InpTradeComment, InpMagicLong );  
  }    
}

//void--------------------------------------------------------------

void OpenTradeLong( ENUM_ORDER_TYPE type, double price, double sl ) {

   double tp = price + ( price - sl );
   price     = NormalizeDouble( price, Digits );
   sl        = NormalizeDouble( sl, Digits );
   tp        = NormalizeDouble( tp, Digits );

   int ticket_BS1 = OrderSend( Symbol(), type, Lots, price, 0, sl, tp, InpTradeComment, InpMagicLong );

   if ( !ticket_BS1 ) {
      Print( "Open failed for %s, %s, price=%f, sl=%f, tp=%f", Symbol(), EnumToString( type ), price, sl, tp );
   }
}

void OpenTradeShort( ENUM_ORDER_TYPE type, double price, double sl ) {

   double tp = price + ( price - sl );
   price     = NormalizeDouble( price, Digits );
   sl        = NormalizeDouble( sl, Digits );
   tp        = NormalizeDouble( tp, Digits );

   int ticket_SS1 = OrderSend( Symbol(), type, Lots, price, 0, sl, tp, InpTradeComment, InpMagicShort );

   if ( !ticket_SS1 ) {
      Print( "Open failed for %s, %s, price=%f, sl=%f, tp=%f", Symbol(), EnumToString( type ), price, sl, tp );
   }
}

hi , i am trying to make a lot multiplier for my ea, im in mql4 since just a couple of weeks, i dont know if this is the best way to do it anyway it keeps giving me a problem that is "ticket_BS1 undeclared identifier" and it goes on with every ticket i have there are 4 on the code im sharing with you how can i fix it?

 
Devi considerare che le variabili dichiarate all'interno di una funzione sono visibili solo alla funzione. Perché queste siano utilizzabili in qualsiasi punto del codice devi renderle globali dichiarandole all'inizio. 
Motivazione: