> For the complete documentation index, see [llms.txt](https://docs.origami.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.origami.tech/user-guide/grids-examples/placing-buy-and-sell-orders-based-on-rsi-of-15-minute-candlesticks.md).

# Placing Buy and Sell Orders Based on RSI of 15-Minute Candlesticks

Orders are placed at levels corresponding to an RSI of 40 for buy orders and an RSI of 60 for sell orders, or at the best bid or ask price if the RSI moves outside the specified range.

```json
{
  "gap": "0.005",
  "min_low": "orderbook().bid[0].price",
  "max_high": "orderbook().ask[0].price",
  "price_low": "min(rsi_to_price(candles_15m, rsi_expected=40), orderbook().ask[0].price, min_low)",
  "price_high": "max(rsi_to_price(candles_15m, rsi_expected=60), orderbook().bid[0].price, max_high)",
  "candles_15m": "candles('m15')",
  "execute_price": "(price_low if side == 'buy' else price_high) * ( 1 + gap * order_pos)",
  "execute_volume": "cached(60, respect='order_pos')(10/execute_price *abs(order_pos))",
  "buy_orders_count": "5",
  "sell_orders_count": "5",
  "sleep_after_seconds": "900"
}
```

In this example, 15-minute candlestick data is used to estimate the price levels that would correspond to an RSI of 40 and 60 in the next period.

[<mark style="color:blue;">`rsi_to_price`</mark>](/function/technical-analysis/rsi-to-price.md)<mark style="color:red;">`(candles_15m, rsi_expected=40)`</mark>

[<mark style="color:blue;">`rsi_to_price`</mark>](/function/technical-analysis/rsi-to-price.md)<mark style="color:red;">`(candles_15m, rsi_expected=60)`</mark>

Bids are placed at RSI 40, and asks are placed at RSI 60 with a price increment of 0.5%, which is defined in the parameter "gap".

Buy orders are placed at the RSI 40 level. Sell orders are placed at the RSI 60 level. A price increment is 0.5%, as specified by the gap parameter.

The volume for each order is calculated as the equivalent of 10 counter tokens multiplied by the order's sequence number.

<mark style="color:red;">`10/`</mark>[<mark style="color:blue;">`execute_price`</mark>](/function/required-parameters/execute-price.md) <mark style="color:red;">`*`</mark>[<mark style="color:blue;">`abs`</mark>](/function/functions/abs.md)<mark style="color:red;">`(`</mark>[<mark style="color:blue;">`order_pos`</mark>](/function/pre-defined-parameters/order-pos.md)<mark style="color:red;">`)`</mark>

The order grid is updated every 15 minutes.

<mark style="color:red;">`"`</mark>[<mark style="color:blue;">`sleep_after_seconds`</mark>](/function/optional-parameters/sleep-after-seconds.md)<mark style="color:red;">`": "900"`</mark>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.origami.tech/user-guide/grids-examples/placing-buy-and-sell-orders-based-on-rsi-of-15-minute-candlesticks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
