Rules

Rules — The Mathematics of Decision

All the grand machinery of trading — the charts, the indicators, the data —
eventually collapses into something beautifully simple:
a comparison.

Less Than. Greater Than. Between. Above. Below. Crossed Over. Crossed Under. Rising. Falling. In Slope.
Each one a quiet, logical whisper that says only one of two things —
True or False.

Welcome to the world of Vyapari Rules.


The Essence of Strategy

At its core, a Strategy is nothing more than a conversation between Rules.

It asks a simple question:

“Do all my conditions agree?”

If the answer is Yes, the Strategy fires — it acts.
If even one condition disagrees, it waits —
quiet, calculating, until the next Bar awakens, and the Rules are tested again.

This cycle repeats endlessly, tick after tick, bar after bar —
the heartbeat of algorithmic trading.


How Rules Work

Vyapari includes a comprehensive library of built-in Rules
to handle virtually any decision-making pattern you can imagine.

Rules operate on Indicators,
which in turn consume Bar Series to generate numerical or boolean values for each Bar.

Then comes the Rule’s moment of truth —
it compares those values and decides.


Example — Crossing the Line

Let’s take a classic example:
you want to detect when the RSI(14) crosses above the 30 level.

That means:

  • On the previous Bar, RSI(14) was below 30
  • On the current Bar, RSI(14) is above 30
    → The condition is True — it crossed above.

In Vyapari, you would use the Crossed Over Rule, configured with two Indicators:

Role Indicator
Comparing Relative Strength Indicator (Close Price, 14)
Comparing With Constant Value Indicator (30.0)

The Rule checks both Bars, compares their values, and returns the verdict — True or False.

Tip "Point. Click. Done."

No code. No syntax.  
Just choose the Rule, select your Indicators, and Vyapari does the rest.

Beyond the Basics

And that’s just the beginning.

Vyapari’s Rule library is rich — logical, mathematical, relational, and temporal comparisons
that let you build Strategies of infinite sophistication, all from simple True/False foundations.

Ready to go deeper?
The entire Rules library, complete with configuration examples and visual guides, awaits you here:
👉 The Rules Section →

Because in Vyapari, decisions are mathematics
and mathematics, when harnessed, becomes profit.