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

 
Alekseu Fedotov:

It's as simple as that.

void OnStart()
  {
// Формируем время  
   Alert("14.30  позавчерашнего дня = ",StrToTime(TimeToStr(iTime(NULL,1440,2),TIME_DATE)+" "+"14:30"));

//14.30  позавчерашнего дня
   datetime time=StrToTime(TimeToStr(iTime(NULL,1440,2),TIME_DATE)+" "+"14:30");

//Бар 14.30  позавчерашнего дня
   int     shift=iBarShift(NULL,0,time);

//Машка 14.30  позавчерашнего дня  
   double ma=iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,shift);

   Alert("Машка 14.30  позавчерашнего дня = ",DoubleToString(ma,Digits));

It's like this.


Alekseu Fedotov, Unfortunately, this is not it. You get the bar number with TF and then you use the same TF, but you need another one (this is the problem). We need to get the bar number with TF (for example 30) and then get the MA with TF (1440), starting from this bar with TF 30. It's like if you now (14.30) would like to get MA with TF 1440. Now - not a problem, but to transfer it to a couple of days ago, that is a problem.

 
STARIJ:
Yes. We should use M1, and M5, .... - to check. Maybe use interpolation? mt5 has a tick history. If you let me know where the profit is, I will take another look.

I need to do the technical analysis retrospectively as if it were happening now and look at the result. That is as if I did technical analysis of MA with TF 1d at 14.30 yesterday and today I got the results of price movement by yesterday's MA. If I use TF 1440 today and look from yesterday's point of view, the data of technical analysis will be different, and therefore the results should be expected to be different.

 
Roman Sharanov:

Help, I need to draw a rectangle from the previous candle's high to a point 200p above it and time a bar ahead.

I wrote the code, but I don't understand why the left point of the rectangle doesn't move? The right one slides behind the hai.

Unexpected behaviour of the function... Earlier, when I tried to create an object named after an already existing one, an error was returned and the object did not change existing parameters into new ones. But now, apparently, changes were made and every time high[0] is changed or a new bar appears, high[1] already has a different value and one of the parameters changes when creating a new rectangle.

The way out is very simple: Check existence of the object before creating it.

 
STARIJ:

It moves



No, I'm not drawing anything with this code

 
Roman Sharanov: No, it doesn't draw anything with this code.

Look at my whole file.

Files:
PR.mq4  3 kb
 
STARIJ:

Have a look at my file


Oh I see, you have MQL4 :)
Made arrays by timeseries and it worked, I still don't understand why it didn't work for me

 
Boss11: I need to do the technical analysis retrospectively as if it were happening now and look at the result. That is, as if I did a technical analysis of MA with TF 1d at 14.30 yesterday and today I got the results of price movement by yesterday's MA. If I use TF 1440 today and look from yesterday's point of view, the data of technical analysis will be different, and therefore the results should be expected to be different.

With TF 1440 everything is clear. but with M1 as you wrote there is a big margin of error?

 
STARIJ:

With TF 1440 everything is clear. but with M1 as you wrote big error?


I haven't tried it with M1, but I think the margin of error will be less. M1->M5 will be more accurate than M30-> 1d

 

Please advise on the answer to a specific question. I'm redoing the Bollinger.

Changed a couple of lines, doesn't draw bars. What is it, logarithms?

Volatility formula from https://research-journal.org/economical/analiz-razlichnyx-metodov-ocenki-istoricheskoj-volatilnosti-dlya-opcionnoj-torgovli/

int start()
  {
   int    i,k,counted_bars=IndicatorCounted();
   double deviation;
   double sum,oldval,newres,oldpos;
//----
   if(Bars<=BandsPeriod) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=BandsPeriod;i++)
        {
         MovingBuffer[Bars-i]=EMPTY_VALUE;
         UpperBuffer[Bars-i]=EMPTY_VALUE;
         LowerBuffer[Bars-i]=EMPTY_VALUE;
        }
//----
   int limit=Bars-counted_bars;
   if(counted_bars>0) limit++;
   for(i=0; i<limit; i++)
      MovingBuffer[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_EMA,PRICE_WEIGHTED,i);
//----
   i=Bars-BandsPeriod+1;
   if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      sum=0.0;
      k=i+BandsPeriod-1;
      oldval=MovingBuffer[i];
      oldpos=i;
      while(k>=i)
        {
         //newres=Close[k]-oldval;
         //sum+=newres*newres;
          sum+=log(fabs(High[k]/Close[k]))*log(fabs(High[k]/Open[k]))+log(fabs(Low[k]/Close[k]))*log(fabs(Low[k]/Open[k]));
         k--;
        }
      deviation=BandsDeviations*MathSqrt(fabs(sum/BandsPeriod));
      UpperBuffer[i]=oldval+deviation;
      LowerBuffer[i]=oldval-deviation;
      i--;
     }
Files:
 

Please tell me how to delete a graphical object. There are vertical lines whose names are constructed from variable values.

string name=="test1"; string Vertline="line_"+name; ObjectCreate(0,VertLine,OBJ_VLINE,0,time,cena); How can I delete only vertical lines with the name test1?

Reason: