Candle Indication - page 5

 

I probably didnt think enough about the difference between Indicators and EA before I started.

I did consider that using the time to define a new candle might not be very accurate but I am only using the UK100 & NASDAQ which have specific open close times and candles always form at 5 & 10 min local & trading time.

Most of the versions I deleted or wrote over, attached is the only version I have which obviously doesnt work too well.

It never developed because it didnt work, I have several other conditions to add but I would have just been adding to the problem.
Files:
 

Bostock58: I probably didnt think enough about the difference between Indicators and EA before I started

I did consider that using the time to define a new candle might not be very accurate but I am only using the UK100 & NASDAQ which have specific open close times and candles always form at 5 & 10 min local & trading time.

Most of the versions I deleted or wrote over, attached is the only version I have which obviously doesnt work too well.

It never developed because it didnt work, I have several other conditions to add but I would have just been adding to the problem.

Unfortunately you are completely of the mark in regards to your knowledge on how Indicator code is done. You will need to do some research, so that you can learn to understand the logic behind an indicator.

For now, put aside the logic you want to achieve and concentrate first at looking at various examples of indicators so you see how they work.

Start with the examples that are installed with MetaTrader, in the "MQL5\Indicators\Examples" folder, and look at their code. Here are some suggestions to start with:

Just realised that you are coding for MQL4, so please ignore the above examples and look at the MQL4 examples instead:

 

Well that has pretty much puts me back to the starting point and hasnt helped at all "put aside the logic" thats the only bit I needed help with.

Words fail me at the moment, I am just off to punch a hole through the wall.

 
Bostock58: Well that has pretty much puts me back to the starting point and hasnt helped at all "put aside the logic" thats the only bit I needed help with. Words fail me at the moment, I am just off to punch a hole through the wall.

How do you expect to develop your coding skills if you are not willing to put in the effort to do your research?

At the moment you still don't understand how an indicator is supposed to be coded, so you need to do something about it if you want to learn:

  1. You can dig into the documentation a read how it works, but something tells me you are not interested in doing that.
  2. So, another option is to study examples of some indicators, but it seems you don't want to do that either.
  3. Yet another option is for you to hire a tutor or mentor to spend some time with you and teach you all that you need to learn, but that costs money and requires that you commit yourself to learning.
  4. And finally, you can hire someone to code it for you, so that you don't have to spend too much time and effort learning to do it yourself.

Do you really think that proficient coders become like that in just a few days or weeks? No, it takes months to become below-average at it, and years to become good at it, and decades to become a master at it.

So, how do you expect to become proficient in such a short amount of time or with just a few posts of guidance. Sorry, but that is not how it works!

You need to put in the effort and do the research, or hire someone to mentor you step-by-step! That is, if you really are set at becoming a MQL coder!

 

As per Anthony's suggestion.

  {
//---
   int begin=(prev_calculated==0)?rates_total-4:rates_total==prev_calculated?0:rates_total-prev_calculated-1;
   bool buyCondition1,buyCondition2,buyCondition3,buyCondition4;
   static bool tradeBuy;
//---
   for(int i=begin;i>=0 && !_StopFlag;i--)
     { 
      buyCondition1=close[i]-close[i+1]>=4; 
      buyCondition2=close[i+1]-close[i+2]>=2;
      buyCondition3=close[i]-close[i+2]>=4;
      buyCondition4=close[i+1]-close[i+3]>=2;
//---
      if(rates_total!=prev_calculated)
        { 
         tradeBuy=false;
         Comment("");
        }
//---
      if(!tradeBuy && (buyCondition1 || buyCondition2 || buyCondition3 || buyCondition4))
        {
         tradeBuy=true;
         BullEntry[i]=low[i];
         Comment("Bull entry");
        }
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
Reason: