'Circles colored by condition do not always show the right color compared to the close price of symbols on chart

Circles colored by condition built on the close value of 3 symbols do not always show the right color compared to the close prices of the same symbols when added to the chart. Can you please advice what the problem is ? Here is the code:

// This source code is subject to the terms of the Mozilla Public License 2.0 at 
https://mozilla.org/MPL/2.0/
// © avirub

//@version=4
study(title = "vix position", shorttitle="vix position")

s1=security("CBOE:VIX9D", "120", close[1], barmerge.gaps_off, barmerge.lookahead_on)
s2=security("CBOE:VIX", "120", close[1], barmerge.gaps_off, barmerge.lookahead_on)
s3=security("CBOE:VIX3M", "120", close[1], barmerge.gaps_off, barmerge.lookahead_on)
s4=security("CBOE:VIXN", "120", close[1], barmerge.gaps_off, barmerge.lookahead_on)

_s1= (s1<s2) and (s2 < s3)   //ok    
_s2= (s1>s2) and (s1<s3 )  //yellow
_s3= (s1>s3) and (s2<s3 )  //orange
_s4= (s1>s3) and (s2>s3 )  //red


plotshape(_s1, style=shape.circle,location=location.bottom,color=color.lime)
plotshape(_s2, style=shape.circle,location=location.bottom,color=color.yellow)
plotshape(_s3, style=shape.circle,location=location.bottom,color=color.orange)
plotshape(_s4, style=shape.circle,location=location.bottom,color=color.red)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source