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

 
Maxim Kuznetsov:

see oanda api - if I am not mistaken in the picture it is PositionBook

thank you!

 
Artyom Trishkin:

So you have to disable the autoscrolling graph. And remember that it's an asynchronous command.

Disabled....

 
Сергей Таболин:

Deactivated....

Then you need to look in your own code.

 

I am trying to take MA indicator data from the older period in MT5.

//OnInit
 if((slowMovingHandleHigherTF=iMA(_Symbol, HighMovingsTF, SlowMovingPeriod_HigherTF, 0, MA_Method, MA_Apply_To))==INVALID_HANDLE) {
      PrintFormat("Slow moving (HigherTF) handle troubles");
      return (INIT_FAILED);
   }
//OnCalculate
 if(!FillArrayFromBuffer(slowMovingHandleHigherTF,SlowValuesHigherTF,0,40)) Print("Beda");

But I get error 4806 (Requested data not found). When I take it from the current timeframe, everything is OK. It takes data. But I have problems with the higher one. Please advise how to fix it

 
Artyom Trishkin:

Then you need to look in your own code.

Can you tell me where I'm wrong?

void OnStart()
{
   ArraySetAsSeries(rates,true);
   ChartSetInteger(ChartID(),CHART_AUTOSCROLL,false);
   

   for(int i = 0; i < in_range; i++)
   {

   // Тут рассчитываю X
      if(X)       {          ChartNavigate(ChartID(),CHART_END,-i);          if(MessageBox(ask,"ASK",MB_OKCANCEL) == IDOK)          {             ObjectCreate(ChartID(),"SigDN_"+IntegerToString(i),OBJ_VLINE,0,rates[i].time,rates[i].open);             //return;             ObjectSetInteger(ChartID(),"SigDN_"+IntegerToString(i),OBJPROP_COLOR,clrRed);             ObjectSetInteger(ChartID(),"SigDN_"+IntegerToString(i),OBJPROP_SELECTABLE,true);             ObjectSetInteger(ChartID(),"SigDN_"+IntegerToString(i),OBJPROP_SELECTED,false);             ObjectSetInteger(ChartID(),"SigDN_"+IntegerToString(i),OBJPROP_STYLE,STYLE_DOT);             Print("SigDN_",i);          }       }    } }

I ran the script on H2 at the beginning of the hour.

As I wrote before, it works fine, and then, from some point, the chart is positioned at the end andMessageBox appears. Why respond to a request, if I can't see the found figure?

 

2361
Starting from period H1, a variable or function outputs strange values.

Print(_Period);
Print(Period());
H1
16385
16385
H4
16388
16388

etc.

 
Roman:

2361
Starting from period H1, a variable or function outputs strange values.

etc.

What is their "strangeness"?

 
Artyom Trishkin:

What is their "strangeness"?

Variable _Period and Period() up to and including M30, outputs the value in minutes.
If the period is M1 then 1
If period M2 then 2
...
If period M30 then 30

It is logical that hourly period will be 60
two hour period 120
three hour 180
etc.

But from H1 onwards the wrong values are displayed.

 
Roman:

The _Period variable and Period() function, up to and including M30, outputs the value in minutes.
If period M1 then 1
If period M2 then 2
...
If the period of M30 then 30

It is logical that hourly period will be 60
two hour period 120
three hour 180
etc.

But from H1 onwards the wrong values are displayed.

EnumToString(Period())

 
Сергей Таболин:

EnumToString(Period())

The help says that the timeframe value should be returned, not the identifier converted withEnumToString()
The _Period variable returns int.
ENUM_TIMEFRAMES Period() also implies that int is returned.

Reason: