Example 4. Technical task “Adviser limit grid”
A grid of limit orders is placed in the number (Orders) at a specified distance (Step_2) from each other with an increase in the step by (PlusStep). The first limit order is placed at a distance (Step_1) from the current price. Above the price, SellLimit orders are placed, below BuyLimit (which orders to place buy or sell are set in the parameters). The lot of the first order from the price is specified by the parameter (Lot) the lot of the remaining orders have the size multiplied by the coefficient (K_Lot). At the distance of PipsStopLoss from the last order, a stop loss is placed for all orders in this direction.
Next, the ADVISER waits for the closing of the profit (ProfitClose) and after closing the entire series starts from the beginning at the start of the next candle (the timeframe of the candle is set in the parameters).
Orders = 5 – number of orders in each direction
Buy = true – allow placing BuyLinit orders
Sell = false – allow placing SellLinit orders
Step_1 =10 – distance from the current price to the first order
Step_2 =10 – distance between orders
PlusStep = 1 – addition in points to the step between orders
Lot = 1 – lot of the first order in the series
K_Lot – the coefficient of increasing the lots of subsequent orders
PipsStopLoss =20 – stoploss of the entire series of orders (set for the order farthest from the price)
ProfitClose= 15 profit in the deposit currency to close the order
TF =60 – timeframe of the candle to start