Download MetaTrader 5

Advise on this thought.

To add comments, please log in or register
tafadzwa
117
tafadzwa  
i want a peace of code in an indicator that does the following : search in the history of a currency pair for the open price (bid) that is equal to the current open price (bid). How best can this be done? Thank yu.
Alain Verleyen
Moderator
33340
Alain Verleyen  
tafadzwa:
i want a peace of code in an indicator that does the following : search in the history of a currency pair for the open price (bid) that is equal to the current open price (bid). How best can this be done? Thank yu.

If you can't find what you need in the Codebase or the Market, then you can create a request in Jobs Service.
Emiliano Graziosi
40
Emiliano Graziosi  
angevoyageur:

If you can't find what you need in the Codebase or the Market, then you can create a request in Jobs Service.


If I correctly understand you must search the open prices of each bar, so a straightforward way is to implement a while loop something like:

int maxnumberofbars = 400;

int i = 1;

bool openpricefound = false;

while(i<=maxnumberofbars && openpricefound==false)

{

if (Open[i] == Bid) openpricefound == true

<any other logic you want on the price must be put in the if>

i++;

}

Bye

whroeder1
15925
whroeder1  

  1. Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. if (Open[i] == Bid) openpricefound == true
    Likely will never match. The == operand. - MQL4 forum
To add comments, please log in or register