I'm not familiar with pinescript, but are you sure
position
should be a string and not simply position := position.middle_right
? That would also imply you shouldn't probably call your variable position
, so actually somithing like myPosition := position.middle_right
.