Skip to main content
Skip to main content
Version: Next 🚧

How to Configure Entry Conditions

Problem

You need to define precise rules for when your algorithm should enter trades. Entry conditions determine when buy or sell signals are generated based on technical indicators, price action, and market conditions.

Prerequisites

  • Basic algorithm configuration completed (Step 1)
  • Position sizing configured (Step 2)
  • Understanding of technical indicators
  • Knowledge of your trading strategy

Position Types

Long Positions Only

Use when you only want to buy (bullish strategies).

{
"entryConditions": {
"positionType": "long",
"conditions": [
// Long entry conditions
]
}
}

When to Use:

  • Bull market strategies
  • Momentum trading
  • Breakout strategies
  • Regulatory restrictions on short selling

Short Positions Only

Use when you only want to sell short (bearish strategies).

{
"entryConditions": {
"positionType": "short",
"conditions": [
// Short entry conditions
]
}
}

When to Use:

  • Bear market strategies
  • Mean reversion from overbought
  • Breakdown strategies
  • Hedging strategies

Both Long and Short

Use when you want to trade in both directions.

{
"entryConditions": {
"positionType": "both",
"longConditions": [
// Conditions for long entries
],
"shortConditions": [
// Conditions for short entries
]
}
}

When to Use:

  • Market-neutral strategies
  • Swing trading
  • Trend-following in both directions
  • Maximizing opportunities

Logical Operators

AND Logic (All Conditions Must Be True)

All conditions must be satisfied simultaneously for a signal.

{
"entryConditions": {
"logicalOperator": "AND",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
},
{
"type": "price_indicator",
"priceType": "close",
"comparison": "above",
"indicator": "SMA",
"period": 200
}
]
}
}

Truth Table:

Condition 1Condition 2Result
TrueTrue✅ Signal
TrueFalse❌ No Signal
FalseTrue❌ No Signal
FalseFalse❌ No Signal

When to Use:

  • High-probability setups
  • Reducing false signals
  • Confirmation strategies
  • Conservative trading

OR Logic (At Least One Condition Must Be True)

Any single condition being true generates a signal.

{
"entryConditions": {
"logicalOperator": "OR",
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 20
},
{
"type": "indicator_value",
"indicator": "Stochastic_K",
"period": 14,
"comparison": "below",
"value": 20
}
]
}
}

Truth Table:

Condition 1Condition 2Result
TrueTrue✅ Signal
TrueFalse✅ Signal
FalseTrue✅ Signal
FalseFalse❌ No Signal

When to Use:

  • Multiple entry triggers
  • Increasing trade frequency
  • Diversified signal sources
  • Aggressive trading

Complex Combinations

You can nest conditions for complex logic:

{
"entryConditions": {
"logicalOperator": "AND",
"conditions": [
{
"logicalOperator": "OR",
"conditions": [
{ "indicator": "RSI", "comparison": "below", "value": 30 },
{ "indicator": "Stochastic_K", "comparison": "below", "value": 20 }
]
},
{
"type": "price_indicator",
"priceType": "close",
"comparison": "above",
"indicator": "SMA",
"period": 200
}
]
}
}

Logic: (RSI < 30 OR Stochastic < 20) AND Price > SMA(200)

Comparison Types

1. Indicator vs Value

Compare an indicator to a fixed value.

{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}

Supported Indicators:

  • SMA, EMA, WMA (Moving Averages)
  • RSI (Relative Strength Index)
  • MACD, MACD_Signal, MACD_Histogram
  • Bollinger_Upper, Bollinger_Middle, Bollinger_Lower
  • Stochastic_K, Stochastic_D
  • ATR (Average True Range)
  • ADX (Average Directional Index)
  • Volume

Comparison Operators:

  • above: Indicator > Value
  • below: Indicator < Value
  • equals: Indicator = Value
  • greater_than_equal: Indicator >= Value
  • less_than_equal: Indicator <= Value

Examples:

// RSI oversold
{
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
}

// MACD histogram positive
{
"indicator": "MACD_Histogram",
"comparison": "above",
"value": 0
}

// ADX strong trend
{
"indicator": "ADX",
"period": 14,
"comparison": "above",
"value": 25
}

// High volume
{
"indicator": "Volume",
"comparison": "above",
"value": 1000000
}

2. Indicator vs Indicator

Compare two indicators to each other.

{
"type": "indicator_indicator",
"indicator1": "SMA",
"period1": 20,
"comparison": "crosses_above",
"indicator2": "SMA",
"period2": 50
}

Comparison Operators:

  • above: Indicator1 > Indicator2
  • below: Indicator1 < Indicator2
  • crosses_above: Indicator1 crosses above Indicator2
  • crosses_below: Indicator1 crosses below Indicator2

Cross Detection: Crosses require the previous candle to be on the opposite side:

  • Crosses Above: Previous: Ind1 <= Ind2, Current: Ind1 > Ind2
  • Crosses Below: Previous: Ind1 >= Ind2, Current: Ind1 < Ind2

Examples:

// Golden Cross (bullish)
{
"indicator1": "SMA",
"period1": 50,
"comparison": "crosses_above",
"indicator2": "SMA",
"period2": 200
}

// MACD bullish crossover
{
"indicator1": "MACD",
"comparison": "crosses_above",
"indicator2": "MACD_Signal"
}

// Fast EMA above slow EMA
{
"indicator1": "EMA",
"period1": 9,
"comparison": "above",
"indicator2": "EMA",
"period2": 21
}

// Stochastic crossover
{
"indicator1": "Stochastic_K",
"comparison": "crosses_above",
"indicator2": "Stochastic_D"
}

3. Price vs Indicator

Compare price to an indicator value.

{
"type": "price_indicator",
"priceType": "close",
"comparison": "above",
"indicator": "SMA",
"period": 50
}

Price Types:

  • open: Opening price
  • high: Highest price
  • low: Lowest price
  • close: Closing price

Examples:

// Price above moving average (bullish)
{
"priceType": "close",
"comparison": "above",
"indicator": "SMA",
"period": 200
}

// Price crosses above Bollinger lower band
{
"priceType": "close",
"comparison": "crosses_above",
"indicator": "Bollinger_Lower",
"period": 20
}

// High touches Bollinger upper band
{
"priceType": "high",
"comparison": "above",
"indicator": "Bollinger_Upper",
"period": 20
}

// Low above EMA (support)
{
"priceType": "low",
"comparison": "above",
"indicator": "EMA",
"period": 20
}

Confirmation Candles

Confirmation candles reduce false signals by requiring conditions to remain true for multiple candles.

{
"entryConditions": {
"confirmationCandles": 2,
"conditions": [
// Conditions must be true for 2 consecutive candles
]
}
}

How It Works

0 Candles (No Confirmation):

  • Signal generated immediately when conditions are met
  • Fastest entry, but more false signals

1 Candle:

  • Conditions must be true for current candle
  • Wait for candle to close before entering

2 Candles:

  • Conditions must be true for 2 consecutive candles
  • More reliable, but slower entry

3+ Candles:

  • Very conservative
  • May miss quick moves

Examples

No Confirmation (0):

{
"confirmationCandles": 0,
"conditions": [
{ "indicator": "RSI", "comparison": "below", "value": 30 }
]
}
  • RSI drops below 30 → Immediate signal

1 Candle Confirmation:

{
"confirmationCandles": 1,
"conditions": [
{ "indicator": "RSI", "comparison": "below", "value": 30 }
]
}
  • RSI below 30 at candle close → Signal next candle

2 Candle Confirmation:

{
"confirmationCandles": 2,
"conditions": [
{ "indicator": "RSI", "comparison": "below", "value": 30 }
]
}
  • RSI below 30 for 2 consecutive candles → Signal

Trade-offs

ConfirmationSpeedReliabilityUse Case
0 candles⚡⚡⚡Scalping, quick moves
1 candle⚡⚡⭐⭐Day trading
2 candles⭐⭐⭐Swing trading
3+ candles🐌⭐⭐⭐⭐Position trading

Time Filters

Restrict trading to specific times and days.

Trading Hours

{
"entryConditions": {
"timeFilters": {
"enabled": true,
"tradingHours": {
"start": "09:30",
"end": "15:00"
}
}
}
}

Examples:

// NSE regular session
{
"tradingHours": {
"start": "09:15",
"end": "15:30"
}
}

// Avoid first hour (volatility)
{
"tradingHours": {
"start": "10:15",
"end": "15:30"
}
}

// Morning session only
{
"tradingHours": {
"start": "09:15",
"end": "12:00"
}
}

// MCX evening session
{
"tradingHours": {
"start": "17:00",
"end": "23:30"
}
}

Trading Days

{
"entryConditions": {
"timeFilters": {
"enabled": true,
"tradingDays": ["monday", "tuesday", "wednesday", "thursday", "friday"]
}
}
}

Examples:

// Weekdays only (no weekends)
{
"tradingDays": ["monday", "tuesday", "wednesday", "thursday", "friday"]
}

// Mid-week only (avoid Monday/Friday)
{
"tradingDays": ["tuesday", "wednesday", "thursday"]
}

// Specific days
{
"tradingDays": ["monday", "wednesday", "friday"]
}

Market Sessions

Pre-Market (NSE):

{
"tradingHours": {
"start": "09:00",
"end": "09:15"
}
}

Regular Session (NSE):

{
"tradingHours": {
"start": "09:15",
"end": "15:30"
}
}

Post-Close (NSE):

{
"tradingHours": {
"start": "15:40",
"end": "16:00"
}
}

Timezone Handling

All times are in Indian Standard Time (IST) by default.

{
"timeFilters": {
"timezone": "Asia/Kolkata"
}
}

Re-Entry Settings

Control how quickly the algorithm can re-enter after exiting a position.

Cooldown Period

{
"entryConditions": {
"reEntry": {
"enabled": true,
"cooldownMinutes": 30
}
}
}

Examples:

// 15-minute cooldown (scalping)
{
"cooldownMinutes": 15
}

// 1-hour cooldown (day trading)
{
"cooldownMinutes": 60
}

// 1-day cooldown (swing trading)
{
"cooldownMinutes": 1440
}

Maximum Re-Entries

{
"entryConditions": {
"reEntry": {
"enabled": true,
"maxReEntries": 3
}
}
}

Prevents Overtrading:

  • 0: No re-entries (one trade per symbol per day)
  • 1-3: Limited re-entries (conservative)
  • 4-10: Multiple re-entries (aggressive)

Combined Example

{
"reEntry": {
"enabled": true,
"cooldownMinutes": 30,
"maxReEntries": 3
}
}

This allows up to 3 re-entries with a 30-minute cooldown between each.

Complete Entry Condition Examples

Example 1: RSI Oversold with Trend Confirmation

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"confirmationCandles": 1,
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 30
},
{
"type": "price_indicator",
"priceType": "close",
"comparison": "above",
"indicator": "SMA",
"period": 200
}
],
"timeFilters": {
"enabled": true,
"tradingHours": {
"start": "09:30",
"end": "15:00"
},
"tradingDays": ["monday", "tuesday", "wednesday", "thursday", "friday"]
}
}
}

Logic: Buy when RSI < 30 AND price > 200 SMA, confirmed for 1 candle, during market hours.

Example 2: Moving Average Crossover

{
"entryConditions": {
"positionType": "both",
"longConditions": [
{
"type": "indicator_indicator",
"indicator1": "SMA",
"period1": 20,
"comparison": "crosses_above",
"indicator2": "SMA",
"period2": 50
}
],
"shortConditions": [
{
"type": "indicator_indicator",
"indicator1": "SMA",
"period1": 20,
"comparison": "crosses_below",
"indicator2": "SMA",
"period2": 50
}
],
"confirmationCandles": 0
}
}

Logic: Buy on golden cross, sell on death cross, no confirmation.

Example 3: Multiple Indicator Confirmation

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "AND",
"confirmationCandles": 2,
"conditions": [
{
"type": "indicator_value",
"indicator": "RSI",
"period": 14,
"comparison": "below",
"value": 40
},
{
"type": "indicator_indicator",
"indicator1": "MACD",
"comparison": "above",
"indicator2": "MACD_Signal"
},
{
"type": "price_indicator",
"priceType": "close",
"comparison": "above",
"indicator": "EMA",
"period": 50
},
{
"type": "indicator_value",
"indicator": "ADX",
"period": 14,
"comparison": "above",
"value": 25
}
]
}
}

Logic: Buy when RSI < 40 AND MACD bullish AND price > EMA(50) AND ADX > 25, confirmed for 2 candles.

Example 4: Bollinger Band Bounce

{
"entryConditions": {
"positionType": "long",
"logicalOperator": "OR",
"confirmationCandles": 1,
"conditions": [
{
"type": "price_indicator",
"priceType": "low",
"comparison": "below",
"indicator": "Bollinger_Lower",
"period": 20
},
{
"type": "price_indicator",
"priceType": "close",
"comparison": "crosses_above",
"indicator": "Bollinger_Lower",
"period": 20
}
],
"reEntry": {
"enabled": true,
"cooldownMinutes": 60,
"maxReEntries": 2
}
}
}

Logic: Buy when price touches or crosses above lower Bollinger Band, max 2 re-entries with 1-hour cooldown.

Verification

After configuring entry conditions, verify:

  1. Logic is correct

    • Test with historical data
    • Ensure conditions align with strategy
  2. Confirmation is appropriate

    • Balance speed vs reliability
    • Match to timeframe and style
  3. Time filters are set

    • Avoid pre-market/after-hours if needed
    • Consider market volatility patterns
  4. Re-entry settings prevent overtrading

    • Cooldown is reasonable
    • Max re-entries is conservative

Troubleshooting

No Signals Generated

Problem: Algorithm never enters trades.

Solutions:

  1. Check if conditions are too strict (use OR instead of AND)
  2. Reduce confirmation candles
  3. Verify time filters aren't blocking all hours
  4. Check indicator values are realistic

Too Many Signals

Problem: Algorithm enters too frequently.

Solutions:

  1. Add more conditions (use AND logic)
  2. Increase confirmation candles
  3. Add time filters
  4. Implement re-entry cooldown

Signals Too Late

Problem: Entries happen after the move.

Solutions:

  1. Reduce confirmation candles
  2. Use faster indicators (shorter periods)
  3. Remove unnecessary conditions
  4. Consider leading indicators

Crossover Not Detecting

Problem: Indicator crossovers don't trigger.

Solutions:

  1. Verify previous candle data is available
  2. Check indicator calculations are correct
  3. Use above/below instead of crosses_above/crosses_below for testing
  4. Ensure sufficient historical data