Entry problem

 

Hi, everyone.


I need to set my entries for when low[0] < low[1] sell, but I can´t do that, could you help me? when write:

 

//*****************************VOID ON TICK---------------------------------------------------------------------------------------------------------------------------------

  
void OnTick()
  {   
  //--- we work only at the time of the birth of new bar
  CopyRates(Symbol(),Period(),0,3,rates);
  double hhh = rates[1].high; // THIS IS MY PROBLEM
  double lll = rates[1].low;
  double cc = rates[0].close; 

  //-----------------
      if(!SymbolInfoTick(Symbol(),ultimoTick))
         {
            Alert("Erro ao obter informações de Preços: ", GetLastError());
            return;
         }
         
      if(CopyRates(_Symbol, _Period, 0, 3, rates)<0)
         {
            Alert("Erro ao obter as informações de MqlRates: ", GetLastError());
            return;
         }
         //-----------------------------------------------------
   static datetime PrevBars=0;
   datetime time_0=iTime(0);
   if(time_0==PrevBars)
      return;
   PrevBars=time_0;        
   int count_buys=0;
   int count_sells=0;
   CalculatePositions(count_buys,count_sells);
   //---------------------------------
      if(!GetIndValue())
      return;
      //----------------------------

   if(SellSignal() && cc<lll)
      if(count_sells>0)
         ClosePositions(POSITION_TYPE_SELL);

   if(BuySignal()&& cc>hhh)
      if(count_buys>0)
         ClosePositions(POSITION_TYPE_BUY);

   if(count_buys==0 && count_sells==0)
     {
      //--- check condition on BUY
      if(BuySignal() && cc>hhh)
        {
         if(!RefreshRates())
           {
            PrevBars=iTime(1);
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Ask()+ExtTakeProfit;
         m_trade.Buy(InpLots,m_symbol.Name(),m_symbol.Ask(),rates[1].low-5,m_symbol.NormalizePrice(tp));
        }
      //--- check condition on SELL
      else if(SellSignal() && cc<lll)
        {
         if(!RefreshRates())
           {
            PrevBars=iTime(1);
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
         m_trade.Sell(InpLots,m_symbol.Name(),m_symbol.Bid(),rates[1].high+5,m_symbol.NormalizePrice(tp));
        }
     }
   else
      Trailing();
 

If I delete this:

 double hhh = rates[1].high; // THIS IS MY PROBLEM
  double lll = rates[1].low;
  double cc = rates[0].clos

Works :

 if(SellSignal())
      if(count_sells>0)
         ClosePositions(POSITION_TYPE_SELL);

   if(BuySignal())
      if(count_buys>0)
         ClosePositions(POSITION_TYPE_BUY);

   if(count_buys==0 && count_sells==0)
     {
      //--- check condition on BUY
      if(BuySignal())
        {
         if(!RefreshRates())
           {
            PrevBars=iTime(1);
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Ask()+ExtTakeProfit;
         m_trade.Buy(InpLots,m_symbol.Name(),m_symbol.Ask(),rates[1].low-5,m_symbol.NormalizePrice(tp));
        }
      //--- check condition on SELL
      else if(SellSignal() )
        {
         if(!RefreshRates())
           {
            PrevBars=iTime(1);
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
         m_trade.Sell(InpLots,m_symbol.Name(),m_symbol.Bid(),rates[1].high+5,m_symbol.NormalizePrice(tp));
        }
     }
   else
 
Silverveins :

Hi, everyone.


I need to set my entries for when low[0] < low[1] sell, but I can´t do that, could you help me? when write:

 

  1. Your code won't compile - many compilation errors. It is impossible to verify your code.
  2. You are asking about 'low [0] <low [1]' and you don't see it anywhere in the code. Please clarify your question.
 
Vladimir Karputov:

  1. Seu código não compilará - muitos erros de compilação. É impossível verificar seu código.
  2. Você está perguntando sobre 'baixo [0] <baixo [1]' e não o vê em nenhum lugar do código. Por favor, esclareça sua pergunta.

In my first comment, I put this:

void  OnTick ()
  {   
  // --- trabalhamos apenas no momento do nascimento da nova barra 
  CopyRates ( Symbol (), Period (), 0 , 3 , rates);
  double hhh = taxas [ 1 ] .alta; // ESTE É O MEU PROBLEMA 
  double lll = rates [ 1 ] .low;
  cc duplo = taxas [ 0 ] .close;


if (SellSignal () && cc <lll) 

       if (count_sells> 0 )

         ClosePositions ( POSITION_TYPE_SELL );


   if (BuySignal () && cc> hhh)

       if (count_buys> 0 )

         ClosePositions ( POSITION_TYPE_BUY );


// ***************************** ANULAR NA MARCAÇÃO ---------------- -------------------------------------------------- -------------------------------------------------- -------------

  
void  OnTick ()
  {   
  // --- trabalhamos apenas no momento do nascimento da nova barra 
  CopyRates ( Symbol (), Period (), 0 , 3 , rates);
  double hhh = taxas [ 1 ] .alta; // ESTE É O MEU PROBLEMA 
  double lll = rates [ 1 ] .low;
  cc duplo = taxas [ 0 ] .close;

  // ----------------- 
      if (! SymbolInfoTick ( Symbol (), ultimoTick))
         {
            Alert ( "Erro ao obter informações de preços:" , GetLastError ());
            retorno ;
         }
         
      if ( CopyRates ( _Symbol , _Period , 0 , 3 , rates) < 0 )
         {
            Alert ( "Erro ao obter as informações de MqlRates:" , GetLastError ());
            retorno ;
         }
         // ------------------------------------------------ ----- 
   data e hora estática  PrevBars = 0 ;
   datetime time_0 = iTime ( 0 );
   if (time_0 == PrevBars)
       return ;
   PrevBars = time_0;        
   int count_buys = 0 ;
   int count_sells = 0 ;
   CalculatePositions (count_buys, count_sells);
   // --------------------------------- 
      if (! GetIndValue ())
       return ;
      // ----------------------------

   if (SellSignal () && cc <lll) 
       if (count_sells> 0 )
         ClosePositions ( POSITION_TYPE_SELL );

   if (BuySignal () && cc> hhh)
       if (count_buys> 0 )
         ClosePositions ( POSITION_TYPE_BUY );
 
Silverveins :


You did not take into account such a moment: you need to complete

CopyRates(Symbol(),Period(),0,3,rates);
ArraySetAsSeries(rates,true);
 
Vladimir Karputov:


Sorry I´m new, could you show me how can I do that?

 
Silverveins :

Sorry I´m new, could you show me how can I do that?

I can't help you: your code doesn't compile - there are a lot of errors during compilation.

My advice: describe what the advisor should do and maybe I can help you put together the advisor from the very beginning. IMPORTANT: ONLY ENGLISH TEXT (EVEN INSIDE MQL5 CODE) !!!