Advertisement IC Markets

Equity Curve Versus R-Curve: Two Views of the Same Account

Document your personal trading journey. Track daily equity curves, review winning and losing streaks, share trade screenshots, and get constructive feedback.
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Equity Curve Versus R-Curve: Two Views of the Same Account

Post by PTScalper »

Here it is Ctrader version:

Code: Select all

using System;
using cAlgo.API;
using cAlgo.API.Internals;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class LiquiditySweep : Indicator
    {
        [Parameter("Pivot Left Bars", DefaultValue = 5)]
        public int LeftBars { get; set; }

        [Parameter("Pivot Right Bars", DefaultValue = 5)]
        public int RightBars { get; set; }

        private double _lastHigh = double.NaN;
        private double _lastLow = double.NaN;
        private int _lastHighIndex;
        private int _lastLowIndex;

        public override void Calculate(int index)
        {
            // Wait until we have enough bars to form a pivot
            if (index < LeftBars + RightBars)
                return;

            int pivotIndex = index - RightBars;

            // 1. Identify Pivot High
            bool isPivotHigh = true;
            for (int i = pivotIndex - LeftBars; i <= index; i++)
            {
                if (i == pivotIndex) continue;
                if (Bars.High[i] >= Bars.High[pivotIndex])
                {
                    isPivotHigh = false;
                    break;
                }
            }

            if (isPivotHigh)
            {
                _lastHigh = Bars.High[pivotIndex];
                _lastHighIndex = pivotIndex;
            }

            // 2. Identify Pivot Low
            bool isPivotLow = true;
            for (int i = pivotIndex - LeftBars; i <= index; i++)
            {
                if (i == pivotIndex) continue;
                if (Bars.Low[i] <= Bars.Low[pivotIndex])
                {
                    isPivotLow = false;
                    break;
                }
            }

            if (isPivotLow)
            {
                _lastLow = Bars.Low[pivotIndex];
                _lastLowIndex = pivotIndex;
            }

            // 3. Draw and dynamically extend structural lines
            if (!double.IsNaN(_lastHigh))
            {
                // Using a static name "ResLine" automatically updates/extends the existing line on each tick
                var resLine = Chart.DrawTrendLine("ResLine", _lastHighIndex, _lastHigh, index, _lastHigh, Color.FromArgb(120, Color.Red));
                resLine.LineStyle = LineStyle.Lines;
            }

            if (!double.IsNaN(_lastLow))
            {
                var supLine = Chart.DrawTrendLine("SupLine", _lastLowIndex, _lastLow, index, _lastLow, Color.FromArgb(120, Color.Green));
                supLine.LineStyle = LineStyle.Lines;
            }

            // 4. Sweep Detection Logic
            // Checks if the current bar swept the previous structure but rejected and closed inside.
            if (!double.IsNaN(_lastHigh) && Bars.High[index] > _lastHigh && Bars.Close[index] < _lastHigh)
            {
                Chart.DrawIcon("SweepHigh_" + index, ChartIconType.DownArrow, index, Bars.High[index] + (Symbol.PipSize * 3), Color.Red);
            }

            if (!double.IsNaN(_lastLow) && Bars.Low[index] < _lastLow && Bars.Close[index] > _lastLow)
            {
                Chart.DrawIcon("SweepLow_" + index, ChartIconType.UpArrow, index, Bars.Low[index] - (Symbol.PipSize * 3), Color.Green);
            }
        }
    }
}
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
Recommended broker for automated trading & scalping IC Markets
PTScalper
Site Admin
Posts: 7821
Joined: Mon Jul 20, 2026 1:28 pm

Re: Equity Curve Versus R-Curve: Two Views of the Same Account

Post by PTScalper »

Key Differences from Pine Script

Line Extension: By passing static string names ("ResLine" and "SupLine") into Chart.DrawTrendLine, the cTrader API automatically handles the garbage collection of the old line segments and dynamically stretches the line to the current index on every tick, keeping your DOM perfectly clean.

Icon Anchoring: Icons are uniquely named ("SweepHigh_" + index) so they remain permanently stamped on the chart where historical sweeps occurred, offset by 3 pips to keep the wicks visible.
Preserve your own money. Scale with the market's money. Exponential growth is the ultimate key.
FXS HongKong Scalper
Posts: 543
Joined: Sat Oct 24, 2026 10:15 pm

Re: Equity Curve Versus R-Curve: Two Views of the Same Account

Post by FXS HongKong Scalper »

Using fixed names for the lines is a clean way to keep the chart tidy in cTrader. One thing to watch with the sweep icons is that the number of objects grows on every sweep, and on a long history with M1 charts that can slow the platform. Limiting the icons to the last few hundred bars, or removing old ones in a loop, keeps performance steady. The 3 pip offset may also need to be scaled for gold or yen pairs, since 3 pips means something different on those symbols.
FXS Official Team | Hong Kong Session Desk
Fairman
Posts: 6955
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Equity Curve Versus R-Curve: Two Views of the Same Account

Post by Fairman »

Comparing the two curves side by side shows things I wouldn't see in either one alone. When I first plotted them, my R-curve climbed steadily, up about 24R over four months, but the dollar curve was nearly flat. The cause turned out to be sizing. I'd cut size after every losing streak, so the winning periods were traded small and the losing ones traded larger than planned after I tried to "make it back".

Hypothetically: 20 winners at +1R traded at 0.3 lots, giving about 20 times 30 dollars, 600 dollars, and 10 losers at -1R traded at 0.6 lots, giving about 10 times 60, 600 dollars lost. In R terms that's +10R, in money it's zero. The strategy was fine, my sizing was the problem.

The flip case you mention, equity beating R, is the one that flatters me. If I size up after a good week, the dollar curve rises faster and I assume I'm improving, when it's just the same edge with more at stake, and the next bad week hits harder.

So I judge the strategy on the R-curve and judge myself on the gap between the two lines.

Do you put the gap on its own chart, like a ratio of the two, or just read them together? And do you adjust for deposits and withdrawals before plotting?
It’s Fairman :geek:
Post Reply