Calculating candle Wick

 

Hi guys

I'm sorry I'm a noobie struggling here.

I'm trying to calculate the wick of the latest candle if there's any, for example, if the current latest bar is red then the high minus the open should give you the top side wick and if the candle is green then the open minus the low will be the lower side wick

and if the candle is green with an upside wick then its (high - open) minus (current bar price - open) 


How can I translate that to MQL4? For example lets say calculating the lower wick of a green bar? 

I hope I was clear and in the right forums and thanks to everyone who's trying to help I really appreciate it .

 
ranisfaris: How can I translate that to MQL4?

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. 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

 
ranisfaris:

Hi guys

I'm sorry I'm a noobie struggling here.

I'm trying to calculate the wick of the latest candle if there's any, for example, if the current latest bar is red then the high minus the open should give you the top side wick and if the candle is green then the open minus the low will be the lower side wick

and if the candle is green with an upside wick then its (high - open) minus (current bar price - open) 


How can I translate that to MQL4? For example lets say calculating the lower wick of a green bar? 

I hope I was clear and in the right forums and thanks to everyone who's trying to help I really appreciate it .

Calculating an upper wick and a lower wick for a candle with index i:

   double
      upperWick,
      lowerWick;
   // Bullish candle
   if(Close[i]-Open[i]>0.0)
     {
      upperWick=High[i]-Close[i];
      lowerWick=Open[i]-Low[i];
     }
   // Bearish or Doji candle   
   else
     {
      upperWick=High[i]-Open[i];
      lowerWick=Close[i]-Low[i];
     }
 
or simplified
   double upperWick = High[i] - MathMax(Close[i],Open[i]);
   double lowerWick =           MathMin(Close[i],Open[i]) - Low[i];
Reason: