Algos C# Scripts

AntoQQE Modern Plus is an extended signal engine

This is a signal system — an indicator that essentially functions as a trading system signal engine.

All the signals you see on the chart and receive can be used and are available for your trading systems.

By adjusting the settings, you can tailor the signals to your specific chart type.

Be careful: Renko settings must differ in order to produce high-quality signals. Everything is described in detail in the documentation. Study the documentation. I am waiting for your feedback.

there's a new updated version just released with improvements:

  • The old ATR filter (fixed tick threshold, hard to calibrate) was replaced with an ATR Ratio filter — compares current ATR vs its own long-term average, works universally across ES/NQ/CL and any timeframe without manual tuning

  • Memory leak fix in swing detection (O(1) instead of growing HashSet)


    # AntoQQE Modern Plus — Technical Reference

Type: Overlay Indicator | Platform: Tickblaze | No-repaint: Yes

---

## Overview

AntoQQE Modern Plus is an extended signal engine built on top of AntoQQE Modern. It uses QQE (Quantitative Qualitative Estimation) as the core directional engine, layered with up to 6 configurable filters. Beyond visual arrows, it outputs ATR-based stop and target price levels readable by external strategies.

---

## Signal Logic

Base signal — QQE flip (no-repaint):

```

Long signal: QQE trend flipped to +1 on bar [i−1] (was not +1 on [i−2])

Short signal: QQE trend flipped to −1 on bar [i−1]

```

All filter checks use Close[i−1] and confirmed closed bars only. The signal never changes after the bar closes.

---

## Filter Chain

Filters are applied in sequence. Any single failure blocks the signal.

### Filter 1 — MTF EMA Direction + Buffer (always active)

Requires price to be on the correct side of the higher-timeframe EMA with a configurable dead zone:

```

Long: Close[i−1] > EMA(TrendTimeframe, TrendEmaPeriod) + Buffer

Short: Close[i−1] < EMA(TrendTimeframe, TrendEmaPeriod) − Buffer

```

### Filter 2 — MTF EMA Slope (optional)

Requires the higher-timeframe EMA to be actively moving in the signal direction:

```

Long: EMA[now] > EMA[prev] + SlopeMin ticks

Short: EMA[now] < EMA[prev] − SlopeMin ticks

```

### Filter 3 — Swing Structure (optional)

Tracks confirmed swing highs and lows on the current chart. Requires micro-trend structure to align with the signal direction:

```

Long: last confirmed swing high = HH AND last confirmed swing low = HL

Short: last confirmed swing high = LH AND last confirmed swing low = LL

```

Bypassed automatically until at least 2 swings of each type are observed (early-bar safety). Swing confirmed after SwingStrength bars on both sides — no repaint.

### Filter 4 — Momentum Trigger (optional)

Requires short-term momentum to confirm direction:

```

Long: Close[i−1] > Close[i−1−MomentumBars]

Short: Close[i−1] < Close[i−1−MomentumBars]

```

> ⚠ Not effective on Renko charts — every Renko brick is already a directional breakout. Use on time-based charts only.

### Filter 5 — ATR Regime (optional)

Skips signals when the market is compressed or inactive:

```

Signal blocked if: ATR(AtrPeriod)[i−1] < AtrMinTicks × TickSize

```

### Filter 6 — Cooldown (optional)

Enforces a minimum gap between consecutive signals. Prevents cluster entries in fast-moving conditions:

```

Signal blocked if: (current bar − last signal bar) < CooldownBars

Set CooldownBars = 0 to disable.

```

---

## Risk Output Plots

When a signal fires, two hidden plots are populated for strategy consumption:

| Plot | Value | Description |

|---|---|---|

| StopPrice | Close[i−1] ± ATR × StopAtrMultiple | Absolute stop level |

| TargetPrice | Entry ± StopDist × RiskRewardRatio | Absolute target level |

Both plots output NaN when there is no signal. Entry reference is always Close[i−1] (the QQE flip bar).

Strategy usage:

```csharp

double sig = _ind.Signal[index]; // 1 / -1 / 0

double stop = _ind.StopPrice[index]; // absolute price

double target = _ind.TargetPrice[index]; // absolute price

```

---

## Visual Plots

| Plot | Visible | Description |

|---|---|---|

| Arrows (OnRender) | Yes | Up arrow = long signal, down arrow = short signal |

| MTF EMA | Yes | Higher-timeframe EMA line |

| Upper / Lower Band | Yes | EMA ± buffer zone (dead zone boundary) |

| Signal | Hidden | Numeric signal value for strategy reading |

| StopPrice | Hidden | ATR-based stop level |

| TargetPrice | Hidden | ATR-based target level |

---

## Parameters

| Parameter | Default | Description |

|---|---|---|

| RSI Period | 14 | QQE base RSI period |

| SF | 5 | RSI smoothing factor |

| QQE Factor | 4.238 | QQE trailing band multiplier |

| Trend Timeframe (min) | 5 | Higher timeframe for EMA filter |

| Trend EMA Period | 50 | EMA period on the trend timeframe |

| Buffer (ticks) | 5 | Dead zone half-width around EMA |

| Use Slope Filter | true | Enable MTF EMA slope requirement |

| Slope Min (ticks) | 1 | Minimum EMA move per bar to qualify |

| Use Swing Filter | true | Enable swing structure requirement |

| Swing Strength | 2 | Bars each side for swing confirmation |

| Use Momentum Trigger | false | Enable momentum gate |

| Momentum Bars | 3 | Lookback for momentum comparison |

| Use ATR Filter | false | Enable ATR minimum regime filter |

| ATR Period | 14 | ATR lookback period |

| ATR Min (ticks) | 10 | Minimum ATR to allow entry |

| Cooldown Bars | 0 | Minimum bars between signals (0 = off) |

| Stop ATR Multiple | 1.5 | Stop distance = ATR × this |

| Risk/Reward Ratio | 2.0 | Target = stop distance × this |

---

## Chart Type Guide

The right filter combination depends on the chart type. Some filters are effective on Renko, others only make sense on time-based charts.

### Renko Charts (OpenProRenko, BetterRenko)

| Filter | Use | Notes |

|---|---|---|

| MTF EMA + Buffer | ✅ Always | Core filter, works on any chart type |

| Slope Filter | ✅ Recommended | EMA slope is meaningful on Renko |

| Swing Filter | ✅ Recommended | SwingStrength=2 works cleanly — Renko removes noise, swing points are clear |

| Momentum Trigger | ❌ Do not use | Every up-brick closes above the previous high by definition. The trigger is always true and adds nothing |

| ATR Filter | ⚠ Optional | ATR on Renko is relatively stable (brick size is fixed). Only useful to filter low-activity periods |

| Cooldown | ✅ Useful | Prevents re-entry on rapid consecutive bricks after a strong move |

Recommended Renko setup:

```

Use Slope Filter: true

Use Swing Filter: true (SwingStrength = 2)

Use Momentum Trigger: false

Use ATR Filter: false

Cooldown Bars: 3–5

```

---

### Minute / Time-Based Charts (1m, 5m, 15m, etc.)

| Filter | Use | Notes |

|---|---|---|

| MTF EMA + Buffer | ✅ Always | Core filter, works on any chart type |

| Slope Filter | ✅ Recommended | Filters flat EMA periods common on time-based charts |

| Swing Filter | ✅ Optional | Increase SwingStrength to 3 — minute charts are noisier, small swings are less reliable |

| Momentum Trigger | ✅ Useful | Close[i−1] > Close[i−1−N] is meaningful on time bars — price direction over N candles is a real signal |

| ATR Filter | ✅ Recommended | Very useful to block overnight/pre-market dead hours when ATR drops sharply |

| Cooldown | ✅ Useful | Prevents cluster signals during volatile news bars |

Recommended minute chart setup:

```

Use Slope Filter: true

Use Swing Filter: optional (SwingStrength = 3)

Use Momentum Trigger: true (MomentumBars = 3–5)

Use ATR Filter: true (AtrMinTicks = instrument-specific)

Cooldown Bars: 5–10

```

> Note: Do not enable Swing Filter and Momentum Trigger simultaneously as a starting point — each individually reduces signal count significantly. Add one, validate, then consider adding the second.

---

## Recommended Usage

Start with all optional filters off and compare signal frequency to AntoQQE Classic. Enable filters one at a time to understand the impact of each:

1. Enable Slope Filter → observe reduction in counter-trend noise

2. Enable Swing Filter → observe structural quality improvement

3. Enable Momentum Trigger (time-based charts only) → observe timing refinement

Running all filters simultaneously will produce very few signals. Recommended approach: use 2 filters maximum for normal trading, add a third only after validating on sufficient history.

Another Breakthrough

I got the example c# files for MACrossover Strategy to compile and install into TickBlaze just as the indicators did and Basically by following the same instructions. I changed the name of MACrossover.cs to MyMACrossover.cs and added the crossoverbase and stops and targets files to my repos directory with the rest of the project files. It compiled with three warnings but runs fine and optimized on a tick profit and stop.

the only changes I made were to rename the MACrossover.cs file to MyMACrossover.cs and accept the visualstudio offer to rename the class. In the constructor MACrossover() which was renamed MyMACrossover() I also changed the string to Name= "MyMACrossover" in order that Tickblaze shows my compiled version with a different name than the original.

One of the next challenges will be to add optimizable time parameters.

I am doing this because I cannot afford to pay for the prebuilt algos and I was dubious about their efficacy. I did purchase SpringBoard because of a big discount deal and it is one that has a published AMA that I watched and was interested in. but have not spent a lot of time with it yet. I really need a new computer. I do not know if the glitches I run into are Tickblazebugs, script bugs or my 10 year old computer.

My untrained eye says that these scripts, indicators and algos are well written. I am growing to like TickBlaze. My main experience is with Ninja. I am specking out a new computer, intel ultra7 265 with 32gb ram. Trying to figure out if I can use my old case and 750 watt power supply. Not sure the cables will fit the new motherboard and a new cable set is almost as much as a new power supply. Bought before from NewEgg but they have a few bad reviews lately. Any ideas would be appreciated.

Still trying to understand the example c# code examples.

So, the strategy files do not have trade initiation logic but there is a separate file that does, CrossoverStrategyBase.cs. Also no risk management part but there is BaseStopsAndTargetsStrategy.cs. I am guessing that there is a way to compile these with for example MaCrossover.cs and produce a working strategy with optimizable stops and targets.

I am thinking that these separate files are a technique to reuse code and compartmentalize logic. I am not a programmer.

Also, it is a mystery to me how when I compile my .dll, my tickblaze platform knows about it and the indicator or strategy is there ready to go to work. I am guessing that somehow my .dll gets incorporated into the main tickblaze .dll. Also guessing that the only one who can see the source for my indicator is me or anyone I give the source to.

Sean has mentioned sharing the code to some items, VMLean for example but I do not see that any where.

Anyway, I think that if I figure out how to put these files together in VS, I will not have any problem coding indicators and strategies, using the example files for my education.

It would be nice if there was a document explaining the available tickblase functions. I am guessing that perhaps because tickblase is in beta they might not be up for spending time on that because things might change?

I am putting this out here in case anyone else is traveling a similar path or even better already knows the answer for how to tell VS to put these files together.

I am pretty sure that I could just cut and paste them into one file but that would short circuit the engineering advantage that I assume is the reason for their separation.

MyMACrossover script

most example algo/strategy scripts that I see in the community do not have source code that includes trading logic. as far as I have found... Also, the one or two I have found do not access the big algo engine so I am guessing that that is always going to be proprietary and if any of us want to use Tickblaze for developing our own strategies then we will need to write our own. I do not know that Tickblaze will be best pleased by this effort but here goes. I hacked the existing samples to produce an MACrossover that works and is optimizable. It is my intent to add optimizable parameters to see if it is possible to replicate or even improve the TickBlaze "AlgoCore." Not that it is really pertinent but the strategy when optimised gave an $10,000 profit and $5000 drawdown Profit factor 1.36 when run on YM 5 min, 1 lot, from 1 dec, 2025 to today.

optimised only on stop and target and that result was 20 tick profit target and 150 tick stop.

MtMACrossTest.JPG
160.15KB

the strategy file is enclosed.

One Problem I have been having is downloading data that works, coudn't get MYM to test on the full range. downloaded complete data in Tickblaze/tools/dataWarehouse. probably not doing it correctly

Planning on testing the same in Ninjatrader and comparing.

1

OnRender not called

Hello,

I'm trying to do a new strategy and just would like to test the following code (it's the code from documentation to have a custom rendering on a strategy) :
namespace Tickblaze.Scripts.Strategies;

public class ClosePriceLine : Strategy

{

[Parameter("Line Color", Description = "Color of the custom line")]

public Color LineColor { get; set; } = Color.Blue;

[Parameter("Line Thickness", Description = "Thickness of the custom line"), NumericRange(1)]

public int LineThickness { get; set; } = 2;

[Parameter("Line Style", Description = "Style of the custom line")]

public LineStyle LineStyle { get; set; } = LineStyle.Solid;

public override void OnRender(IDrawingContext context)

{

var points = new List<Point>();

for (var barIndex = Chart.FirstVisibleBarIndex; barIndex <= Chart.LastVisibleBarIndex; barIndex++)

{

var point = new Point()

{

X = Chart.GetXCoordinateByBarIndex(barIndex),

Y = ChartScale.GetYCoordinateByValue(Bars[barIndex].Close)

};

points.Add(point);

}

context.DrawPolygon(points, null, LineColor, LineThickness, LineStyle);

}

}

I'm in debug with Visual studio. Everything works fine with other methods (like OnBar) but when launching the strategy ahead with the Replay engine I can't have the debug to enter in the OnRender method...Do you know what is happening ?

Best regards
HPI

2

Algos - SpringBoard & Sweeper

Algos - SpringBoard & Sweeper

It would be nice, traders helping traders, with a discussion and share thread of results, settings, experiences and hoorah stories using either of these two algos.

ok, who would like to go first or at least kick off the share thread.

let's start with these data analytic basics

a) if you could state the date range and basic settings (whatever you feel comfortable sharing) this would help with the credibility so that one could first try to recreate the posted chart results and then improve from there

b) share advice on what worked, traps, flaws, etcetera. keep in mind this is a global audience, and while we are US centric, especially for CME products and EST & CST oriented, posting what UTC you're based on or your shared charts are based on would also help reduce the '20 questions' syndrome that results with cryptic replies

with that being said, let the games begin.

PS. If the house (TickBlaze) would contribute the AMA scripts that were posted here, it would be easier to access (instead of searching through so many comments), that might get this thread going

4

Mean Reversion Short Strategy Using RSI on NG Daily Charts.

Some financial instruments exhibit distinct market tendencies based on their inherent characteristics and trading behavior. For instance, the E-mini S&P 500 (ES) typically demonstrates a long side mean reversion tendency, meaning that after significant deviations from its average price, it tends to revert over an extended period. In contrast, Natural Gas (NG) has a short side mean reversion tendency, where price deviations correct themselves relatively quickly.

This strategy is a simple mean reversion short strategy applied to Natural Gas (NG), utilizing the Relative Strength Index (RSI) indicator as the primary trading signal. The core idea is to identify overbought conditions in the market where NG is likely to revert downward, and then execute short trades accordingly.

Strategy Overview

  • The strategy does not incorporate any additional filters or risk management layers; it is purely for educational purposes to illustrate the fundamental concept of mean reversion trading.

  • It demonstrates how to enter and exit trades based on the RSI indicator signals.

  • In addition to RSI-based exits, the strategy also includes an exit mechanism based on a predefined number of bars, ensuring that trades do not overstay in the market beyond a certain threshold.

This strategy serves as a basic framework for understanding mean reversion trading in NG and can be further refined by incorporating additional indicators, volatility filters, or risk management rules to enhance performance in real trading environments.

namespace CC.Strategies.ShortRSIMeanReversionStrategy;

using Tickblaze.Scripts.Indicators;

public class ShortRSIMeanReversionStrategy : Strategy
{
	[NumericRange(2, 10)]
	[Parameter("RSI Entry Period")]
	public int RsiEntryPeriod { get; set; } = 3;
	
	[NumericRange(2, 10)]
	[Parameter("RSI Exit Period")]
	public int RsiExitPeriod { get; set; } = 2;

	[NumericRange(60, 90)]
	[Parameter("RSI Entry Level")]
	public int RsiEntryValue { get; set; } = 90;

	[NumericRange(10, 40)]
	[Parameter("RSI Exit Level")]
	public int RsiExitValue { get; set; } = 30;

	[NumericRange(0, 20)]
	[Parameter("Exit - Number of bars")]
	public int ExitNumberOfBars { get; set; } = 5;
	
	[NumericRange(0, 1000)]
	[Parameter("Position size")]
	public int PositionSize { get; set; } = 1;

	private RelativeStrengthIndex _rsi_entry;
	private RelativeStrengthIndex _rsi_exit;
	private int _entryIndex;

	public ShortRSIMeanReversionStrategy()
	{
		Name = "Short RSI Mean Reversion Strategy";
		ShortName = "CC.SRSIMR";
		Description = "A mean reversion strategy based on the Relative Strength Index (RSI) generating a short signal when the RSI rises above the entry level and exiting when it falls below the exit level or after number of the bars.";
	}

	protected override void Initialize()
	{
		_rsi_entry = new RelativeStrengthIndex(Bars.Close, RsiEntryPeriod, MovingAverageType.Simple, 1);
		_rsi_exit = new RelativeStrengthIndex(Bars.Close, RsiExitPeriod, MovingAverageType.Simple, 1);
		_rsi_entry.Result.Color = Color.Blue;
		_rsi_exit.Result.Color = Color.Cyan;
		_rsi_entry.Average.IsVisible = false;
		_rsi_exit.Average.IsVisible = false;
		_rsi_entry.OverboughtLevel.Value = RsiEntryValue;
		_rsi_entry.OversoldLevel.Value = RsiExitValue;
		_rsi_exit.OverboughtLevel.Value = RsiEntryValue;
		_rsi_exit.OversoldLevel.Value = RsiExitValue;		
		_rsi_entry.ShowOnChart = true;
		_rsi_exit.ShowOnChart = true;
	}
	
	protected override void OnBar(int index)
	{
		if (index == 0)
		{
			return;
		}

		var rsi_entry = new[] { _rsi_entry.Result[index], _rsi_entry.Result[index - 1] };
		var rsi_exit = new[] { _rsi_exit.Result[index], _rsi_exit.Result[index - 1] };
		
		if (Position?.Direction is OrderDirection.Short && _entryIndex > 0)
		{
			_entryIndex--;
		}
		
		if (rsi_entry[1] <= RsiEntryValue && RsiEntryValue < rsi_entry[0])
		{
			EnterMarket(OrderDirection.Short, "Short RSI Mean Reversion");
		} else 
		if (rsi_exit[1] >= RsiExitValue && RsiExitValue > rsi_exit[0])
		{
			if (Position?.Direction is OrderDirection.Short)
			{
				ClosePosition("Exit RSI Mean Reversion");
				_entryIndex = 0;
			}
		} else 
		if (Position?.Direction is OrderDirection.Short && _entryIndex == 0)
		{
			ClosePosition("Exit RSI Mean Reversion Bars");
		}
	}

	private void EnterMarket(OrderDirection direction, string comment = "")
	{
		if (Position?.Direction == direction)
		{
			return;
		}
		
		_entryIndex = ExitNumberOfBars;

		var price = Bars.Close[^1];
		var action = direction is OrderDirection.Long ? OrderAction.Buy : OrderAction.SellShort;
		var exitMultiplier = direction is OrderDirection.Long ? 1 : -1;
		var quantity = PositionSize;
		var marketOrder = ExecuteMarketOrder(action, quantity, TimeInForce.Day, comment);
	}
}
10

Mean Reversion Long Strategy Using RSI on MES Daily Charts. (Update Feb.17.2025 for 2.0.0.50-RC.419)

Overview of the Strategy

This is a straightforward mean reversion long strategy implemented on the Micro E-mini S&P 500 futures (MES), utilizing the Relative Strength Index (RSI) as the primary indicator for trade signals. The strategy is designed to capitalize on short-term price movements when the market becomes oversold, expecting a potential bounce or reversion to the mean.

Purpose and Scope

The primary objective of this strategy is to serve as an educational example rather than a fully optimized trading system. It is intended to demonstrate the basic principles of constructing a mean reversion strategy and provide insights into how trades can be systematically entered and exited based on RSI signals.

Key Features of the Strategy

  1. Indicator-Based Entry

    • The RSI indicator is used to identify oversold conditions, which may indicate a potential reversal or short-term price recovery.

    • A long position is initiated when the RSI value falls below a predefined threshold, such as 30, signaling an oversold market.

  2. Exit Rules

    • The position is exited when the RSI returns to a higher level, indicating that the price has potentially reverted to the mean or shown sufficient recovery.

    • Additionally, the strategy includes a time-based exit, closing the position after a predetermined number of bars, regardless of price action. This ensures the trade does not linger indefinitely and aligns with short-term trading principles.

Simplicity and No Additional Filters

To maintain simplicity and focus on educational value, this strategy does not incorporate additional filters such as trend confirmation, volatility bands, or multi-timeframe analysis. It is intentionally kept basic to illustrate the core mechanics of mean reversion trading.

Educational Focus

The strategy is ideal for traders who are new to algorithmic or systematic trading and wish to understand how to:

  • Implement entry and exit conditions using technical indicators.

  • Apply risk management through predefined exits.

  • Test and analyze the performance of a simple trading rule before exploring more complex approaches.

Conclusion

While this example highlights the foundational concepts of mean reversion trading using RSI, traders are encouraged to expand upon it by adding enhancements like dynamic stop-loss levels, profit targets, or additional indicators to refine entry and exit signals. The provided framework is an excellent starting point for experimenting with trading ideas and learning the process of strategy development.

using Tickblaze.Scripts.Indicators;

namespace CC.Strategies.LongRSIMeanReversionStrategy;

public class LongRSIMeanReversionStrategy : Strategy
{
	[NumericRange(2, 10)]
	[Parameter("RSI Entry Period")]
	public int RsiEntryPeriod { get; set; } = 2;
	
	[NumericRange(2, 10)]
	[Parameter("RSI Exit Period")]
	public int RsiExitPeriod { get; set; } = 4;

	[NumericRange(60, 90)]
	[Parameter("RSI Exit Level")]
	public int RsiExitValue { get; set; } = 70;

	[NumericRange(10, 40)]
	[Parameter("RSI Entry Level")]
	public int RsiEntryValue { get; set; } = 25;

	[NumericRange(0, 20)]
	[Parameter("Exit - Number of bars")]
	public int ExitNumberOfBars { get; set; } = 6;
	
	[NumericRange(0, 1000)]
	[Parameter("Position size")]
	public int PositionSize { get; set; } = 1;

	private RelativeStrengthIndex _rsi_entry;
	private RelativeStrengthIndex _rsi_exit;
	private int _entryIndex;

	public LongRSIMeanReversionStrategy()
	{
		Name = "Long RSI Mean Reversion Strategy";
		ShortName = "CC.LRSIMR";
		Description = "A mean reversion strategy based on the Relative Strength Index (RSI) generating a long signal when the RSI falls below the entry level and exiting when it rises above the exit level or after number of the bars.";
	}

	protected override void Initialize()
	{
		_rsi_entry = new RelativeStrengthIndex(Bars.Close, RsiEntryPeriod, MovingAverageType.Simple, 1);
		_rsi_exit = new RelativeStrengthIndex(Bars.Close, RsiExitPeriod, MovingAverageType.Simple, 1);
		_rsi_entry.Result.Color = Color.Blue;
		_rsi_exit.Result.Color = Color.Cyan;
		_rsi_entry.Average.IsVisible = false;
		_rsi_exit.Average.IsVisible = false;
		_rsi_entry.OverboughtLevel.Value = RsiExitValue;
		_rsi_entry.OversoldLevel.Value = RsiEntryValue;
		_rsi_exit.OverboughtLevel.Value = RsiExitValue;
		_rsi_exit.OversoldLevel.Value = RsiEntryValue;		
		_rsi_entry.ShowOnChart = true;
		_rsi_exit.ShowOnChart = true;
	}
	
	protected override void OnBar(int index)
	{
		if (index == 0)
		{
			return;
		}

		var rsi_entry = new[] { _rsi_entry.Result[index], _rsi_entry.Result[index - 1] };
		var rsi_exit = new[] { _rsi_exit.Result[index], _rsi_exit.Result[index - 1] };
		
		if (Position?.Direction is OrderDirection.Long && _entryIndex > 0)
		{
			_entryIndex--;
		}
		
		if (rsi_entry[1] >= RsiEntryValue && RsiEntryValue > rsi_entry[0])
		{
			EnterMarket(OrderDirection.Long, "Long RSI Mean Reversion");
		} else 
		if (rsi_exit[1] <= RsiExitValue && RsiExitValue < rsi_exit[0])
		{
			if (Position?.Direction is OrderDirection.Long)
			{
				ClosePosition("Exit RSI Mean Reversion");
				_entryIndex = 0;
			}
		} else 
		if (Position?.Direction is OrderDirection.Long && _entryIndex == 0)
		{
			ClosePosition("Exit RSI Mean Reversion Bars");
		}
	}

	private void EnterMarket(OrderDirection direction, string comment = "")
	{
		if (Position?.Direction == direction)
		{
			return;
		}
		
		_entryIndex = ExitNumberOfBars;

		var price = Bars.Close[^1];
		var action = direction is OrderDirection.Long ? OrderAction.Buy : OrderAction.SellShort;
		var exitMultiplier = direction is OrderDirection.Long ? 1 : -1;
		var quantity = PositionSize;
		var marketOrder = ExecuteMarketOrder(action, quantity, TimeInForce.Day, comment);
	}
}