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

 
Good evening .
 if(count==0)comment+="No symbols for trading!";
      Comment(comment);
      MqlTick tick;
      tick.ask=SymbolInfoDouble(structPairs.name,SYMBOL_ASK);
      tick.bid=SymbolInfoDouble(structPairs.name,SYMBOL_BID);
      tick.time=TimeCurrent();
      Trade(false,structPairs, tick, Orders, inputs);
What does this piece of code say? When does it appear? All pairs in the list are there and all history is loaded .
 
Darirunu:
Good evening .What does this piece of code say? When does it appear? All pairs are in the list and all history is loaded .

Investor password?

 
Darirunu:
Good evening. What does this piece of code say? When does it appear? All pairs in the list are there and all history is loaded .
If some counter is 0 (I'm guessing it's the result of a previous run), then a line is added to the comment
No symbols for trading!

the rest is business as usual...

 
Taras Slobodyanik:

Thank you

Checking that there is no object on the second bar

         for(int jj=i;jj<obj_total;jj++)
           {
            nameARs=ObjectName(jj);
            if(ObjectType(nameARs)!=OBJ_RECTANGLE) continue;
            if(StringFind(nameARs,"QUADRO",0)!=-1)
              {

               time_ars=ObjectGetInteger(0,nameARs,OBJPROP_TIME);//break;

              }
           }
         //===---===
         if(time_ars!=Time[i+2])
           {
           //....
           }
How do I check that there are no objects on the ten bars?
 

Indicator.

For each bar, calculate the sum of bullish bar sizes and the sum of bearish bar sizes

In the buffer write the difference of these sums.

What is wrong here?

int counted_bars=IndicatorCounted(),
       limit;
 
   if(counted_bars>0)
      counted_bars--;
   
   limit=Bars-counted_bars;
   
   double up_sum=0, down_sum=0;
   for(int i=0;i<limit;i++)
   {
      for(int f = 0; f < Period; f++){
         if(close[f] - open[f] > 0) up_sum += close[f] - open[f];
         if(close[f] - open[f] < 0) down_sum += MathAbs(close[f] - open[f]);
      }
      PVTBuffer[i]=up_sum-down_sum;
   }
 
Roman Sharanov:

Indicator.

For each bar, calculate the sum of bullish bar sizes and the sum of bearish bar sizes

In the buffer write the difference of these sums.

What is wrong here?

Transfer

double up_sum=0, down_sum=0;

inside the first cycle - before announcing the second cycle.

 
Roman Sharanov:

Indicator.

For each bar, calculate the sum of bullish bar sizes and the sum of bearish bar sizes

In the buffer write the difference of these sums.

What is wrong here?

Try to reset the variablesup_sum=0, down_sum=0;

before the second, internal loop.

int counted_bars=IndicatorCounted(),
       limit;
 
   if(counted_bars>0)
      counted_bars--;
   
   limit=Bars-counted_bars;
   
   double up_sum, down_sum;
   for(int i=0;i<limit;i++)
   {
    up_sum=0; 
    down_sum=0;
      for(int f = 0; f < Period; f++){
         if(close[f] - open[f] > 0) up_sum += close[f] - open[f];
         if(close[f] - open[f] < 0) down_sum += MathAbs(close[f] - open[f]);
      }
      PVTBuffer[i]=up_sum-down_sum;
   }

Like this

 
Alekseu Fedotov:

Try resettingup_sum=0, down_sum=0;

before the second, internal loop.

Like this

did so, and yes, it makes sense, but now it's no longer displayed at all

 
Ghabo:

Thank you

Checking that there is no object on the second bar

How do I check that there are no objects on the ten bars?

If you know how to create the exact name of an object, then there is no point in going through all the objects on the chart.
It is enough to go through these (assumed) names.

for(int i=0;i<10;i++)
   {
   if (ObjectFind(0,"QUADRO"+Time[i])<0)
      Print("Нет объекта на баре № ",IntegerToString(i));
   else
      Print("Найден oбъект на баре № ",IntegerToString(i));
   }
 
Roman Sharanov:

I did, and yes, it makes sense, but now it's no longer displayed at all

Yes, also like this, fix it.

In the inner loop

for(int f = 0+i; f < Period+i; f++)

Reason: