Why can be this happening?

 

This happens:



when I have this:


   if(array_st[0]<rates[0].open && array_st[1]<rates[1].open  && array_rsi[0]<=1) //&& IsNewOrderAllowed()==true)
     {
      valueB=array_atr[0];
      Print("Open Order Buy");
      Alert("Buying");
      Orden="Buy";
      sl2=NormalizeDouble(tick.ask - 10*valueB,_Digits);
      tp2=NormalizeDouble(tick.bid + valueB,_Digits);
      trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,get_lot(tick.bid),tick.bid,sl2,tp2,"Buy");
      return;
     }
   if(array_st[0]>rates[0].open && array_st[1]>rates[1].open  && array_rsi[0]>=99) //&& IsNewOrderAllowed()==true)
     {
      valueS=array_atr[0];
      Print("Open Order Sell");
      Alert("Selling");
      Orden="Sell";
      sl2=NormalizeDouble(tick.bid + 10*valueS,_Digits);
      tp2=NormalizeDouble(tick.ask - valueS,_Digits);
      trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,get_lot_s(tick.ask),tick.ask,sl2,tp2,"Sell");
      return;
     }


what is rates doing, and why is selling opening?

array_st is the array of the custom indicator.

 
  1. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

  2. Always post all relevant code (using Code button) or attach the source file. We have no idea what your arrays types are, their indexing direction, how you filled them, nor your indicator, and your call.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

 
William Roeder #:
  1. Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
              Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
              Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010)

  2. Always post all relevant code (using Code button) or attach the source file. We have no idea what your arrays types are, their indexing direction, how you filled them, nor your indicator, and your call.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

   MqlRates rates[];
   double last=0;
   ArraySetAsSeries(rates,true);
   int start_pos_r=0,count_r=3;
   CopyRates(m_symbol.Name(),my_timeframe,start_pos_r,count_r,rates);
double array_st[];
   ArraySetAsSeries(array_st,true);
   int start_pos_st=0,count_st=3;
   if(!iGetArrayST(handle_iST,0,start_pos_st,count_st,array_st))
      return;
handle_iST=iCustom(_Symbol,PERIOD_CURRENT,"supertrend_");
//+------------------------------------------------------------------+
bool iGetArrayST(const int handleST,const int bufferST,const int start_posST,
               const int countST,double &arr_bufferST[])
  {
   bool resultST=true;
   if(!ArrayIsDynamic(arr_bufferST))
     {
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
      return(false);
     }
   ArrayFree(arr_bufferST);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copiedST=CopyBuffer(handleST,bufferST,start_posST,countST,arr_bufferST);
   if(copiedST!=countST)
     {
      //--- if the copying fails, tell the error code
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
                  __FILE__,__FUNCTION__,countST,copiedST,GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(resultST);
  }
no errors ... 
Files: