Cyato Grid Basic Buy & Sell [BACKTEST]

Private indicator

This Grid bot strategy creates buy orders when the price goes down one level or more, and sell order when the price goes up one level or more.
To avoid useless trades, the lastest traded level is disabled until another level is crossed.

To create the grid, one upper level and one lower level is calculated. Those 2 levels are either given by the user using "MANUAL" mode or automatically calculated by an AI. The space between these two levels are then divided equally into several steps, creating the grid. The number of steps is chosen by the user, from 3 to 20.


This is the Backtest version meaning this is the one you should use with the Strategy Tester (more below).

Select either "MANUAL" or "AI" mode.
When using "MANUAL", you have to configure an upper level and a lower level.
When using "AI", the upper and lower level are automatically calculated from last 7 days high/low plus a 3% deviation. You can configure the timeframe and the deviation.

Select the grid quantity, from 3 to 20.

Example with 3:

Example with 10:

Example with 20:

You can choose between "Once Per Bar Close" or "Once Per Bar" alert type.
"Once Per Bar Close" will wait candle close to confirm a trade.
"Once Per Bar" will trigger a trade if the price crossed a step anytime inside a candle. Note that the backtest will still use bar close price in its calculation.


The strategy will buy 1 contract when a BUY signal appears and sell 1 contract when a SELL signal appears.
Here 1 contract = 1 BTC

The strategy can buy up to 20 contracts. Pyramiding is enabled.

The Backtest info panel is here to show how many trades are open in the backtest.

I know very well that a backtest has no value if several trades are left open. That is why I coded a feature to close all open trades at once on the last candle. This feature can be turned on and off.

To get this indicator, use the link in my signature below, thanks!
Release Notes: Core behavior fixes
Release Notes: AI mode updated:
The up/lower step is now calculated using high/lowest of 100 bars of higher data, plus a percent increased range.
Release Notes: AI strategy behavior improvements:
When the grid moves, the last traded level was reset when it should not.
Release Notes: NEW: STOP LOSS Feature
You can turn it on/off

Make the strategy close all orders if price breaks below step 0 which is one step below step 1
Release Notes: You can now choose between a LONG or a SHORT strategy

Release Notes: Updated info panel
Release Notes: New input setting to change the order size.
Release Notes: Added strategy alerts text inputs!

How to create Strategy Alerts:
Write your alert messages for EXIT, LONG and SHORT orders in the settings (Backtest section).
Then click add alert, and in the alert message, write the following:
Release Notes: bugfixes:
The highest step was misbehaving sometimes.
Release Notes: Bugfixes with the AI mode.
Release Notes: Updated Backtest Period settings: we can now select hours and minutes.
Release Notes: Max number of grid steps increased to 30, but steps above 24th will not be printed on chart due to graphic limitations.
Release Notes: Configuration panel udpated: smaller and better placement.

Added new alert system!
To use it:
1. Write your alert messages in the indicator settings (alert section at the bottom)
2. CLick "Create Alert" as usual, but choose "alert() function calls only"

That's all! You will receive alerts for every event.
Release Notes: Max grid quantity increased to 100

Max grid quantity plotted on chart increased to 59
That means grid steps above 59th will not be plotted (due to graphic limitations)

AI mode improved. An option was added to use the old AI mode if needed.
Release Notes: Fixed multiple entries bug while letting the indicator run with recalculate on every tick setting on
Release Notes: Bugfix: deals not closing in the backtest when using "recalculate on every" tick in real time.
Release Notes: Updated inputs, added tooltips
Updated info panel
Release Notes: Order Size
Added an option to choose from "Fixed", "% of Equity", or "Contracts".
Release Notes: Added new Backtest Results panel!
You can disable it by going in the style tab -> tables, or by clicking the indicator setting "Backtest Results Table".
Release Notes: Backtest orders realtime behavior fix bug: several closing orders on the same candle
Release Notes: Updated backtesting behavior:
- each step is now closed with its corresponding previous step, instead of "First In, First Out".
- order size is now set in the regular backtest properties tab.
Release Notes: fix backtest period option
Release Notes: Alerts will no longer stop triggering if they are outside of the backtest period.
Release Notes: Fix backtest bug (multiple orders on same bar)
Release Notes: .
Release Notes: Revert
Release Notes: Updated config panel
Release Notes: Added Grid step size to the backtest panel
Added Break Even line
Release Notes: Fix for real time backtesting
Release Notes: Updated default settings for easier onboarding.
The indicator is now plotting all of the max 100 grid step lines.
Release Notes: Added more stop loss features:
Added optional Upper and Lower Stop Loss with price configuration and action being either "Stop Bot" or "Stop Bot and buy/sell base currency using all equity".

Added alerts for both stop losses.

🔥Get the Cyatophilum Indicators today 🔥 =>

Automated Strategies with Backtest and Alert Setup - Now with Binance API Bots!

I am taking PineScript Commissions ✔
Invite-only script

Access to this script is restricted to users authorized by the author and usually requires payment. You can add it to your favorites, but you will only be able to use it after requesting permission and obtaining it from its author. Contact cyatophilum for more information, or follow the author's instructions below.

TradingView does not suggest paying for a script and using it unless you 100% trust its author and understand how the script works. In many cases you can find a good open-source alternative for free in our Community Scripts.


The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Author's instructions

This indicator access can be purchased through a subscription on my website:

Want to use this script on a chart?

Warning: please read before requesting access.