→ Executing Market Order to Buy 20000 EURUSD SUCCEEDED, Position PID14579299Įxecuting Market Order to Buy 30000 EURUSD Var positions = Positions.FindAll("myLabel", Symbol, TradeType.Buy) Įxecuting Market Order to Buy 20000 EURUSD ĮxecuteMarketOrder(TradeType.Buy, Symbol, 20000, "myLabel") ĮxecuteMarketOrder(TradeType.Buy, Symbol, 30000, "myLabel") Here we illustrate the method FindAll ( Positions.FindAll) which returns an array of positions that we can loop through. On each new incoming bar, the cBot will look for the order with one of two labels and close only half of it, if the volume is equal to or greater than 20,000. Let’s modify the previous example to create two market orders with the same labels ( "myLabel"). | 14:55:17.901 | cBot "New cBot" was started successfully for EURUSD, h1. If (position != null & position.GrossProfit > 10) Var position = Positions.Find("myLabel") ĮxecuteMarketOrder(TradeType.Buy, Symbol, 10000, "myLabel")
The code sample below creates a Market Order and if the position Gross Profit is above a certain value (null & position.GrossProfit > 10), it closes the position.
New Position SL price is 1.18744 Closing a Position → Executing Market Order to Buy 10000 EURUSD (TP: 10) SUCCEEDED, Position PID14576161 Print("Position entry price is ", position.StopLoss) ĬBot "New cBot" was started successfully for EURUSD, h1.Įxecuting Market Order to Buy 10000 EURUSD (TP: 10) Var result = ExecuteMarketOrder(TradeType.Buy, Symbol, 10000)
If the order execution is successful the entry price is printed to the log. The following simple cBot creates a Market Order upon startup and saves the result in the result variable. A simple cBot with a successful result.Synchronous Operation Method Executing Market Orders