Category Trend  Published on 18/12/2023

darvas box

Description

The "Darvas Boxes" refer to a trading strategy developed by Nicolas Darvas, a professional dancer who became a renowned trader in the 1950s. His strategy was based on a technical analysis approach and was outlined in his 1960 book titled "How I Made $2,000,000 in the Stock Market."

Here is a general description of how Darvas Boxes work:

Identification of Trends and Patterns: Darvas focused on identifying trends and price patterns. He looked for stocks forming "boxes" or "rectangles" on the price chart. A "box" is formed when prices move sideways within a certain range.

Entry Point: Once a box was identified, Darvas placed a buy order above the upper level of the box. This served as a signal to enter a position when the price broke through the upper resistance of the box.

Stop Loss and Risk Management: Darvas employed a stop-loss approach to protect his investments. He placed a stop loss just below the lower level of the box. This allowed him to limit losses in case the price didn't move as anticipated.

Profit Targets: Darvas had predetermined profit targets. Once the price reached a specific target level, he sold his position to secure a profit.

Constant Monitoring: Darvas closely monitored his positions, continually adjusting his stop-loss orders below new support levels and booking profits when prices reached his targets.

It's essential to note that the Darvas Boxes strategy is based on technical analysis and involves active portfolio management. As with any trading strategy, there are risks, and there's no guarantee of success. Investors should conduct their own analysis and carefully consider their risk profile before adopting any trading strategy.


using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DarvasBox : Indicator
    {
        private double boxTop;
        private double boxBottom;
        private bool isBoxActive;
        private int boxStart;
        private int boxCount;

        [Parameter("Tick Percentage", DefaultValue = 0.5, MinValue = 0, MaxValue = 100)]
        public double TickPercentage { get; set; }

        protected override void Initialize()
        {
            isBoxActive = false;
            boxCount = 0;
        }

        public override void Calculate(int index)
        {
            if (index <= 0)
                return;

            if (isBoxActive)
            {
                // Close the box if price goes below 50% of the box or above 50% of the box
                if (MarketSeries.Low[index] < boxBottom * (1 - TickPercentage / 100) || MarketSeries.High[index] > boxTop * (1 + TickPercentage / 100))
                {
                    DrawDarvasBox(boxStart, index);
                    isBoxActive = false;
                }
            }
            else
            {
                // Open a new box if the high breaks the previous high
                if (MarketSeries.High[index] > MarketSeries.High[index - 1])
                {
                    boxTop = MarketSeries.High[index];
                    boxBottom = MarketSeries.Low[index];
                    boxStart = index;
                    isBoxActive = true;
                }
            }
        }

        private void DrawDarvasBox(int startIndex, int endIndex)
        {
            // Draw Darvas Box lines
            double boxHeight = Symbol.PipSize * 10; // You can adjust the height as needed

            ChartObjects.DrawLine("DarvasBoxTop" + boxCount, startIndex, boxTop, endIndex, boxTop, Colors.Yellow, 3, LineStyle.Solid);
            ChartObjects.DrawLine("DarvasBoxBottom" + boxCount, startIndex, boxBottom, endIndex, boxBottom, Colors.Yellow, 3, LineStyle.Solid);

            boxCount++;
        }
    }
}

DE
DELETED_USER

Joined on 28.06.2022 Blocked

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: darvas.algo
  • Rating: 0
  • Installs: 211
  • Modified: 18/12/2023 16:39
Comments
Log in to add a comment.
No comments found.