4 and 10 bar high/low in chart

 

Hello:

I want to add a bar counter with up or down signals, every time MACD crosses the 0 line.


EX: If macd crosses line 0 upwards. Show with an arrow between the last 12 bars the fourth lowest bar and the 10th lowest bar.

The same in the opposite case.

If macd crosses line 0 down. Show with an arrow between the last 12 bars the fourth highest bar and the 10th highest bar.


In the attach file I can show when MACD cross 0 line, but cant do counter.

I know to get the signals the code looks like:

double val;

int val_index=iLowest(NULL,0,MODE_LOW,12,12);

if(val_index!=-1) val=Low[val_index];

but cant add to indicator, getting error... :(

Please can help me !!

Thanks.

Files:
 
Marcelo Borasi: Show with an arrow between the last 12 bars the fourth highest bar and the 10th highest bar.
You know how to get the signals? What does the lowest low have to do with your want?
  1. Create a 2D array. For the last 12 bars, put the high in element zero, and the bar index in element one.
  2. Sort it.
  3. Now you can access the fourth/tenth elements and get the corresponding index.
  4. Populate your buffers.
 

Thanks for your answer, can you help me how to create the array. and add to the indicator please.


Thanks.

 

Help you with what? You haven't stated a problem, you stated a want.
     How To Ask Questions The Smart Way. 2004
          Prune pointless queries.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Code Base.
              Hiring to write script - General - MQL5 programming forum 2019.08.21

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

Reason: