What is the problem with this?

 

I need to compare Bid prize with Moving Avarage. This is need to open a position. 1feltetelLong=1CriteriaLong.

This is an INT number, and it will be =0 when a position is opened.

 
extern double __STRATEGY_MAGIC=1572468051;

//Inputs
extern int _MAperi = 300;
extern double _7pip = 0.0007;

extern int _SL = 100;
extern int _TP = 100;
extern double _Lots=0.01;

//Declaration
double _Moving_Avarage;
double _Arithmetic;
bool _Compare;
double _Bid;
bool _Open_Long;
double _Arithmetic_2;
bool _Compare_2, _Compare_3;
bool _Open_Short;


int _num=0,_num2=0,z=0,y=0,_Van=0,_Van2=0;
double _Par_SAR,_MA;
int _1feltetelLong=0,_1feltetelShort=0;
bool _2feltetelLong=false,_2feltetelShort=false;

int start(){


   //Level 1
  
 _Par_SAR = iSAR(Symbol(),0,0.02,0.2,0);
 _Moving_Avarage = iMA(Symbol(),0,_MAperi,0,1,0,0);
  
  _Bid = Bid;
   _MA= _Moving_Avarage;
   
  //Level 2
  
   _Arithmetic = _Moving_Avarage + _7pip;
   
   _Arithmetic_2 = _Moving_Avarage - _7pip;

   
   //Level 3
  
    _Compare = _Bid > _Arithmetic;
   
    _Compare_2 = _Bid < _Arithmetic_2;

    //_Compare_3 = (MarketInfo(Symbol(),MODE_BID)==_MA); 
    //Level 4
       RefreshRates();
       if (MarketInfo(Symbol(),MODE_BID)==_MA)
     {
     _1feltetelLong++;
     _1feltetelShort++;
     }
     
     
     /*if (_Compare==true)
     {
     _2feltetelLong=true;
     }
     if (_Compare_2==true)
     {
     _2feltetelShort=true;
     }*/
     
     
     if(_1feltetelLong >0 && _Compare && !__isExist(0) && _Par_SAR<_Bid && (_Bid<_Moving_Avarage+0.002))// && _num==0)
     {
     _Open_Long = OrderSend(Symbol(),0,_Lots,MarketInfo(Symbol(),MODE_ASK),0,MarketInfo(Symbol(),MODE_ASK)-MarketInfo(Symbol(),MODE_POINT)*_SL,MarketInfo(Symbol(),MODE_ASK)+MarketInfo(Symbol(),MODE_POINT)*_TP,"",__STRATEGY_MAGIC + 0)>=0;
   
     _num++;
     _Van=1;
     _1feltetelLong=0;
     }
     if(_1feltetelShort >0 && _Compare_2 && !__isExist(0) && _Par_SAR>_Bid && (_Bid>_Moving_Avarage-0.002))// && _num2==0)
     {
     _Open_Short = OrderSend(Symbol(),1,_Lots,MarketInfo(Symbol(),MODE_BID),0,MarketInfo(Symbol(),MODE_BID)+MarketInfo(Symbol(),MODE_POINT)*_SL,MarketInfo(Symbol(),MODE_BID)-MarketInfo(Symbol(),MODE_POINT)*_TP,"",__STRATEGY_MAGIC + 0)>=0;
   
     _num2++;
     _Van2=1;
     _1feltetelShort=0;
     }
   
     
     for (y=0;y<OrdersHistoryTotal();y++)
         {
            //if (OrderCloseTime() != 0 ){  
            OrderSelect(__Ticket(0),SELECT_BY_POS,MODE_HISTORY==true);
            if (OrderSymbol() == Symbol() && __STRATEGY_MAGIC == OrderMagicNumber())
            {
            _num=0;
            _num2=0;
            _Van=0;
            _Van2=0;
            }
          }  
     
if (_num>0 && _Par_SAR<_Bid)
      {
      OrderSelect(__Ticket(0),SELECT_BY_TICKET);
      OrderModify(__Ticket(0),0,_Par_SAR,OrderTakeProfit(),0);
     }
     
 if (_num2>0 && _Par_SAR>_Bid)
      {
      OrderSelect(__Ticket(0),SELECT_BY_TICKET);
      OrderModify(__Ticket(0),0,_Par_SAR,OrderTakeProfit(),0);
      }    
     
     for (z=0;z<OrdersHistoryTotal();z++)
         {
            OrderSelect(__Ticket(0),SELECT_BY_POS,MODE_HISTORY);
            if (OrderSymbol() == Symbol() && __STRATEGY_MAGIC == OrderMagicNumber())
            {
            _num=0;
            _num2=0;
            
            }
     }
     return(0);
     }
//Services
bool __selectOrderByMagic(int __magic){for(int __i=0;__i<OrdersTotal();__i++){if(OrderSelect(__i,SELECT_BY_POS,MODE_TRADES)&&OrderMagicNumber()==__STRATEGY_MAGIC+__magic)return(true);}return(false);}
bool __isExist(int __magic){return(__selectOrderByMagic(__magic));}
int __Ticket(int __magic){if(!__selectOrderByMagic(__magic))return(0);return(OrderTicket());}

So,

RefreshRates();
if (MarketInfo(Symbol(),MODE_BID)==_MA)
{
_1feltetelLong++;
_1feltetelShort++;

}

I need to compare Bid prize with Moving Avarage. This is need to open a position. 1feltetelLong=1CriteriaLong.

This is an INT number, and it will be =0 when a position is opened.

 
if (MarketInfo(Symbol(),MODE_BID)==_MA)
The == operand. - MQL4 forum
 
for (loop all the orders to find if a position is already open)

if (MarketInfo(Symbol(),MODE_BID)==_MA && position isn't open)
   {
   _1feltetelLong++;
   _1feltetelShort++;
   }
 


Thank you for your help!

I do everything and you made my day! I'm happy, thank you so much!

 
if (NormalizeDouble(Bid,4)==NormalizeDouble(_Moving_Avarage,4))
     {
     _1feltetelLong++;
     _1feltetelShort++;
     }
I tried it, but not opened a position. What is the problem? Please help! Thank you!
Reason: