I could not get your version to work...so I decided to continue with the original... Basically I get the data in the inputed TF, copy it to the buffer.. and then collect only over the most recent TF candle.
I followed the tutorial on MTF but I could not get this to work... I think I have an error on the last loop... can an expert given me a hand? I am stuck with this... thanks...
#property indicator_chart_window#property indicator_buffers4#property indicator_plots2//--- the FractalUp plot#property indicator_label1"FractalUp"#property indicator_type1DRAW_ARROW#property indicator_color1clrBlue//--- the FractalDown plot#property indicator_label2"FractalDown"#property indicator_type2DRAW_ARROW#property indicator_color2clrRedinputENUM_TIMEFRAMES period=PERIOD_M30;
int handle;
int bars_calculated=0;
double FractalUpBuffer[];
double FractalDownBuffer[];
int Multiplier;
intOnInit() {
Multiplier= PeriodSeconds(period)/PeriodSeconds(Period());
SetIndexBuffer(0,FractalUpBuffer,INDICATOR_DATA);
SetIndexBuffer(1,FractalDownBuffer,INDICATOR_DATA);
PlotIndexSetInteger(0,PLOT_ARROW,217); // arrow upPlotIndexSetInteger(1,PLOT_ARROW,218); // arrow downArraySetAsSeries(FractalUpBuffer,true);
ArraySetAsSeries(FractalDownBuffer,true);
handle=iFractals(_Symbol,period);
return(INIT_SUCCEEDED);
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[]) {
int values_to_copy;
//--- determine the number of values calculated in the indicatorint calculated=BarsCalculated(handle);
if(calculated<=0) {GetLastError();return(0); }
if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1) {
if(calculated>rates_total) values_to_copy=rates_total;
else values_to_copy=calculated;
} else {
values_to_copy=(rates_total-prev_calculated)+1;
}
values_to_copy=values_to_copy*Multiplier ;
if(values_to_copy<=0) {GetLastError();return(0); }
double UpBuffer[];
double DownBuffer[];
ArraySetAsSeries(UpBuffer,true);
ArraySetAsSeries(DownBuffer,true);
if(!CopyBuffer(handle, 0,0 , values_to_copy, UpBuffer)) return(0);
if(!CopyBuffer(handle, 1,0 , values_to_copy, DownBuffer)) return(0);
for(int i=0; i<values_to_copy && !IsStopped(); i++)
{
if(i-values_to_copy-1 <0 ) continue; //by pass first part of array...aovoid error due to out of range array.double Up=UpBuffer[i];
double Down=DownBuffer[i];
if( Up == EMPTY_VALUE)
{
FractalUpBuffer[i]=FractalUpBuffer[i-1];
} else{
FractalUpBuffer[i]=Up;
}
if( Down == EMPTY_VALUE)
{
FractalDownBuffer[i]=FractalDownBuffer[i-1];
} else{
FractalDownBuffer[i]=Down;
}
}
return(rates_total);
}
voidOnDeinit(constint reason) {
if(handle!=INVALID_HANDLE)
IndicatorRelease(handle);
//--- clear the chart after deleting the indicatorComment("");
}
WE encountered a problem with the code above regarding some 4806 error... so in the meantime I figure out an alternative version that seems to work... want it to share it...in case needed in the future...
The Fractals indicator is classically 4 bars after the fact because the Fractal is centered on the 3rd bar and identified on the 5th bar. But this is the best use I've seen of it as it's forming support and resistance through the last known fractals. The price will likely break above or below the markers giving you a zone to potentially place stop orders. I tested this code and I find it looks better with DRAW_LINE drawing style. Easy to change from arrows to lines.
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.
I could not get your version to work...so I decided to continue with the original... Basically I get the data in the inputed TF, copy it to the buffer.. and then collect only over the most recent TF candle.
I followed the tutorial on MTF but I could not get this to work... I think I have an error on the last loop... can an expert given me a hand? I am stuck with this... thanks...
I decided to hire a freelancer to make this code MTF...here it is for those interested... credit to the developer..
WE encountered a problem with the code above regarding some 4806 error... so in the meantime I figure out an alternative version that seems to work... want it to share it...in case needed in the future...
ok, this is the last version...seems to work well...credit to the freelancer...
ok, this is the last version...seems to work well...credit to the freelancer...
Dear Camilo,
Thanks for your kindness..... Your indicator helps me....