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.
#property indicator_label1 "LINE"#property indicator_type1 DRAW_LINE#property indicator_color1 clrGold#property indicator_style1 STYLE_SOLID#property indicator_width1 2inputint period = 10; //Период усреденияinputbool USE_LIMIT= false; //вкл/выкл лимитирование//Заключается в ограничении максимального изменения значения индикатораinputdouble use_limit= 0.00005; //Величина//на которую максимально может измениться индикаторdouble Buffer[];
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+intOnInit()
{
SetIndexBuffer(0,Buffer,INDICATOR_DATA);
//PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0);return(0);
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constint begin,
constdouble &price[])
{
//--- вычисления значений индикатора//--- calculate the indicator valuesint start=0;
//--- если расчет уже производился на предыдущем запуске OnCalculate//--- if the calculation is made on a previous run of OnCalculateif(prev_calculated>0) start=prev_calculated-1; // установим начало расчетов с предпослденего бара -- Set the start of the penultimate bar calculations//--- заполняем индикаторный буфер значениями//--- fill indicator buffer valuesfor(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 functionreturn(rates_total);
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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.
Thank you for your attention.
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)
If it doesn't work on a demo account, let me know.
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
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.
What's wrong with the code?
Graphics are fine, in the tester the error Array Out Of Range comes up
Buffer[i+1] === +1 не делается проверка на выход за массив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-1Seems to work