simple pending order EA

 
hi please can any one help me with this pending order ea. It should open one buy stop and one sell stop each side of the market. The problem it has is it opens a buy stop then a sell stop then another buy stop:/  if I change to the code so it has the sell stop first then I get two sell stops and one buy stop:/ Its driving me nuts, if you can tell me where i'm going wrong, I might save my sanity many thanks :)
 

Mistake in line 129 

OrderType... 

Reason: