# Grids Examples

<details>

<summary>Grid 1: <a href="/pages/7DXMPVsmVv4qE0zWkr1F">Selling at the Best Price with Minimum Price and Balance Constraints</a></summary>

```json
{
"gap": "0.005",
"execute_price": "max(orderbook().ask[0].price-symbol().price_precision,min_ask_price)*(1+gap*(order_pos-1))",
"min_ask_price": "orderbook().bid[0].price+symbol().price_precision",
"execute_volume": "10/execute_price+abs(order_pos)*10/execute_price",
"buy_orders_count": "0",
"sell_orders_count": "5 if balance('counter').total < 5000 else 0"
}
```

</details>

<details>

<summary>Grid 2: <a href="/pages/3BLMvaxDCOVV6jVANuz8">Selling at the Best Price Considering Historical Data</a></summary>

```json
{
"gap": "0.01",
"candles_1d": "candles('d1', 'base-counter',count=30)",
"execute_price": "max(orderbook().ask[0].price-symbol().price_precision,(month_mean_high+month_mean_close)/2,min_ask_price)*(1+gap*(order_pos-1))",
"min_ask_price": "max(month_mean_close,orderbook().bid[0].price+symbol().price_precision*2)",
"execute_volume": "10/execute_price if execute_price<month_mean_high else (10/execute_price+abs(order_pos)*10/execute_price)",
"month_mean_high": "mean([price.high for price in candles_1d])",
"buy_orders_count": "0",
"month_mean_close": "mean([price.close for price in candles_1d])",
"sell_orders_count": "5 if balance('counter').total < 5000 else 0"
}
```

</details>

<details>

<summary>Grid 3: <a href="/pages/9dsQop0t4wxMYgSNhInX">Buying at the Best Price with Maximum Price and Balance Constraints</a></summary>

```json
{
"gap": "0.005",
"execute_price": "min(orderbook().bid[0].price+symbol().price_precision,max_bid_price)*(1+gap*(order_pos+1))",
"max_bid_price": "orderbook().ask[0].price-symbol().price_precision",
"execute_volume": "10/execute_price+abs(order_pos)*10/execute_price",
"buy_orders_count": "5 if balance('counter').total > 5000 else 0",
"sell_orders_count": "0"
}
```

</details>

<details>

<summary>Grid 4: <a href="/pages/8TZAFR1EHXYmqJuBPd6D">Buying at the Best Price Considering Historical Data</a></summary>

```json
{
"gap": "0.01",
"candles_1d": "candles('d1', 'base-counter',count=30)",
"execute_price": "min(orderbook().bid[0].price+symbol().price_precision,(month_mean_low+month_mean_close)/2,max_bid_price)*(1+gap*(order_pos+1))",
"max_bid_price": "min(month_mean_close,orderbook().ask[0].price-symbol().price_precision*2)",
"execute_volume": "10/execute_price if execute_price>month_mean_low else (10/execute_price+abs(order_pos)*10/execute_price)",
"month_mean_low": "mean([price.low for price in candles_1d])",
"buy_orders_count": "5 if balance('counter').total > 5000 else 0",
"month_mean_close": "mean([price.close for price in candles_1d])",
"sell_orders_count": "0"
}
```

</details>

<details>

<summary>Grid 5: <a href="/pages/zQGCJYeDBl4RCFcpPJqa">Placing Orders at the Best Price or with a Minimum Spread</a></summary>

```json
{
"gap": "0.005",
"min_spread": "0.02",
"pivot_price": "(orderbook().ask[0].price+orderbook().bid[0].price+ticker())/3",
"execute_price": "(pivot_price*(1-min_spread/2+(order_pos+1)*gap) if pivot_price*(1-min_spread/2)<=(orderbook().bid[0].price+symbol().price_precision) else min(orderbook().bid[0].price + symbol().price_precision,orderbook().ask[0].price - symbol().price_precision)*(1+gap*(order_pos+1))) if side=='buy' else (pivot_price*(1+min_spread/2+(order_pos-1)*gap) if pivot_price*(1+min_spread/2)>=(orderbook().ask[0].price-symbol().price_precision) else max(orderbook().ask[0].price - symbol().price_precision,orderbook().bid[0].price + symbol().price_precision)*(1+gap*(order_pos-1)))",
"execute_volume": "20/execute_price + 0 * abs(order_pos)/execute_price",
"buy_orders_count": "5",
"sell_orders_count": "5"
}
```

</details>

<details>

<summary>Grid 6: <a href="/pages/3IxjvIlPsz2ExUQ2uGZA">Placing Orders with a Spread Based on Historical Data</a></summary>

```json
{
"gap_ask": "0.005",
"gap_bid": "0.005",
"price_ask": "max(orderbook().ask[0].price-symbol().price_precision,(two_weeks_mean_high+two_weeks_mean_close)/2,mean_high_15m,min_ask_price)",
"price_bid": "min(orderbook().bid[0].price+symbol().price_precision,(two_weeks_mean_low+two_weeks_mean_close)/2,mean_low_15m,max_bid_price)",
"candles_1d": "candles('d1', 'base-counter',count=14)",
"spread_min": "10*symbol().price_precision",
"candles_15m": "candles('m15','base-counter')",
"mean_low_15m": "mean([price.low for price in candles_15m])",
"execute_price": "(((price_bid+price_ask)/2-spread_min/2)*(1+gap_bid*(order_pos+1)) if side=='buy' else ((price_bid+price_ask)/2+spread_min/2)*(1+gap_ask*(order_pos-1))) if (price_ask-price_bid)<spread_min else (price_bid*(1+gap_bid*(order_pos+1)) if side=='buy' else price_ask*(1+gap_ask*(order_pos-1)))",
"max_bid_price": "mean_low_15m",
"mean_high_15m": "mean([price.high for price in candles_15m])",
"min_ask_price": "mean_high_15m",
"execute_volume": "(6/execute_price if execute_price>two_weeks_mean_low else 10 / execute_price * abs(order_pos)) if side=='buy' else (6/execute_price if execute_price<two_weeks_mean_high else 10 / execute_price * abs(order_pos))",
"buy_orders_count": "5",
"sell_orders_count": "5",
"two_weeks_mean_low": "mean([price.low for price in candles_1d])",
"two_weeks_mean_high": "mean([price.high for price in candles_1d])",
"two_weeks_mean_close": "mean([price.close for price in candles_1d])"
}
```

</details>

<details>

<summary>Grid 7: <a href="/pages/ffGQ6IqP5lkTSxrfUJzw">Placing Buy and Sell Orders Based on RSI of 15-Minute Candlesticks</a></summary>

```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"
}
```

</details>

<details>

<summary>Grid 8: <a href="/pages/MKWcP780qWKtGxShfcUk">Buying and Selling When the 15-Minute RSI Exits a Defined Range</a></summary>

```json
{
  "max_bid": "mean([candle.close for candle in candles_m15])",
  "min_ask": "mean([candle.close for candle in candles_m15])",
  "rsi_m15": "rsi(candles('m15', 'base-counter'), period=14, column='close')[0]",
  "candles_m15": "candles('m15', 'base-counter')",
  "execute_price": "min(orderbook().ask[0].price,max_bid) if side == 'buy' else max(orderbook().bid[0].price,min_ask)",
  "execute_volume": "10 / ticker()",
  "buy_orders_count": "1 if rsi_m15 < 30 else 0",
  "sell_orders_count": "1 if rsi_m15 > 70 else 0",
  "sleep_after_seconds": "300"
}
```

</details>


---

# Agent Instructions: 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.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.
