Download MetaTrader 5

Question about positive and negative numbers

To add comments, please log in or register
Paul
526
Paul  

I've been trying to establish the cross above or below zero, on an indicator.  I am comparing the value of Bar #2 to Bar #1.   Not Bar #0.  If Bar#2 < 0 and Bar#1 > 0 then cross up.  If Bar#2 > 0 and Bar#1 < 0 then cross down.  Should be simple.  If below 0, number is negative.  If above, positive.  My problem is, that when both Bars are negative, the code ignores their state and which ever Bar is larger determines cross up and cross down.  Same condition occurs with both Bars, positive.  How would I code this so that I only consider one Bar positive and one Bar negative to determine cross  up or cross down, and ignore cases where there is two Bars positive or two Bars negative?

Thanks!

Keith Watford
Moderator
9641
Keith Watford  

Then you have not coded what you have outlined above

Show your code and somebody may be able to help you 

To add comments, please log in or register