MT5 Indicator not displaying correctly

 

Hi,

I have n arrow indicator not displaying correctly. see image below. If I change time frame sometimes it corrects itself to show only one sell signal or buy signal.Below is my code. Is there also a way I can move the signal close to the entry candle? Attached find the code and the error

Files:
error.png  43 kb
trendvalue.mq5  12 kb