Coding help please, can anyone make this MT5 indicator based on fractal collect data from other time frame?

 

Hi all,


I using a very helpful MT5 indicator which I found it free in this website, I use it in my daily trading, but I see it will be great if I can choose which time frame should the indicator collect data from, for example I attach it to daily chart but I want the indicator showing results based on the monthly chart, Can anyone help me please?


Best Regards

 
Tarik Aljanabi: Can anyone help me please?
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help
          urgent help.

Or pay someone. Top of every page is the link Freelance.

 
William Roeder:
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
          No free help
          urgent help.

Or pay someone. Top of every page is the link Freelance.

Thanks William Roeder,


I thought it's easy for someone here to make this indicator take data from other time frame, for example add an option to the indicator " use time frame H1,4H...etc , this is the help I need.


Best Regards

 

Try line 64 FRA_Handle=iFractals(NULL,0); The 0 means current time frame. If you push F1 the help menu launches, then type iFractals, by period you can click on Enum_timeframes, find the time frame you want and copy it, then place it where the zero is   


FRA_Handle=iFractals(NULL,PERIOD_MN1)

I have not checked to see if this works or if anything else needs to be changed
 
Brian Rumbles:

Try line 64 FRA_Handle=iFractals(NULL,0); The 0 means current time frame. If you push F1 the help menu launches, then type iFractals, by period you can click on Enum_timeframes, find the time frame you want and copy it, then place it where the zero is   


FRA_Handle=iFractals(NULL,PERIOD_MN1)

I have not checked to see if this works or if anything else needs to be changed

Many Thanks,


I did it but the indicator now work only on the MN1 chart and not showing anything on other time frames.


Best Regards

 

I found these links helpful, I could not get the code to use the other time frame data

For mql4

https://www.mql5.com/en/forum/173574/page348#comment_4542105               Looked at code in remjie's post  r3_mtf_matrv2.mq4 

line 103  ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);


This function not available in mql5

https://www.mql5.com/en/forum/188388



Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the rates_array array. The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar. If you know the amount of data you need to copy, it should better be done to a statically allocated...
 

So have to somehow use this code for mql5

https://www.mql5.com/en/docs/series/copyrates


void OnStart() 
  { 
//--- 
   MqlRates rates[]; 
   ArraySetAsSeries(rates,true); 
   int copied=CopyRates(Symbol(),0,0,100,rates); 
   if(copied>0) 
     { 
      Print("Bars copied: "+copied); 
      string format="open = %G, high = %G, low = %G, close = %G, volume = %d"; 
      string out; 
      int size=fmin(copied,10); 
      for(int i=0;i<size;i++) 
        { 
         out=i+":"+TimeToString(rates[i].time); 
         out=out+" "+StringFormat(format, 
                                  rates[i].open, 
                                  rates[i].high, 
                                  rates[i].low, 
                                  rates[i].close, 
                                  rates[i].tick_volume); 
         Print(out); 
        } 
     } 
   else Print("Failed to get history data for the symbol ",Symbol()); 
  }



I don't know how to get it to work, need advice from someone more skilled than me

Documentation on MQL5: Timeseries and Indicators Access / CopyRates
Documentation on MQL5: Timeseries and Indicators Access / CopyRates
  • www.mql5.com
Gets history data of MqlRates structure of a specified symbol-period in specified quantity into the rates_array array. The elements ordering of the copied data is from present to the past, i.e., starting position of 0 means the current bar. If you know the amount of data you need to copy, it should better be done to a statically allocated...
 

Working with Multi-Timeframes is not so simple. You need to have 'at least' the historical data for such timeframe.

Technical details are long, but to be short, and for you to be able to test it, first open the symbol chart, then manually change it to M1, then to H1, then MN1, so Metatrader can download data to build the intermediary timeframes.

After it, test your code.

Otherwise you may see empty charts or graphics [or empty copy arrays] and will spend hours trying to figure out that was not your code error, but just missing bars. ;)

Metatrader by default only download chart data when you open such timeframe on the main chart. So to have an indicator showing another timeframe, it has to be opened at least once on that timeframe.

 
If you don't have any history, here's how you can get all available from your broker.