Find the price that has been in the most number of candles.

 
Hello

I am trying to find the price that has been in the most candles, to mark a level of importance.

The idea is that this function finds the price at which this has happened above the current price, however I am lost at this point.

I am attaching the code that I currently have, I hope you can help me please.


double ImportantHighLevel() //busca obtener el nivel más importante arriba del precio actual.

   {
    double highlevel= 0,
           level    = 0,
           distmin  = Ask + 100*Point,  //define el nivel mínimo para contar cruces.
           distmax  = Ask + 2000*Point; //define el nivel máximo para contar cruces.
           
    int candles = 1500,
        cross   = 0,
        shift   = 0;
    
    for(level=distmin; level<=distmax; level=Point) //define el rango de precio para obtener el nivel más alto.
       {
        for(shift=1; shift<=candles; shift++) //define el rango de velas a buscar.
           {
            if (level<=High[shift] && level>=Low[shift]) cross++; //define los parámetros para identificar un cruce y lo cuenta.
            return cross; //obtiene la cantidad de cruses por cada nivel.
           }
        int levels[1900] = level;
        highlevel = ArrayMaximum(levels,WHOLE_ARRAY,0); //obtiene el nivel con mayor cantidad de cruces.
        
       }  
    
    
    return (highlevel);
   }
 
        int levels[1900] = level;
        highlevel = ArrayMaximum …

That is moronic.

You set the first element to level ( int(distmin) ), and set all the others to zero.

Then ask for the index of the highest element. The answer is zero, and highlevel equals zero.

 
Angel Antonio Martinez Velasquez:
Hello

I am trying to find the price that has been in the most candles, to mark a level of importance.

The idea is that this function finds the price at which this has happened above the current price, however I am lost at this point.

I am attaching the code that I currently have, I hope you can help me please.


Hello.

Why do you test in a specific range above the price ?

What are the criteria for seeking that price ?

The Price action candles themselves  can guide you on finding the most important level because they already have 4 levels stored in them ,but.

This is MT4 not MT5 so you are limited to a range instead of a specific price (no historic ticks access).

  • Step 1 would be to define the range in past bars for which you want to discover the most important level
  • Step 1.5 ,if feeling brave, would be to find the lowest level timeframe available for each of those candles
    [because if you are checking on the H1 , and that H1 bar has M1 data available ,you can seek in the M1 domain for this time range increasing your precision-again since there are no ticks.The bravery will be needed if that H1 bar has some M1 some M5 some M15 and an M30 :) ]
  • Step 2 You acquire all the price levels (4 from each candle regardless of timeframe) and you create a map with all the prices encountered
  • Step 3 You sort that map top to bottom (the prices)
  • Step 4 You treat each pair of prices as a range and you check its importance 
  • Step 5 You now have the most reoccuring range (and more ranges in the list for utilization , whether its Support/Resistance or Market Profile) 
 
Lorentzos Roussos:

    Hi Loren


    Thank you very much for supporting me again, your help is welcome.