Questions from Beginners MQL5 MT5 MetaTrader 5 - page 777

 
Aleksey Vyazmikin:

Can you write a kernel for OpenCL? I know of only one person here who claims to use OpenCL to optimise on the fly - while the EA is running. I am not aware of any other examples.

I would like to take a look at them myself. Even asked to release an article on the subject, but the administration does not know how to apply it to real trading.

It's amazing, opencl has been supported for already 5 years, but there are no specific working examples for trading and no articles... Well, since the developers themselves do not know how to apply it, then let's focus on cloud optimization
 
ax237b:
it's just amazing, support for opencl has been around for 5 years and no concrete working examples for trades or articles... well if the developers themselves don't know how to apply it, then let's focus on cloud optimisation
What is so surprising? The terminal works with sufficient speed, the delay in the broker's response. So opencl is resting for now. What happens next - we'll see
 

Please help!

I am remaking the indicator, here is the code for drawing

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot Label1
#property  indicator_label1  "High";
#property  indicator_type1   DRAW_LINE;
#property  indicator_color1  clrRed;
#property  indicator_style1  STYLE_DOT;
#property  indicator_width1  1;
//--- plot Label2
#property  indicator_label2  "Low";
#property  indicator_type2   DRAW_LINE;
#property  indicator_color2  clrRed;
#property  indicator_style2  STYLE_DOT;
#property  indicator_width2  1;
//--- plot Label3
#property  indicator_label3  "Close";
#property  indicator_type3   DRAW_LINE;
#property  indicator_color3  clrAquamarine;
#property  indicator_style3  STYLE_SOLID;
#property  indicator_width3  1;


//--- input parameters
input int InpChannelPeriod=48; // Period
//--- indicator buffers
double ExtHighBuffer[];
double ExtLowBuffer[];
double ExtCloseBuffer[];
//---
int i,limit,start;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtHighBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtLowBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtCloseBuffer,INDICATOR_DATA);   
//--- set accuracy
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- set first bar from what index will be drawn
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,InpChannelPeriod);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,InpChannelPeriod);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,InpChannelPeriod);   
//---
   return(0);
  }

//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- check for rates if(rates_total<InpChannelPeriod) return(0); //--- preliminary calculations if(prev_calculated==0) limit=InpChannelPeriod; else limit=prev_calculated; //--- the main loop of calculations for(i=limit;i<rates_total && !IsStopped();i++) { ExtHighBuffer[i]=100.0; ExtLowBuffer[i]=0.0; ExtCloseBuffer[i]=50.0; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+

Style#propertyindicator_style2STYLE_DOT; - does not draw on the chart at all

Style#propertyindicator_style2STYLE_SOLID; - draws on the chart inSTYLE_DOT

What is this anomaly, or my hands are wrong?

 

What is the best way to calculate the moving average from the graphical array - here or in the indicator?

Are there any ready-made functions or libraries recommended by developers?

 
Aleksey Vyazmikin:

What is the best way to calculate the moving average from the graphical array - here or in the indicator?

Maybe there are some ready-made functions or libraries recommended by developers?


Or even a simple variant - to draw MA in the basement from iMA - I get nothing :(

I'm calling via function

double MA_TF(int index)
  {
   double MA[1];
   ResetLastError();
   if(CopyBuffer(handle_MA_TF,0,index,1,MA)<0)
     {
      PrintFormat("Failed to copy data from the handle_MA_TF indicator, error code %d",GetLastError());
      return(0.0);
     }
   return NormalizeDouble(MA[0],Digits());
  }

But, it's not right - inside out...

 

With the wizard made a call inside out to MA_TF(rates_total-i) - seems to have helped, but I look at the history and sometimes there is a discrepancy with the built-in indicator (even with normalisation removed), can this be the case?

And, how to make the indicator output decimal values?

 
Aleksey Vyazmikin:

What is the best way to calculate the moving average from the graphical array - here or in the indicator?

Are there any ready-made functions or libraries recommended by developers?

There's MovingAverages.mqh in the Include folder...
 
Alexey Viktorov:
There's MovingAverages.mqh in the Include folder...

Thanks, I didn't know, but can I see an example of where to work with it?

 
Aleksey Vyazmikin:

Thanks, I didn't know, but can I see an example of where to work with it?

Alexey, is the search not working anymore?

There is a file search on the top right. You adjust the search area by clicking on the gear.


And here's the result.


 
Alexey Viktorov:

Alexei, is the search no longer working?

There is a file search on the top right. You adjust the search area by clicking on the gear.


and here's the result.



Indeed, why not search your own - thanks!

Reason: