Grid cBot
Strategy Overview¶
The Grid cBot implements a grid trading strategy where multiple buy or sell orders for a symbol are placed at regular price intervals or "steps", forming a "grid" of positions. As the symbol price changes, new positions are opened constantly to take advantage of fluctuations.
The Grid cBot uses a combination of simple arithmetic and logical checks to open positions, calculate profits and manage its trade operations. It is most effective in range-bound or sideways markets. It also performs decently in low-volatility conditions and markets with known resistance and support levels.
Indicator Integration¶
The Grid cBot does not rely on any indicator to define its grid strategy; it does not try to predict whether a symbol price will go up or down. Instead, it targets profitable trades from price movements in any direction.
The cBot executes trades based on this simple rule:
If the symbol price moves beyond a specified number of pips (defined by the StepPips
parameter), the cBot opens a new position.
Calculation and Logic¶
Initial Trade Execution
When the cBot starts, it checks whether there are any open positions in the grid. If there are no open positions, the cBot opens the first position immediately through the OpenPosition()
method. This first step ensures that the grid starts with an initial trade based on the specified trade side (TradeType
).
Profit Monitoring
On each tick (i.e., each price update), the cBot checks whether the cumulative net profit of all open grid positions meets or exceeds the specified target profit (TargetProfit
). If the target profit has been reached, all open positions are closed, and the cBot stops running.
The target profit is the sum of the net profit from each position in the grid.
\(n\) – number of open positions in the grid
\(\text{NetProfit}(p_i)\) – net profit of position \(i\)
Opening Positions
If the target profit has not been reached and there are open positions, the cBot calculates the distance (in pips) between the last opened grid position and the current market price.
For buy positions:
For sell positions:
Entry Price. The price at which the last buy position for the symbol was opened.
Ask Price. The current ask price for the symbol.
Bid Price. The current bid price for the symbol.
Pip Size. The value of one pip for the symbol.
If the calculated distance is greater than or equal to the defined step size (StepPips
), a new position is opened using the OpenPosition()
method.
Each time before it opens a new position, the cBot checks and confirms that there are enough funds for the operation. If the funds are insufficient, the cBot stops attempting to open new positions and logs the "Not enough money to open additional positions" message.
Closing Positions
Once the TargetProfit
is reached, the cBot logs the "Target profit is reached. Closing all grid positions" message.
The CloseGridPositions()
method then loops through all open positions in the grid, closes them and then the cBot logs the "All grid positions are closed. Stopping cBot" message. The cBot is then stopped.
Parameters¶
Parameter | Unit | Definition | Tips |
---|---|---|---|
Quantity | Lot | Volume of each trade. | Conservative traders may specify small lot sizes to reduce exposure and manage risk carefully, especially in a volatile market. This way, any potential loss is minimised if the market moves against the grid. Aggressive traders may specify big lot sizes to maximise profits when they are confident in a market. While this approach is riskier, it delivers greater returns when the grid captures large price fluctuations effectively. |
Trade side | — | Direction of the trade (Buy or Sell). | In a rising market, traders may select Buy. When the symbol temporarily retraces downwards, the cBot buys at lower levels. As the market moves back up, each buy position becomes profitable. In a falling market, traders may select Sell. When the symbol price temporarily retraces upwards, the cBot sells at higher levels. As the market moves back down, each sell position becomes profitable. |
Step | Pip | Distance between two consecutive grid positions. The smaller the step, the more frequently new trades are opened, while a larger step results in fewer trades. | In a sideways or low-volatility market, traders may set a small value. This setting ensures that the cBot opens positions more frequently and captures small price fluctuations, especially when the price moves within a narrow band. In trending or more volatile markets, traders may set a large value. This setting reduces the number of trades opened, allows the cBot to capture larger movements and helps to avoid overtrading during strong trends. |
Target profit | — | Cumulative profit in the account currency that must be reached before the cBot closes all open positions and stops trading. | Traders looking for quick, small profits may set a low value. This setting ensures that the grid closes as soon as a small profit is made, minimising the risk of positions being held too long in volatile markets. Traders who prefer to wait for large profits can set a high value. This setting allows the grid to stay open longer, allowing the cBot to accumulate profits over a series of larger market movements before all positions are closed. |
Application¶
Range-Bound or Sideways Markets¶
The Grid cBot is most effective in range-bound markets where the price oscillates between support and resistance levels. In such markets, as prices frequently move up and down within a defined range, cBot opens positions regularly and capitalises on fluctuations.
Use Case
Consider a scenario where EURUSD stays in the range between 1.1000 and 1.1100. The cBot opens buy positions when the price drops closer to 1.1000 and opens sell positions near 1.1100. As the price oscillates between these levels, the cBot captures profits from each swing.
Best Practices
- Set a small step size to capture frequent price swings.
- Set a modest target profit so that the grid closes frequently, allowing you to secure small, consistent profits.
- Monitor market news or upcoming events that could lead to a breakout from the range and cause large drawdowns.
Low Volatility Markets¶
In low-volatility markets, price movements tend to be slow and less pronounced. As the price moves gradually, the grid cBot gets ample time to open multiple positions without facing the risk of large, rapid market movements.
Use Case
Consider a scenario where USDJPY exhibits low volatility as it often does during the Asian trading session. The Grid cBot can open positions with a small step size and capture small, gradual price movements that occur during those quiet hours.
Best Practices
- Use a tight step size to capitalise on the smaller price movements typical in low-volatility markets.
- Set a low trade volume to reduce risk in case volatility unexpectedly increases.
- Keep an eye on market conditions, unexpected news or events and be ready to stop the cBot quickly.
Markets with Known Levels¶
The Grid cBot can do well in markets with strong, well-defined support and resistance levels. Those levels act as price barriers and cause the market to frequently bounce back, resulting in a range that the cBot can exploit.
Use Case
Consider a scenario where the price of gold (XAUUSD) oscillates between a strong support level at USD 2,000 and a resistance level at USD 2,050. The Grid cBot opens buy orders near USD 2000 and sell orders near USD 2050, profiting from the price bouncing between these levels.
Best Practices
- Set the step size based on the market volatility. A high-volatility market may require larger step sizes, while low-volatility markets can use smaller steps.
- Use the Grid cBot around markets with well-established support and resistance levels to avoid getting caught in a breakout.
- Be cautious of events or news that could cause a breakout to avoid large losses. The cBot is not prepared to handle the market breaking through support or resistance levels.
Non-Directional Markets¶
Certain currency pairs exhibit non-directional movement with frequent price fluctuations, but their price does not show a strong long-term trend. The Grid cBot works well in such markets because it can capture frequent fluctuations without the risk of getting caught in a long-term trend.
Use Case
Consider a scenario where EURCHF moves in a non-directional manner, a common occurrence given the stability of the Eurozone and Switzerland’s economy. The Grid cBot can open positions with a small step size, capturing profits from frequent fluctuations without worrying about large directional trends.
Best Practices
- Use a small step size to capture frequent price movements.
- Consider setting a low trade volume to manage risk in case the market breaks out into a trend.
Summary¶
The Grid cBot operates on the assumption that during both bullish and bearish markets, there will be retracements or pullbacks. It buys low and sells high in bullish markets and sells high and buys low in bearish markets; the cBot captures profits when the market resumes the primary trend after retracements.
Since the cBot does not use indicators, it cannot assess whether the market is trending or ranging. It simply opens positions based on price movement alone, ignoring market sentiment or trend strength.
The absence of indicators makes the trading process purely mechanical; the cBot relies only on predefined rules for opening positions at regular intervals. While this approach can be profitable in range-bound markets, it tends to suffer in trending, highly volatile or rapidly changing markets.
In addition to configuring the cBot to apply their personal strategies, traders may consider introducing indicators to filter trades based on market conditions:
- Moving Averages (MA) can help identify the market trend, allowing the cBot to trade only in the direction of the trend.
- Relative Strength Index (RSI) can signal overbought or oversold conditions, helping the cBot avoid opening new positions when the market is stretched in one direction.
- Bollinger Bands can provide insight into price volatility, allowing the cBot to adjust the grid spacing or hold off on trading during periods of high volatility.