Try using ask and bid instead of "currentPrice" inside OrderSend function for Buy and Sell , this code will keep sending orders if u did'nt limit the number of orders by giving a if condition with OrdersTotal function. eg : if(OrdersTotal() == 0) { your OrderSend function here. }