Indicator Question - page 5

 
Oh one last question

Is it more typical to count forward or backward when building indicators that may be used in EA's

Does one create more problems then the other or is it just a matter of preference and design ?

Please advise

Thanks

 
Every now and then take a look at this article: https://www.mql5.com/en/articles/1456 it can be a bit daunting but keep at it, bit by bit, once you understand it you will have learned about Indicators, EAs and their differences.
 
Agent86:
Oh one last question

Is it more typical to count forward or backward when building indicators that may be used in EA's

Does one create more problems then the other or is it just a matter of preference and design ?

Typically many of the Indicators I have seen count up i++, in my humble opinion this is wrong . . . a chart builds from the left to the right, old candles are on the left new ones on the right. When an Indicator process the old bars on a chart ( so it can then start processing the most current bar(s) ) shouldn't it do so in a way that is representative of the way it will work on live data ?

Technical Indicators aren't my thing, I have had to get acquainted with them out of necessity, but my experience with them is small, I would also welcome other answers from more experienced people.

 

usually, as far as I am concern during actual trading, the entire sets of bars prices far away in the past is quite irrelevant. Only perhaps those handful of recent ones, in any given frame.

In this regard, I rather 'transfer' the indicator's logic, if they are good enough, to some function or lib where the EA can use directly, instead of calling iCustom and reading buffers, etc. This can be problematic issues, dont forget.

So, to me a good indicator is one that is able to allow me to do just that.

 
I think I will experiment some with each but it seems to me that I would prefer to increment forward from 0 however how does the standard indicators increment ?

If I wanted to use iFractals for something useful in an EA it seems like the signal occurs naturally; and if I wanted to refer back in time to a previous iFractal, then I would i++ the shift to a previous iFractal

But when I see people's EA's and there appears indicators on the charts. Are they using iCustom indicators and indicators they have added or is this typically put into the EA itself and when you open the EA does this occur automatically ?

I'm trying to sort it all out

 
RaptorUK:
Every now and then take a look at this article: https://www.mql5.com/en/articles/1456 it can be a bit daunting but keep at it, bit by bit, once you understand it you will have learned about Indicators, EAs and their differences.
I will thanks.

I need to just keep at it I don't really want to keep struggling but would prefer to learn all that there is about MQL4 so that I can code my own ideas and also contribute to the code base a bit.

I'll keep reading thanks again
 
Hi

Can someone confirm if I'm considering this code correctly ?

Is my print statement referring to the previous iFractal ?

//maybe something like this to count back to the previous iFractal for reference
//needs work     
    for(i=0; val1==val3; i++)
      {
      val1=iFractals(NULL, 0, MODE_UPPER,i);
      val3=iFractals(NULL, 0, MODE_UPPER,0);
      if (val1 > 0)
         {
         Print (val1, " = val1");
         }
        }
It's all I could think of with my limited knowledge so far.

Anyhow, is there anything wrong with this method to go back to the previous iFractal if indeed thats what I have created here.

It seems right in theory from what I can tell ?

Please advise

Thanks

 

When you get an iFractal the value is > 0, yes ?

So, for example, if you want to know where the last UPPER and LOWER iFractals were just do something like this . . .

val1 = 0; val2 = 0; i = 0;

while( val1==0 && val2==0)
   {
   if (iFractals(NULL, 0, MODE_UPPER,i) > 0 && val1==0) val1 = i;
   if (iFractals(NULL, 0, MODE_LOWER,i) > 0 && val2==0) val2 = i;
   i++;
   }
Print("Last UPPER Fractal at ", val1, " Last LOWER Fractal at ", val2);
 
for(i=0; val1==val3; i++) <--- val1==val3??? This is indeed, "tricky"
       {
      val1=iFractals(NULL, 0, MODE_UPPER,i);
      val3=iFractals(NULL, 0, MODE_UPPER,0);
      if (val1 > 0)
         {
         Print (val1, " = val1");
         }
        }

Honestly, this is my first time seeing this, for the loop termination condition. Its is tricky one...

 

It looks cool to me ... All you have to do is test it within the back-tester. Here's how I would do it.

void start(){
   double val1=0,val3=0;
   for(int i=0; i<=3; i++){
      val1=iFractals(NULL, 0, MODE_UPPER,i);
      val3=iFractals(NULL, 0, MODE_UPPER,0);
      if(val1>val3){
        Print("Value_1="+val1+" TimeOf_Fractal="+TimeToStr(TimeCurrent()));
        break;
      }
   }
}

I cannot remember how Fractals are formed. I believe its formed on the third bar. And it considers the two bars before and after it.

Save the above code as an EA and run a short back-test. You could attach the indicator to the back-test chart to confirm.

Here's what I got:

2011.10.06 06:38:49     2011.01.02 23:00  De_Bugger EURUSD,M1: Value_1=1.33710000 TimeOf_Fractal=2011.01.02 23:00
Reason: