Spike or candle identification

Wamaitha  

Hello, I have the following code that hard-codes how to identify a spike and a candle on boom 1000 and crash 1000 for the M1. However is there a generic way of identify whether we are in a spike or a candle regardless of time frame or whether its a boom or crash without hardcoding the length. This code is part of ontick since I want to know at present if the current formation is a candle or a spike. Im assuming there is a mathematical way mql5 computes it so as to draw the different styling on the chart. For example on my chart a spike is red and a candle is green. So whats the code behind the scenes that does this regardless of timeframe or symbol.


void OnTick(){  
 double current_price = SymbolInfoDouble(_Symbol,SYMBOL_BID);   
   double close_for_last_candle = iClose(_Symbol,PERIOD_CURRENT,0);
   string candle_or_spike = "";   
      
   if(MathAbs(close_for_last_candle - current_price) < 0.8500 && MathAbs(close_for_last_candle - current_price) < 1.2500 ){
      candle_or_spike = "CANDLE";
      
   }else if(MathAbs(close_for_last_candle - current_price) > 1.2500){
      candle_or_spike = "SPIKE"      ;
   };

 Comment("Currently in a ",candle_or_spike );
};
William Roeder  
Wamaitha Nyamu: However is there a generic way of identify whether we are in a spike or a candle regardless of time frame or whether its a boom or crash without hardcoding the length.
Of course, there is. Code it without hard coding the size. E.g. the tail > 2 body size, or |prevClose-close| > ATR
Wamaitha  
William Roeder #:
Of course, there is. Code it without hard coding the size. E.g. the tail > 2 body size, or |prevClose-close| > ATR

@William Roeder While this can work for some cases. It doesnt always work. Look at the attached image. They both have the same length. Im looking for a solution that doesnt rely on length. Like what prompts mq5 to plot that specific candle as a candle while another as a spike regardless of length.

Files:
booom.jpeg  223 kb
William Roeder  
  1. Wamaitha Nyamu #: It doesnt always work. Look at the attached image. They both have the same length.

    Until you can state your requirements in concrete terms, it can not be coded.

  2. Wamaitha Nyamu #: Like what prompts mq5 to plot that specific candle as a candle while another as a spike regardless of length.

    The market movement made the terminal plot that candle.

Wamaitha  
How can I code a spike without hard coding it, that is using the length as a differentiating factor
Amos Tsopotsa  
Wamaitha Nyamu #:
How can I code a spike without hard coding it, that is using the length as a differentiating factor

use a timer

William Roeder  
Wamaitha Nyamu #: How can I code a spike without hard coding it, that is using the length as a differentiating factor

Until you can state your need in concrete terms, it can not be coded.

Perhaps length vs. ATR

Reason: