MT5 bug ?

 

I compare current, previous Bar heights, high, low, open, close.

The result is always negative, despite the candle direction. Have tried int, char data types.

Is it MT5 bug ?

Why negative symbol appears in both directions ?

 
arjani111:

I compare current, previous Bar heights, high, low, open, close.

The result is always negative, despite the candle direction. Have tried int, char data types.

Is it MT5 bug ?

Why negative symbol appears in both directions ?

you need to be clearer about what you are saying, maybe attached your code and show the output..

 
int OnInit()
  {

   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {

   ObjectDelete(0,"Label5");

  }

void PutLabel(string name,string text,int x,int y,color clr)
  {
   ObjectDelete(0,name);
ObjectCreate(0,name,OBJ_LABEL,0,0,0);
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_RIGHT_UPPER);
ObjectSetString(0,name,OBJPROP_TEXT,text);

  ObjectSetString(0,name,OBJPROP_FONT,"Arial");

   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);

   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
  }

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],

                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {

   int barHighLow=0;

int high1 = iHigh(Symbol(), PERIOD_M1,0);
int low1 = iLow(Symbol(), PERIOD_M1,0);

barHighLow=low1-high1;

         PutLabel("Label5"," lowhigh:
"+(int)NormalizeDouble(barHighLow,10)+"   $ ",150,30,Yellow);

   return(rates_total);

  }
 
Paul Anscombe:

you need to be clearer about what you are saying, maybe attached your code and show the output..

I have uploaded the code.
So any suggestions why MT5 always show negative result when candle High and Low is being compared ?

P.S. how to show the output ?
You can attach this mt5 indicator to any chart and you will see the results. Greetings

 
arjani111:
I have uploaded the code.
So any suggestions why MT5 always show negative result when candle High and Low is being conpared ?

P.S. how to show the output ?
You can attach this mt5 indicator to any chart and you will see the results. Greetings

you need to change the variables to double instead of int  

you need to take the low from the high  instead of the high from the low

 
Paul Anscombe:

you need to change the variables to double instead of int  

you need to take the low from the high  instead of the high from the low


It does not solve the issue. Now I get always always positive result.
Candles are going in both directions, negative and positive, but result does not show it.
Looks like MT5 developers put ABS function on it or something similar.

I compare open and close values as well.
Example: open 0, close 1. Difference ?
Example: open 0, close -1. Difference ?
MT5 does not see difference
 
arjani111:

It does not solve the issue. Now I get always always positive result.
Candles are going in both directions, negative and positive, but result does not show it.
Looks like MT5 developers put ABS function on it or something similar.

I compare open and close values as well.
Example open 0, close 1. Difference ?
Example open 0, close -1. Difference ?
MT5 does not see difference

well if you want it to represent bear/bull you need to change your logic.

check if the Close is > Open 

if yes  High - Low gives positive  for a bull bar

if no Low - High gives a negative for a bear bar

 
Paul Anscombe:

well if you want it to represent bear/bull you need to change your logic.

check if the Close is > Open 

if yes  High - Low gives positive  for a bull bar

if no Low - High gives a negative for a bear bar

Thank you Paul !

I have used logic:

 if the Close is > Open then = 1
           Close is < Open then = -1

And HighLow * 1 or HighLow * - 1. This conversion gives me the result I wished to.

Can you take a look at this ?

https://www.mql5.com/en/forum/338305#

I expect similar issue related to MT5 peculiarities.

 
arjani111: I expect similar issue related to MT5 peculiarities.

Has nothing to do with "MT5 peculiarities." That is reality. The high is always greater or equal to the low. Therefor high-low will always be positive.

 
William Roeder:

Has nothing to do with "MT5 peculiarities." That is reality. The high is always greater or equal to the low. Therefor high-low will always be positive.

It is theoretically and should be practically, but

MT5 live data printed by MT5 indicator gives me:

Open = Close
High = Open

Always. So there the confusion comes from.

So if so then according to what MT5 prints.

Open - High = Close - Open

But it should not.
And indeed MT5 gives correct results when it come to callculation.
So why it prints one and gives another ?

I will upload picture if it is confusing.
 
arjani111:
I have uploaded the code.
So any suggestions why MT5 always show negative result when candle High and Low is being compared ?

P.S. how to show the output ?
You can attach this mt5 indicator to any chart and you will see the results. Greetings

As already said by other people, High will be always greater than Low.

High is the maximum of the candle, Low the minimum. How can maximum be less than minimum?!

High-Low will be always positve.

Low-High will be always negative.

Reason: