Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 428

 
Artyom Trishkin:
I'm not offended by stubbornness. Why?
And variables need to be initialised explicitly. You'll get to the importance of initialization someday. In the meantime, you can throw out everything inside the curly brackets.

Appreciate the humour. Thank you.

 
input int ExtDepth=12;//
input int ExtDeviation=5;//
input int ExtBackstep=3;//

input int Deviation=10;

//---------------------------------
int zz_handle;
struct zz_info{
   double P_;
   datetime T_;
};
double zz_value[];
datetime zz_time[];
zz_info zz_highs[2];
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   zz_handle=iCustom(_Symbol,PERIOD_CURRENT,"Examples\\ZigZag",ExtDepth,ExtDeviation,ExtBackstep);
   

   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

   int count=0; 
   int i=1;
   
   CopyBuffer(zz_handle,0,1,1,zz_value);
   if(zz_value[0]!=0)
      {
      while(count<2)
         {
            CopyBuffer(zz_handle,0,i,1,zz_value);
            CopyTime(_Symbol,PERIOD_CURRENT,i,1,zz_time);
            i++;
            if(zz_value[0]!=0)
               {
                  zz_highs[count].P_=zz_value[0];
                  zz_highs[count].T_=zz_time[0];
                  count++;
               }
                           
         }
      DrawFibofan(zz_highs);
      }
      double high[];
      double low[];
      datetime Time[];
      CopyHigh(_Symbol,PERIOD_CURRENT,1,1,high);
      CopyLow(_Symbol,PERIOD_CURRENT,1,1,low);
      CopyTime(_Symbol,PERIOD_CURRENT,1,1,Time);
      double fibo_p=ObjectGetValueByTime(0,"DisFibo",Time[0],0);
      Comment(fibo_p);
   
  }
//+------------------------------------------------------------------+
void DrawFibofan(zz_info &zz[])
{
   if(zz[0].P_-zz[1].P_>0) 
      {
         ObjectDelete(0,"AscFibo");
         ObjectCreate(0,"AscFibo",OBJ_FIBOFAN,0,zz[1].T_,zz[1].P_,zz[0].T_,zz[0].P_);
         ObjectSetInteger(0,"AscFibo",OBJPROP_LEVELS,1);
         ObjectSetDouble(0,"AscFibo",OBJPROP_LEVELVALUE,0.882);
         ObjectSetInteger(0,"AscFibo",OBJPROP_LEVELCOLOR,clrNavy);
         ObjectSetInteger(0,"AscFibo",OBJPROP_WIDTH,2);
         ObjectSetString(0,"AscFibo",OBJPROP_LEVELTEXT,"88.2");
      }

      else
      {
         ObjectDelete(0,"DisFibo");
         ObjectCreate(0,"DisFibo",OBJ_FIBOFAN,0,zz[1].T_,zz[1].P_,zz[0].T_,zz[0].P_);
         ObjectSetInteger(0,"DisFibo",OBJPROP_LEVELS,1);
         ObjectSetDouble(0,"DisFibo",OBJPROP_LEVELVALUE,0.882);
         ObjectSetInteger(0,"DisFibo",OBJPROP_LEVELCOLOR,clrNavy);
         ObjectSetInteger(0,"DisFibo",OBJPROP_WIDTH,2);
         ObjectSetString(0,"DisFibo",OBJPROP_LEVELTEXT,"88.2");
      }
}

Can you tell me what's wrong, I don't understand how to get the value of the Fibo fan line on the previous candle?

Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • www.mql5.com
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. Обсудим совместные проекты в редакторе - зачем они и...
 
Roman Sharanov:

Can you tell me what's wrong, I don't understand how to get the value of the Fibo fan line on the previous candle?

Something is piled up here, both mql4 and mql5...

What language should I use to get the value?

 
nicholishen:

Comparison of numbers with a floating point for equality

bool ( fabs (number1-number2) < _Point / 10 * 5 )
bool flag = ( fabs (number1-number2) < _Point / 10 * 5 )
 
If you delete an account in the terminal, I understand that only the display of the account in the terminal is deleted. the account itself on the broker's server is not deleted.
 
igrok333:
If you delete an account in the terminal, I understand that only the display of the account in the terminal is deleted. the account itself on the broker's server is not deleted.

Yes, you got that right.

 
STARIJ:
It's very simple. You need to set 7 parameters to calculate the iMA. The first parameter, the name of the symbol, is obvious. As the second, timeframe, set M1. The third parameter - the period - set as many times greater than you need, how many days is greater than one minute. The fourth parameter - shift = 0. The next two parameters - the method of averaging and price type - you know. The last one is the bar number. Please calculate the bar number if you know the time you need. That's all! Double-check it by making calculations for M5 and M15 timeframes. Maybe even for M30.

Alekseu Fedotov:

It's as simple as that.

It's like this.


I'll try it tomorrow and report back. Thank you)

 

Can you tell me how to catch and lock the reversal moment of the Parabolic SAR indicator? At least just an idea how to do it. Thanks in advance!

 
Corvin85:

Can you tell me how to catch and lock the reversal moment of the Parabolic SAR indicator? At least just an idea how to do it. I have no idea how to use it.


you can check the current and previous bar.

For example, the previous one was higher than the price, the current one is lower than the price.

 

Hello, dear forum members. Can you advise what needs to be done to ensure that the t1 ticket is not redrawn when a position is opened under the same conditions. So that when a condition to close these (but not other) positions occurs, both (or possibly more)

if(ЗДЕСЬ УСЛОВИЕ ОТКРЫТИЯ ПОЗИЦИИ БАЙ)
      {
      t1=OrderSend(Symbol(),OP_BUY,lot,Ask,slippage,0,0,"",0,0,Green);
      if(t1>0)
           {
            if(OrderSelect(t1,SELECT_BY_TICKET,MODE_TRADES))
              { Print("Открыта позиция BUY20");
               buy20=true;
              }
           }
         else
            Print("Error opening BUY20 order : ",GetLastError());
      return;
      }


ticket. So far only the last ticket is read and the closing loop ignores the first one. The loop seems to be built correctly:

void ClosePoz()
  { RefreshRates();
         double WPR0 = iWPR(NULL,PERIOD_M5,bars,0);
         bool rez1 = false;
         bool rez2 = false;
  int total=OrdersTotal();
      for(int i=OrdersTotal()-1;i>=0;i--)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         {
         if(OrderTicket()==t1 && buy20 && MathAbs(WPR0)>81)
         rez1 =  OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),int(MarketInfo(OrderSymbol(),MODE_DIGITS))),slippage,clrNONE); 
        
         if(OrderTicket()==t2 && buy80 && MathAbs(WPR0)<20)
         rez2 =  OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(MarketInfo(OrderSymbol(),MODE_BID),int(MarketInfo(OrderSymbol(),MODE_DIGITS))),slippage,clrNONE);                 
         }
       continue;  
      }      
     
  } 
Reason: