Questions from Beginners MQL5 MT5 MetaTrader 5 - page 744

 
Marat Sultanov:
There is a section of code in there that I didn't understand. You need to correct it yourself.


Can you show me what exactly....

 
Rafael Sahibgareev:


Can you show me what exactly....


Download the code -Marat Sultano wrote there what is unclear.
 

Marat, thanks for your help with the code ......

Another question, please show me how to correctly arrange a loop for the following code section ......

//--- цикл расчета 
      
        {
        
         //--- если предыдущая свеча имеет параметры больше MSC
         if(IsLossCandle)
            if(ASSHighBuf[i-1]>=max_size_candel)
               BufferLossCanle[i]=low[i-1];
                 {
                  if(IsTopShadow)
                     if((ASSOpenBuf[i-1]==ASSCloseBuf[i-1]) && IMaDifBuff[i]-IMaDifBuff[i-1]>0 || (ASSLowBuf[i-1]==0 && IMaDifBuff[i]-IMaDifBuff[i-1]>0))
                        BufferTop[i]=low[i-1];
                  if(IsLowerShadow)
                     if((ASSOpenBuf[i-1]==ASSCloseBuf[i-1]) && IMaDifBuff[i]-IMaDifBuff[i-1]<0 || (ASSLowBuf[i-1]==0 && IMaDifBuff[i]-IMaDifBuff[i-1]<0))
                        BufferLower[i]=high[i-1];
                 }
        }


//--- return value of prev_calculated for next call 
   return(rates_total);
  }
 
Rafael Sahibgareev:

Marat, thanks for your help with the code ......

Another question, please show me how to correctly arrange a loop for the following code fragment ......

It goes like this:

//--- цикл расчета
   const int Limit = fmax(prev_calculated, 1);

   for(int i=Limit; i<rates_total; ++i)
   {
      //--- если предыдущая свеча имеет параметры больше MSC
      if(IsLossCandle)
      {
         if(ASSHighBuf[i-1]>=max_size_candel) BufferLossCanle[i]=low[i-1];

         if(IsTopShadow)
         {
            if((ASSOpenBuf[i-1]==ASSCloseBuf[i-1] && IMaDifBuff[i]-IMaDifBuff[i-1]>0) || (ASSLowBuf[i-1]==0 && IMaDifBuff[i]-IMaDifBuff[i-1]>0))
            {
               BufferTop[i]=low[i-1];
            }
         }

         if(IsLowerShadow)
         {
            if((ASSOpenBuf[i-1]==ASSCloseBuf[i-1] && IMaDifBuff[i]-IMaDifBuff[i-1]<0) || (ASSLowBuf[i-1]==0 && IMaDifBuff[i]-IMaDifBuff[i-1]<0))
            {
               BufferLower[i]=high[i-1];
            }
         }
      }
   }

//--- return value of prev_calculated for next call 
   return(rates_total);
}

I'm just confused by a part of your code:

if(ASSHighBuf[i-1]>=max_size_candel)
   BufferLossCanle[i]=low[i-1];
     {

Why should the curly bracket stand there? Was there an intention that you didn't implement? (I'm alluding to the conditionalelse operator)

 

Marat, thank you once again, I wrote my last code at school 22 years ago.

I was sitting at the expense of else operator, where to put it as a breaker of next four operators.....

I think I can handle it myself ........

Marat, please advise or point me to the link if the calculation can be done without using the "loop" .....

 
Rafael Sahibgareev:

Marat, thank you once again, I wrote my last code at school 22 years ago.

I was sitting at the expense of else operator, where to put it as a breaker of next four operators.....

I think I can handle it myself ........

Marat, please advise or point me to the link if this calculation can be done without using a "loop" .....

Excuse me, may I ask your purpose, what result do you want to get from the discussed piece of code? Once I understand your intent, it will be much easier for me to help you :)
 

About the cycle asked out of curiosity...... Is this possible......

It itself is without tricky, the first operator "if" if works forbidden then, do not work direction classification operators .......

Further, in the future, I plan to change the code, to make it tick with work on a zero bar,

so that this same ban classifier appears on the tick when the spread goes beyond....indicator without additional clustering filters scalper....

In fact, I understand it that all patterns live in ticks......

 

You need a cycle to go through the bars. If you need readings for the last 1 or 2 bars only, you can do without the loop, but if you need to analyze a dozen or more bars, you'd better use the loop, right?

If you refuse to use loops you will doom yourself to Chinese code :)

 

Raphael, I recommend that you read in this order:

  1. Conditional if-else statement
  2. Operator for
  3. While loop operator
  4. Continue operator continue
  5. continue operator break

And if you get sucked in, then go deeper:

  1. Operators
  2. Language basics
I have divided them by frequency of use in practice. Nothing complicated, just enough to get the gist of it.


 

Thanks for the advice and recommendations, today is too late, tomorrow I will again read the help and articles....

I was only interested in the last three bars including option[0].....

Later I will probably need more 15-20 ...... I cannot do without cycles .....

Thanks again sincerely for your help and support.....