Why This iFractal didn't work

 

hi guy,

why this code didn't work :


#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red

input ENUM_TIMEFRAMES TimeFrame1 = PERIOD_M5; // Timeframe 1
input ENUM_TIMEFRAMES TimeFrame2 = PERIOD_M15; // Timeframe 2
input ENUM_TIMEFRAMES TimeFrame3 = PERIOD_H1; // Timeframe 3

double UpFractalBuffer[];
double DownFractalBuffer[];

void 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 &TickVolume[],
                 const long &Volume[],
                 const int &Spread[])
  {
   int limit = rates_total - prev_calculated;
   
   ArraySetAsSeries(UpFractalBuffer, true);
   ArraySetAsSeries(DownFractalBuffer, true);
   
   for(int i = 0; i < limit; i++)
     {
      // Calculate fractals for the current timeframe
      if (iFractals(NULL, TimeFrame1, i) > 0)
        UpFractalBuffer[i] = iFractals(NULL, TimeFrame1, i);
      if (iFractals(NULL, TimeFrame1, i) < 0)
        DownFractalBuffer[i] = iFractals(NULL, TimeFrame1, i);
      
      // Calculate fractals for the higher timeframes
      if (iFractals(NULL, TimeFrame2, i) > 0)
        UpFractalBuffer[i] = iFractals(NULL, TimeFrame2, i);
      if (iFractals(NULL, TimeFrame2, i) < 0)
        DownFractalBuffer[i] = iFractals(NULL, TimeFrame2, i);
      
      if (iFractals(NULL, TimeFrame3, i) > 0)
        UpFractalBuffer[i] = iFractals(NULL, TimeFrame3, i);
      if (iFractals(NULL, TimeFrame3, i) < 0)
        DownFractalBuffer[i] = iFractals(NULL, TimeFrame3, i);
     }
     return(rates_total);
  }
 

We don't know what you mean by "didn't work"! We cannot guess what is on your mind.

You will have to explain in detail and with some screenshots.

 
Fernando Carreiro #:

We don't know what you mean by "didn't work"! We cannot guess what is on your mind.

You will have to explain in detail and with some screenshots.

So please delete the topic sir.

Thanks

 

Is this MQL4 or MQL5 code?

In MQL5, the iFractals function returns a handle, not buffer data. In MQL5 you have to use CopyBuffer to get the buffer values.

Documentation on MQL5: Technical Indicators / iFractals
Documentation on MQL5: Technical Indicators / iFractals
  • www.mql5.com
iFractals - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
p4rnak #: So please delete the topic sir.
Why? Are you not asking for assistance?
 
Fernando Carreiro #:
Why? Are you not asking for assistance?

yes sir, but I think it's too hard to code. :-)

 
Fernando Carreiro #:

Is this MQL4 or MQL5 code?

In MQL5, the iFractals function returns a handle, not buffer data. In MQL5 you have to use CopyBuffer to get the buffer values.

But with copy buffer, Can We Use That For Multi timeframe?

If We Can, Show Me An Example Please.


I Just Need To Get High[] And Low[] Array From a Specific Time Frame.

And Then I Can Use Them For My Calculations.

 
p4rnak #: But with copy buffer, Can We Use That For Multi timeframe? If We Can, Show Me An Example Please.

Yes, you can do multi-symbol, and multi-timeframe. I gave you two links. Did you follow them and read the documentation, where they give you an example?

Please learn to read the documentations and experiment with example code given there.

 
Fernando Carreiro #:

Yes, you can do multi-symbol, and multi-timeframe. I gave you two links. Did you follow them and read the documentation, where they give you an example?

Please learn to read the documentations and experiment with example code given there.

I do, But there is some example for Moving Averages; They didnt use high and low.

Thanks

 
p4rnak #: I do, But there is some example for Moving Averages; They didnt use high and low.

Please pay attention to what is posted. I provided a link for the iFractals function, which includes an example for Fractals.

Did you read it? Did you experiment with the example code?

There are also examples in the CodeBase. Please do some research on their use.

Documentation on MQL5: Technical Indicators / iFractals
Documentation on MQL5: Technical Indicators / iFractals
  • www.mql5.com
iFractals - Technical Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Fernando Carreiro #:

Please pay attention to what is posted. I provided a link for the iFractals function, which includes an example for Fractals.

Did you read it? Did you experiment with the example code?

There are also examples in the CodeBase. Please do some research on their use.

I Do Before Sir, When I Use That Code In My MT5; it did not show any arrow in another TF. 

Fore Example When I choose M5 it's not work in M1.

Thanks

Reason: