Questions from a "dummy" - page 234

 
forward666: Yes, I need a visualisation

For testing: https://www.metatrader5.com/ru/terminal/help/algotrading/visualization

No help found yet for live trading - just try opening and closing a position in a demo account.

 
Boris.45: Good afternoon, esteemed traders! Please help a newbie programmer. I have written a program block using fractals for several timeframes to search for moving channels (SK) of Borispolz and started writing algorithms for position opening. I have faced a situation when the timeframe of fast moving trends is only one or two bars. This situation suggests the following: you need to work on selected timeframes in the search and calculation of SK parameters, while the decision to place orders or open positions should be made on very small timeframes. Please advise how to arrange the program in such a way that the block for calculating the SK parameters works only on the selected timeframes, e.g. H1 and H4, and the block for making decisions about placing orders works on M1 timeframe. I have not found solutions for that in the articles.

Thank you for your attention.

I am quite far from fractals, but here are some general considerations. We can try in the simplest way: create an indicator that calculates "SK parameters" on H4. Then let our Expert Advisor check this indicator at every tick and make decisions about placing orders.
 
Yedelkin:

For testing: https://www.metatrader5.com/ru/terminal/help/algotrading/visualization

For live trading I haven't found any help yet - just try opening and closing a position in a demo account.

Thank you! I will try it!

But I just need it for visualisation on a demo account)

 
forward666: But I just need it for visualisation on a demo account)
If it doesn't work on a demo account, write to me.
 
Yedelkin:
If it doesn't work on a demo account, let me know.
Ok! I will try it tonight and report back!
 
forward666:

But I just need it for visualisation on a demo account)


From the history, you can pull the mouse to the chart (with the shifter - everything).

!!! With a controller will reset the chart settings.
 

What's wrong with the code?

Graphics are fine, in the tester the error Array Out Of Range comes up

#property indicator_label1  "LINE"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrGold
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

input int    period   = 10;       //Период усредения
input bool   USE_LIMIT= false;    //вкл/выкл лимитирование
                                  //Заключается в ограничении максимального изменения значения индикатора
input double use_limit= 0.00005;  //Величина
                                  //на которую максимально может измениться индикатор

double         Buffer[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
   
   SetIndexBuffer(0,Buffer,INDICATOR_DATA);
   //PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//--- вычисления значений индикатора
//--- calculate the indicator values
   int start=0;
//--- если расчет уже производился на предыдущем запуске OnCalculate
//--- if the calculation is made on a previous run of OnCalculate
   if(prev_calculated>0) start=prev_calculated-1; // установим начало расчетов с предпослденего бара -- Set the start of the penultimate bar calculations
//--- заполняем индикаторный буфер значениями
//--- fill indicator buffer values
   for(int i=start;i<rates_total;i++)
     {
      Buffer[0]=price[0];
      double delta=(price[i]-Buffer[i])/period;
      if(USE_LIMIT && delta>use_limit)
        {
         delta=use_limit;
        }
      if(USE_LIMIT && delta<-use_limit)
        {
         delta=-use_limit;
        }
      Buffer[i+1]=Buffer[i]+delta;
     }
//--- вернем значение prev_calculated для следующего вызова функции
//--- return the value for the next call of prev_calculated function
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
lazarev-d-m:

What's wrong with the code?

Graphics are fine, in the tester the error Array Out Of Range comes up


Loop goes until i<rates_total.Then there is Buffer[ i+1] .

Buffer[rates_total] .There is no such thing.The last index is rates_total-1.

 
lazarev-d-m:

What's wrong with the code?

Graphics are fine, in the tester the error Array Out Of Range comes up


Buffer[i+1] === +1 не делается проверка на выход за массив
 
Karlson:


The loop goes until i<rates_total.Then there is Buffer[ i+1] .

Buffer[rates_total] .There is no such thing.The last index is rates_total-1.

Changed to this

i<rates_total-1
Seems to work
Reason: