Examples\Fractals usage in EA

 

I am trying to make my EA based on the Fractals sample form the Indicator-->Examples folder. Here is the code that I tried:  

#include<Trade\Trade.mqh>

CTrade trade;

void OnTick()
  {
int test = iCustom(_Symbol,_Period,"Examples\\Fractals");
MqlRates rates_price[];

 if(rates_price.high == buff[0])
  {
  trade.Sell(0.1);
  }
   if(rates_price.low == buff[0])
   
   {
   trade.Buy(0.1);
   
   }
  }

I don't know why I can not able to trade with the signals that are produced by this code and the indicator. Any Idea and help? I am using MQL5

 
jafferwilson:

I am trying to make my EA based on the Fractals sample form the Indicator-->Examples folder. Here is the code that I tried:  

I don't know why I can not able to trade with the signals that are produced by this code and the indicator. Any Idea and help? I am using MQL5

This article may help:

https://www.mql5.com/en/articles/43

How to call indicators in MQL5
How to call indicators in MQL5
  • 2010.03.12
  • KlimMalgin
  • www.mql5.com
In MQL5 there are several ways to call indicators, and they are mostly carried out using IndicatorCreate() and iCustom() functions. Moreover, these functions only return indicator handle, and further work on indicators is done through it. So what is a handle? How to deal with IndicatorCreate() and iCustom() functions? And how your expert will...
 
Anthony Garot:

This article may help:

https://www.mql5.com/en/articles/43

Thanks let me check this... I hope this works.

 
Anthony Garot:

This article may help:

https://www.mql5.com/en/articles/43

Can you just get me a sample code that will help me understand how the indicator in the example folder --> Fractals work in the EA. Kindly show a small code so that I can used it the way. I have tried teh article what you have suggested already.

Kindly, help me.

 
jaffer wilson:

Can you just get me a sample code that will help me understand how the indicator in the example folder --> Fractals work in the EA. Kindly show a small code so that I can used it the way. I have tried teh article what you have suggested already.

Kindly, help me.

I have the same problem.

 

One can only confirm fractals a few bars after the fact, so you will never detect a fractal by looking at the current bar nor even the previous bar.

If one had a series array representing the fractal values, where index “0” is the current bar, then you will only be able to detect a fractal at index “2” or “3”.

At “2” it would still be tentative and in progress and not confirmed as the current price could still change and invalidate it. Only at “3” is it confirmed!

So, when analyzing the fractal indicator, search from index “2” or preferably from “3” and beyond for earlier fractals.

 

An example of working with Fractals (Upper only) :

Files:
 
Vladimir Karputov #:

An example of working with Fractals (Upper only) :

Thank you VEEERY MUCH!

 
jaffer wilson: I am trying to make my EA based on the Fractals sample form the Indicator-->Examples folder.
void OnTick()
  {
int test = iCustom(_Symbol,_Period,"Examples\\Fractals");

Perhaps you should read the manual, especially the examples.
   How To Ask Questions The Smart Way. (2004)
      How To Interpret Answers.
         RTFM and STFW: How To Tell You've Seriously Screwed Up.

They all (including iCustom) return a handle (an int). You get that in OnInit. In OnTick/OnCalculate (after the indicator has updated its buffers), you use the handle, shift and count to get the data.
          Technical Indicators - Reference on algorithmic/automated trading language for MetaTrader 5
          Timeseries and Indicators Access / CopyBuffer - Reference on algorithmic/automated trading language for MetaTrader 5
          How to start with MQL5 - General - MQL5 programming forum - Page 3 #22 (2020)
          How to start with MQL5 - MetaTrader 5 - General - MQL5 programming forum - Page 7 #61 (2020)
          MQL5 for Newbies: Guide to Using Technical Indicators in Expert Advisors - MQL5 Articles (2010)
          How to call indicators in MQL5 - MQL5 Articles (2010)

Reason: