Golden Dragon

by nobulart in category Other at 03/10/2013
Description

Still under active development and highly experimental. A polynomial regression channel trading system loosley based upon Mostafa Belkhayate's trading system. Uses the BelkahayatePRC and Hull Moving Average custom indicators (versions used are included - please remember to install and compile them and update the inclusion references in the Golden Dragon before compiling the bot). Many additional functions have been included to facilitate fine-tuning. This can be traded on anything from a 1 minute chart upwards. I've found 5-15 minute chart periods tend to work best.

Remember to update the two references in this robot before compiling it for the first time. 
It will not work if it cannot find the compiled custom indicators.

UPDATED to v1.3 - Slight logic change to avoid concurrent martingales. Updated parameter defaults to those which I use as a benchmark starting point when testing new charts (normally 5 minute).

Click here to watch a YouTube video of this bot executing a single trade on EURUSD.

Golden Dragon XAUUSD

Golden Dragon USDCHF

Parameter Reference

Dragon Number - Used to track trades associated with a Dragon instance. Only required if running multiple instances on the same instrument. Assign a unique number to each. [ Default = 1 ]

COG Degree - Degree for the polynomial regression centre-of-gravity line. A setting of 1 uses a linear regression. 2-4 produce progressively tighter fitting curves [ Default = 3, Range = 1-4, Typically = 3-4 ]

COG Period - Number of bars that the polynomial regression should be calculated over. [ Default = 260 ]

1st Channel Offset - Offset distance for the first (inner) channel lines. These lines may be optionally used as target lines for trades. [ Default = 1.4 ]

2nd Channel Offset - Offset distance for the second (intermediate) channel lines. These lines are used for trade entry selection and may be optionally used as target lines for trades originating on the opposite side of the centreline. [ Default = 2.4 ]

3rd Channel Offset - Offset distance for the third (outer) channel lines. These lines are used for trade entry selection and may be optionally used as target and/or stop loss lines for trades. [ Default = 3.4 ]

COG Trade Biasing - When enabled, trades are filtered according to whether the COG is rising (long trades only) or falling (short trades only). [ Default = No ]

Adaptive Trade Biasing - When enabled, the maximum permitted number of long and short trades will be automatically adjusted based on performance. If a long trade is lost then the maximum number of long trades will be decremented by 1 and the maximum number of short trades will be increased by 1 (up to the specified maximum), and vica-versa. [ Default = No ]

Hull Trade Biasing - Uses a Hull Moving Average to filter trade entry direction. If enabled, will only enter long positions if the HMA is rising, and short positions if it is falling. [ Default = Yes ]

Hull Period - Hull Moving Average period in bars. The HMA is used to aid trade entry timing. Long trades are entered when the HMA passes upwards through either of the lowest two channel lines (and price is within the Entry Window distance above the entry line). Short trades are entered when the HMA passes downwards through either of the uppermost two channel lines (and price is within the Entry Window distance below the entry line). Longer HMA periods result in more reliable entry points, but reduced profit per trade due to later entry. [ Default = 5, Typical Range = 4 - 10 ]

ATR Filter 1| 2 Period - If both of these are non-zero, then trades will only be opened when the ATR1 value is lower than ATR2. Acts as a volatility filter. [ Default = 0 | 0 ]

ATR Filter 1| 2 MA Type - Specify the type of smoothing to be used for each of the average true range indicators. [ Default = Simple | Simple ]

Long Trades - Maximum number of long positions which may be simultaneously opened. Higher values increase both profitability and risk. Some markets trade profitably in one direction only. [ Default = 1, Off = 0 ]

Short Trades - Maximum number of short positions which may be simultaneously opened. Higher values increase both profitability and risk. Some markets trade profitably in one direction only. [ Default = 1, Off = 0 ]

Buy Wait - Minimum number of bars to wait between entering trades. Used primarily to prevent trade "bunching" and manage risk levels. [ Default = 20, Off = 0 ]

Buy Wait on Loss - Additional number of bars to wait after losing a trade. New trades will not be entered until the wait period is complete. Useful for dealing with occasional high-volatility. Allows the market time to settle before resuming trading. Values slightly higher than the COG period seem to work quite well. [ Default = 260 ]

Stop Loss - Fixed stop loss position relative to trade entry points. [ Default = 100 pips ]

Target LevelSpecifies which of the polynomial regression channels will be used for setting the trade targets. By default the centreline (0) will be used, but any of them may be specified, with the 1st channel line on the opposite side from entry being 1, and the 3rd channel line on the opposite side from entry being 3. Higher numbers result in greater proftability and greater risk. [ Default = 0 (centre), Range = -1, 0, 1, 2, 3 ]

Dynamic Targets - Enabling this will causes the targets for open trades to be adjusted to track the specified Target Level with each new bar. Overrides the default fixed targetUseful in some rare circumstances. [ Default = No ]

Opening Lot Size - Starting order volume per trade. If the Money Management or Martingale functionality is enabled then this specifies the minimum trade volume allowed. [ Default = 10000 ]

Maximum Lot Size - Maximum lot that can be placed on any one trade. Zero disables. [ Default = 0 ]

Minimum Profit - Specifies the minimum number of pips to be won on any trade. Trades with dynamic targets will be automatically closed if the target price moves within the minimum profit specified here. [ Default = 1 ]

Maximum SlippageSpecifies the spread allowable per trade entry. [ Default = 2, Attempt Limit Order = 0 ]

Entry Window - Minimum distance (in pips) that price must be from an entry line before a trade can be entered. This has been added to compensate for the entry lag created by the Hull moving average. Trades are no longer entered immediately when the HMA crosses an entry line - the bot will wait for price to be within the Entry Window distance of the entry channel line before opening the trade. Smaller values here will reduce the number of trades entered, but will also increase average profit per trade. [ Default = 5, Range >= 0 ]

Dynamic Stops - Stop Loss positions are dynamically adjusted to track the relevant 3rd channel line on every bar. Seldom of use, but may be useful in some configurations. [ Default = No ]

Trailing Stops - Enables trailing stops. [ Default = No ]

Trailing Stop Trigger - Distance in pips that price must move from entry before the trailing stop is enabled. [ Default = 20 ]

Trailing Stop Distance - Distance from the current price (in pips) for a triggered trailing stop. [ Default = 20 ]

Balance Stop Loss - Proportion of account balance that must be maintained after a loss. Any losses which cause the account balance to drop below this threshhold will result in all losing trades to be closed immediately to preserve the account balance at the current level. For example, if this is set to 0.5, the current account balance is $1000, all losing positions will be closed immediately and the Dragon will exit if the account balance drops below $1000x0.5 = $500 on close of any trade. [ Default = 0.5, Range = 0-1 ]

Equity Stop Loss - If account equity drops below this proportion of the account balance, then all losing open trades are closed immediately and the Dragon will exit. [ Default = 0.5, Range = 0-1 ]

Equity Trade FilterWill prevent any new trades from being entered into whilst account equity is less than this proportion of the account balance. [ Default = 0.5, Range = 0-1 ]

Trade on Fridays - Does exactly what it says. Provides a means to prevent the opening of new trades on Fridays. Useful in some markets which frequently gap when markets open on a Monday. [ Default = Yes ]

Money Management - Will proportionally increase lot sizes based upon account equity, ie. if the account equity at start of trade is $1000 and the lot size is 10k, then the lot size will be incremented to 20k when the equity reaches $2000, to 30k at $3000, and so on. [ Default = Yes ]

Martingale Enabled - Specifies whether the Martingale-derived loss recovery strategy will be used. This can be extremely succesful because of the high win proportion achievable. When the bot is stopped, either manually or automatically, the current martingale level is saved to a text file in the user's default documents folder (so that the bot can be restarted without "forgetting" it's martingale duties). The level will be restored on start up. Delete or edit the file to reset or preset the martingale level. [ Default = Yes ]

Reversingale Enabled - Enables instant position reversals upon lost trades. Ignores the Buy Wait and Buy Wait on Loss periods altogether. Uses the Martingale Multiplier to calculate the lot size and target distance required in order to recover from a loss. Only works if the Martingale functionality is enabled. Particularly useful in markets (such as gold) that tend to make large rapid moves after long periods of consolidation. [ Default = No ]

Martingale Multipler - When a trade is lost, then the next trade will increase the lot size by the factor specified by this parameter. eg. if the Multiplier is 2, then the lot size will be doubled and the target distance will be roughly half of the lost pips. If set to 4, then the lot size will be quadrupled and the target distance will be roughly one quarter of the lost pips. [ Default = 2 ]

Martingale Recursions - Limit the number of times that consecutive Martingale multiplications may occur. [ Default = 2 ]

Debug Level - Specifies the amount of operational information that will be output to the log. [ Default = 0, Range = 0-2 ]

Together, all of these parameters make for a flexible trading system which has the potential to achieve relatively steady profitability with minimal drawdown in every market that I've tested it on. That said, it can take A LOT of backtesting to tune it to a particular market. Have fun, and please share your profitable parameters, bug fixes, optimizations, enhancements or improvements. This is my first time working with C#, so I'm sure there are plenty of areas which can be optimized.

 

 

Download
6780 downloads
How to install
Warning! Executing the following cBot may result in loss of funds. Use it at your own risk.
Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgo
//#reference: ..\Indicators\Hull Moving Average.algo
//#reference: ..\Indicators\BelkhayatePRC.algo

// Golden Dragon v1.3
// Released 20th October 2013
// Created by Craig Stone (except for trailing stops code which is drawn from Spotware's sample code)

using System;
using System.Linq;
using System.IO;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC)]
    public class GoldenDragon : Robot
    {
        [Parameter("Dragon Number", DefaultValue = 1, MinValue = 1)]
        public int DragonNumber { get; set; }

        [Parameter("COG Degree", DefaultValue = 3, MinValue = 1, MaxValue = 4)]
        public int cogDegree { get; set; }

        [Parameter("COG Period", DefaultValue = 260, MinValue = 1)]
        public int cogPeriod { get; set; }

        [Parameter("1st Channel Offset", DefaultValue = 1.4, MinValue = 0.1)]
        public double Inner { get; set; }

        [Parameter("2nd Channel Offset", DefaultValue = 2.4, MinValue = 0.1)]
        public double Middle { get; set; }

        [Parameter("3rd Channel Offset", DefaultValue = 3.4, MinValue = 0.1)]
        public double Outer { get; set; }

        [Parameter("COG Trade Biasing", DefaultValue = false)]
        public bool cogBias { get; set; }

        [Parameter("Adaptive Trade Biasing", DefaultValue = false)]
        public bool AdaptiveBias { get; set; }

        [Parameter("Hull Trade Biasing", DefaultValue = true)]
        public bool HullBias { get; set; }

        [Parameter("Hull Period", DefaultValue = 5, MinValue = 1)]
        public int HullPeriod { get; set; }

        [Parameter("ATR Filter 1 Period", DefaultValue = 0, MinValue = 0)]
        public int atr1Period { get; set; }

        [Parameter("ATR Filter 1 MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType atr1Type { get; set; }

        [Parameter("ATR Filter 2 Period", DefaultValue = 0, MinValue = 0)]
        public int atr2Period { get; set; }

        [Parameter("ATR Filter 2 MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType atr2Type { get; set; }

        [Parameter("Long Trades", DefaultValue = 1, MinValue = 0)]
        public int MaxLongTrades { get; set; }

        [Parameter("Short Trades", DefaultValue = 1, MinValue = 0)]
        public int MaxShortTrades { get; set; }

        [Parameter("Buy Wait (bars)", DefaultValue = 20, MinValue = 1)]
        public int BuyWait { get; set; }

        [Parameter("Buy Wait on Loss (bars)", DefaultValue = 260)]
        public int LossDelay { get; set; }

        [Parameter("Stop Loss (pips)", DefaultValue = 100, MinValue = 0)]
        public int StopLoss { get; set; }

        [Parameter("Target Level", DefaultValue = 0, MinValue = -1, MaxValue = 3)]
        public int TargetLevel { get; set; }

        [Parameter("Dynamic Targets", DefaultValue = false)]
        public bool DynamicTargets { get; set; }

        [Parameter("Opening Lot Size", DefaultValue = 10000, MinValue = 1)]
        public int OpeningLotSize { get; set; }

        [Parameter("Maximum Lot Size", DefaultValue = 1000000, MinValue = 0)]
        public int MaxLotSize { get; set; }

        [Parameter("Minimum Profit (pips)", DefaultValue = 1, MinValue = 0)]
        public int MinimumPips { get; set; }

        [Parameter("Maximum Slippage (pips)", DefaultValue = 2, MinValue = 0)]
        public int Slippage { get; set; }

        [Parameter("Entry Window (pips)", DefaultValue = 5, MinValue = 0)]
        public int EntryWindow { get; set; }

        [Parameter("Dynamic Stops", DefaultValue = false)]
        public bool DynamicStops { get; set; }

        [Parameter("Trailing Stops", DefaultValue = false)]
        public bool TrailingStops { get; set; }

        [Parameter("Trailing Stop Trigger (pips)", DefaultValue = 20)]
        public int Trigger { get; set; }

        [Parameter("Trailing Stop Distance (pips)", DefaultValue = 20)]
        public int TrailingStop { get; set; }

        [Parameter("Balance Stop Loss (ratio)", DefaultValue = 0.5, MinValue = 0, MaxValue = 1)]
        public double BalanceStop { get; set; }

        [Parameter("Equity Stop Loss (ratio)", DefaultValue = 0.5, MinValue = 0, MaxValue = 1)]
        public double EquityStop { get; set; }

        [Parameter("Equity Trade Filter", DefaultValue = 0.5, MinValue = 0, MaxValue = 1)]
        public double EquityFilter { get; set; }

        [Parameter("Trade on Fridays", DefaultValue = true)]
        public bool FridayTrading { get; set; }

        [Parameter("Money Management", DefaultValue = true)]
        public bool MoneyManagement { get; set; }

        [Parameter("Martingale Enabled", DefaultValue = true)]
        public bool MartingaleEnabled { get; set; }

        [Parameter("Reversingale Enabled", DefaultValue = false)]
        public bool Reversingale { get; set; }

        [Parameter("Martingale Multiplier", DefaultValue = 2, MinValue = 2, MaxValue = 10)]
        public int MartingaleFactor { get; set; }

        [Parameter("Martingale Recursions", DefaultValue = 2, MinValue = 1, MaxValue = 4)]
        public int MartingaleMax { get; set; }

        [Parameter("Debug Level", DefaultValue = 0, MinValue = 0, MaxValue = 3)]
        public int Debug { get; set; }

        private int LongPositions = 0, ShortPositions = 0, MaxLong = 0, MaxShort = 0;
        private int BuyVolume = 0, TakeProfit = 0, Count = 0, MartingaleActive = 0, Quantity = 0;

        private int t1ix;
        private double t1h3, t1h2, t1h1, t1c0, t1l1, t1l2, t1l3;

        private double bid = 0, ask = 0, spread = 0, pipsize = 0, buystop = 0, sellstop = 0, OpeningBalance = 0, LostPips = 0, BotBalance = 0;

        private bool TradeSafe, BuySafe, SellSafe;
        private bool isTrigerred;

        private string DragonID, desktopFolder, filePath;

        StreamWriter _fileWriter;
        StreamReader _fileReader;

        private Position position;

        private BelkhayatePRC cog;
        private HMA hull;
        private AverageTrueRange atr1, atr2;

        protected override void OnStart()
        {
            DragonID = "Golden Dragon " + Symbol.Code + "-" + DragonNumber;

            Count = BuyWait;
            BuyVolume = OpeningLotSize;
            Quantity = BuyVolume;
            OpeningBalance = Account.Balance;

            MaxLong = MaxLongTrades;
            MaxShort = MaxShortTrades;

            cog = Indicators.GetIndicator<BelkhayatePRC>(cogDegree, cogPeriod, Inner, Middle, Outer);
            hull = Indicators.GetIndicator<HMA>(HullPeriod);

            if (atr1Period > 0 && atr2Period > 0)
            {
                atr1 = Indicators.AverageTrueRange(atr1Period, atr1Type);
                atr2 = Indicators.AverageTrueRange(atr2Period, atr2Type);
            }

            Message(0, "Dragon awakening...");

            foreach (var position in Account.Positions)
            {
                if (position.Label == DragonID)
                {
                    BotBalance += position.GrossProfit;
                    switch (position.TradeType)
                    {
                        case TradeType.Buy:
                            LongPositions++;
                            break;
                        case TradeType.Sell:
                            ShortPositions++;
                            break;
                    }
                }
            }

            if (LongPositions > 0 || ShortPositions > 0)
                Message(0, "Found " + LongPositions + " half-eaten eagle(s) and " + ShortPositions + " rotting sheep");
            else
                Message(0, "No open trades found");

            ChartRefresh();

            filePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DragonID + ".txt");

            if (MartingaleEnabled && File.Exists(filePath))
            {
                _fileReader = File.OpenText(filePath);
                MartingaleActive = Int32.Parse(_fileReader.ReadLine());
                Message(0, "Martingale Level : " + MartingaleActive);
                _fileReader.Close();
            }
        }

        protected override void OnBar()
        {
            Count++;

            Message(2, "Buy Wait " + Count + ", Long " + LongPositions + " of " + MaxLong + ", Short " + ShortPositions + " of " + MaxShort + ", Martingale Level " + MartingaleActive + ", TradeSafe " + TradeSafe + ", BuySafe " + BuySafe + ", SellSafe " + SellSafe);

            // COGx1
            t1ix = (int)cog.ix;
            t1h3 = (double)cog.sqh3.LastValue;
            t1h2 = (double)cog.sqh2.LastValue;
            t1h1 = (double)cog.sqh.LastValue;
            t1c0 = (double)cog.prc.LastValue;
            t1l1 = (double)cog.sql.LastValue;
            t1l2 = (double)cog.sql2.LastValue;
            t1l3 = (double)cog.sql3.LastValue;

            if (DynamicTargets)
            {
                foreach (var position in Account.Positions)
                {
                    if ((position.Label == DragonID) && (Math.Abs((sbyte)(position.TakeProfit - position.EntryPrice) / pipsize) > MinimumPips))
                        switch (position.TradeType)
                        {
                            case TradeType.Buy:
                                switch (TargetLevel)
                                {
                                    case -1:
                                        Trade.ModifyPosition(position, position.StopLoss, (t1l1 - ask));
                                        break;
                                    case 0:
                                        Trade.ModifyPosition(position, position.StopLoss, (t1c0 - ask));
                                        break;
                                    case 1:
                                        Trade.ModifyPosition(position, position.StopLoss, (t1h1 - ask));
                                        break;
                                    case 2:
                                        Trade.ModifyPosition(position, position.StopLoss, (t1h2 - ask));
                                        break;
                                    case 3:
                                        Trade.ModifyPosition(position, position.StopLoss, (t1h3 - ask));
                                        break;
                                }
                                break;
                            case TradeType.Sell:
                                switch (TargetLevel)
                                {
                                    case -1:
                                        Trade.ModifyPosition(position, position.StopLoss, (bid - t1h1));
                                        break;
                                    case 0:
                                        Trade.ModifyPosition(position, position.StopLoss, (bid - t1c0));
                                        break;
                                    case 1:
                                        Trade.ModifyPosition(position, position.StopLoss, (bid - t1l1));
                                        break;
                                    case 2:
                                        Trade.ModifyPosition(position, position.StopLoss, (bid - t1l2));
                                        break;
                                    case 3:
                                        Trade.ModifyPosition(position, position.StopLoss, (bid - t1l3));
                                        break;
                                }
                                break;
                        }
                }
            }

            if (DynamicStops && !TrailingStops)
            {

                foreach (var position in Account.Positions)
                {
                    if (position.Label == DragonID)
                        switch (position.TradeType)
                        {
                            case TradeType.Buy:
                                Trade.ModifyPosition(position, (t1l3 - t1c0 - t1l3), position.TakeProfit);
                                break;
                            case TradeType.Sell:
                                Trade.ModifyPosition(position, (t1h3 + t1h3 - t1c0), position.TakeProfit);
                                break;
                        }
                }

            }


        }


        protected override void OnTick()
        {
            bid = Symbol.Bid;
            ask = Symbol.Ask;
            spread = Symbol.Spread;
            pipsize = Symbol.PipSize;
            TradeSafe = true;
            BuySafe = true;
            SellSafe = true;

            if (Trade.IsExecuting)
            {
                return;
            }

            if (!FridayTrading && Server.Time.DayOfWeek == DayOfWeek.Friday)
            {
                return;
            }

            if (Account.Equity / Account.Balance < EquityStop)
            {
                Message(0, "Equity protection stop triggered. Profitable positions remain open");
                ClosePositions();
                Stop();
                return;
            }

            if (Account.Equity < Account.Balance * BalanceStop)
            {
                Message(0, "Account balance protection triggered. Profitable positions remain open");
                ClosePositions();
                Stop();
                return;
            }

            if (Account.Equity < Account.Balance * EquityFilter)
                TradeSafe = false;

            if (TrailingStops)
                AdjustTrailingStops();

            if (HullBias)
            {
                if (hull.hma.IsRising())
                    SellSafe = false;
                if (hull.hma.IsFalling())
                    BuySafe = false;
            }

            if (atr1Period > 0 && atr2Period > 0 && atr1.Result.LastValue > atr2.Result.LastValue)
                TradeSafe = false;

            if (cogBias)
            {
                if (cog.prc.IsRising())
                    SellSafe = false;
                if (cog.prc.IsFalling())
                    BuySafe = false;
            }


            if (Count > BuyWait && TradeSafe)
            {

                if (LongPositions < MaxLong && BuySafe && ((hull.hma.HasCrossedAbove(cog.sql3, 1) && (ask < (cog.sql3.LastValue + (EntryWindow * pipsize)))) || (hull.hma.HasCrossedAbove(cog.sql2, 1) && (ask < (cog.sql2.LastValue + (EntryWindow * pipsize))))))
                {
                    OpenPosition(TradeType.Buy);
                    Message(1, "Pursuing an eagle...");
                }

                if (ShortPositions < MaxShort && SellSafe && ((hull.hma.HasCrossedBelow(cog.sqh3, 1) && (bid < (cog.sqh3.LastValue - (EntryWindow * pipsize)))) || (hull.hma.HasCrossedBelow(cog.sqh2, 1) && (bid > (cog.sqh2.LastValue - (EntryWindow * pipsize))))))
                {
                    OpenPosition(TradeType.Sell);
                    Message(1, "Swooping on a sheep...");
                }
            }

            ChartRefresh();

        }

        private void OpenPosition(TradeType tradetype)
        {
            if (Trade.IsExecuting || Count < BuyWait)
            {
                return;
            }

            switch (tradetype)
            {
                case TradeType.Buy:
                    switch (TargetLevel)
                    {
                        case -1:
                            TakeProfit = (int)(Math.Abs(t1l1 - ask) / pipsize);
                            break;
                        case 0:
                            TakeProfit = (int)(Math.Abs(t1c0 - ask) / pipsize);
                            break;
                        case 1:
                            TakeProfit = (int)(Math.Abs(t1h1 - ask) / pipsize);
                            break;
                        case 2:
                            TakeProfit = (int)(Math.Abs(t1h2 - ask) / pipsize);
                            break;
                        case 3:
                            TakeProfit = (int)(Math.Abs(t1h3 - ask) / pipsize);
                            break;
                    }
                    break;
                case TradeType.Sell:
                    switch (TargetLevel)
                    {
                        case -1:
                            TakeProfit = (int)(Math.Abs(bid - t1h1) / pipsize);
                            break;
                        case 0:
                            TakeProfit = (int)(Math.Abs(bid - t1c0) / pipsize);
                            break;
                        case 1:
                            TakeProfit = (int)(Math.Abs(bid - t1l1) / pipsize);
                            break;
                        case 2:
                            TakeProfit = (int)(Math.Abs(bid - t1l2) / pipsize);
                            break;
                        case 3:
                            TakeProfit = (int)(Math.Abs(bid - t1l3) / pipsize);
                            break;
                    }
                    break;
            }

            if (MartingaleEnabled && MartingaleActive > 0)
            {
                TakeProfit = (int)(StopLoss / MartingaleFactor * 1.2);
                Message(1, "St.George sighted...");
            }

            if (MoneyManagement == true && Account.Balance > OpeningBalance)
            {
                Quantity = BuyVolume * (int)(Account.Balance / OpeningBalance);
                Message(3, "Money Management : " + Quantity + "(BV:" + BuyVolume + ")");
            }
            else
            {
                Quantity = BuyVolume;
            }

            if (MaxLotSize > 0 && Quantity > MaxLotSize)
                Quantity = MaxLotSize;

            if (TakeProfit < MinimumPips)
                TakeProfit = MinimumPips;

            Request request = new MarketOrderRequest(tradetype, Quantity) 
            {
                Label = DragonID,
                SlippagePips = Slippage,
                StopLossPips = StopLoss,
                TakeProfitPips = TakeProfit
            };

            Trade.Send(request);
            Count = 0;
        }


        private void ClosePositions()
        {
            foreach (var position in Account.Positions)
            {
                if (position.Label == DragonID)
                {
                    if (position.GrossProfit < 0)
                    {
                        Trade.Close(position);
                        Message(2, "Closing position " + position.Id + " for $" + position.GrossProfit + " loss");
                    }
                }
            }
        }


        protected override void OnPositionOpened(Position openedPosition)
        {
            switch (openedPosition.TradeType)
            {
                case TradeType.Buy:
                    LongPositions++;
                    break;
                case TradeType.Sell:
                    ShortPositions++;
                    break;
            }

            if (MartingaleEnabled && MartingaleActive > 0)
                MartingaleActive--;
        }

        protected override void OnPositionClosed(Position closedPosition)
        {

            switch (closedPosition.TradeType)
            {
                case TradeType.Buy:
                    LongPositions--;
                    break;
                case TradeType.Sell:
                    ShortPositions--;
                    break;
            }


            if (closedPosition.GrossProfit < 1)
            {
                Message(1, "Attacked by St. George!");

                if (LossDelay > 0)
                {
                    Count = -(LossDelay);
                    Message(1, "Dragon is licking his wounds...");
                }

                if (AdaptiveBias == true)
                {
                    switch (closedPosition.TradeType)
                    {
                        case TradeType.Buy:
                            if (MaxLong > 1)
                                MaxLong--;
                            if (MaxShort < MaxShortTrades)
                                MaxShort++;
                            break;

                        case TradeType.Sell:
                            if (MaxShort > 1)
                                MaxShort--;
                            if (MaxLong < MaxLongTrades)
                                MaxLong++;
                            break;
                    }
                }

                if (MartingaleEnabled && MartingaleActive < MartingaleMax)
                {
                    MartingaleActive++;

                    BuyVolume = (int)closedPosition.Volume * MartingaleFactor;

                    if (MaxLotSize > 0 && BuyVolume > MaxLotSize)
                        BuyVolume = MaxLotSize;

                    if (Reversingale)
                    {
                        Message(1, "Taking evasive action");

                        if (closedPosition.TradeType == TradeType.Sell)
                        {
                            TakeProfit = (int)(-closedPosition.Pips / MartingaleFactor * 1.2);
                            if (TakeProfit < MinimumPips)
                                TakeProfit = MinimumPips;
                            Request request = new MarketOrderRequest(TradeType.Buy, BuyVolume) 
                            {
                                Label = DragonID,
                                SlippagePips = Slippage,
                                StopLossPips = StopLoss,
                                TakeProfitPips = TakeProfit
                            };
                            Trade.Send(request);
                        }
                        else
                        {
                            TakeProfit = (int)(-closedPosition.Pips / MartingaleFactor * 1.2);
                            if (TakeProfit < MinimumPips)
                                TakeProfit = MinimumPips;
                            Request request = new MarketOrderRequest(TradeType.Sell, BuyVolume) 
                            {
                                Label = DragonID,
                                SlippagePips = Slippage,
                                StopLossPips = StopLoss,
                                TakeProfitPips = TakeProfit
                            };
                            Trade.Send(request);
                        }
                        Message(2, "Reversingale Stop. Entry " + closedPosition.EntryPrice + ", Loss " + closedPosition.GrossProfit + ", New Entry " + Symbol.Ask + ", New Target " + TakeProfit);
                    }
                }

            }
            else
            {
                BuyVolume = OpeningLotSize;

                if (MartingaleActive > 0)
                {
//                    MartingaleActive--;
//                    Message(1, "St. George defeated! Revenge is sweet");
                }
                else
                    Message(1, "Dinner is served!");
            }
        }


        private void AdjustTrailingStops()
        {
            foreach (var position in Account.Positions)
            {
                if (position.Label == DragonID)
                {
                    if (position.TradeType == TradeType.Buy)
                    {
                        double distance = Symbol.Bid - position.EntryPrice;

                        if (distance >= Trigger * Symbol.PipSize)
                        {
                            if (!isTrigerred)
                            {
                                isTrigerred = true;
                                Message(1, "Trailing Stop Loss triggered...");
                            }

                            double newStopLossPrice = Math.Round(Symbol.Bid - TrailingStop * Symbol.PipSize, Symbol.Digits);

                            if (position.StopLoss == null || newStopLossPrice > position.StopLoss)
                            {
                                Trade.ModifyPosition(position, newStopLossPrice, position.TakeProfit);
                            }
                        }
                    }
                    else
                    {
                        double distance = position.EntryPrice - Symbol.Ask;

                        if (distance >= Trigger * Symbol.PipSize)
                        {
                            if (!isTrigerred)
                            {
                                isTrigerred = true;
                                Message(1, "Trailing Stop Loss triggered...");
                            }

                            double newStopLossPrice = Math.Round(Symbol.Ask + TrailingStop * Symbol.PipSize, Symbol.Digits);

                            if (position.StopLoss == null || newStopLossPrice < position.StopLoss)
                            {
                                Trade.ModifyPosition(position, newStopLossPrice, position.TakeProfit);
                            }
                        }
                    }

                }
            }
        }

        protected void ChartRefresh()
        {
            var name = "info";
            var text = DragonID;
            text += "\nBuy " + BuySafe + " / Sell " + SellSafe + " / Trade " + TradeSafe;
            text += "\nActive Lot Size : " + Quantity;
            text += "\nMartingale Level : " + MartingaleActive;
            text += "\nLong / Short : " + LongPositions + " / " + ShortPositions;
            text += "\nBuy Wait : " + (BuyWait - Count).ToString();

            var staticPos = StaticPosition.TopLeft;
            var color = Colors.Gray;
            ChartObjects.DrawText(name, text, staticPos, color);
        }

        protected void Message(int level, string message)
        {
            if (level <= Debug)
                Print("[{0}] {1}", level, message);
        }

        protected override void OnStop()
        {

            if (MartingaleEnabled)
            {
                File.Delete(filePath);
                File.WriteAllText(filePath, MartingaleActive.ToString());
                Message(0, "Saved Martingale Level : " + MartingaleActive);
            }

            Message(0, "Dragon Sleeping");
        }

    }
}
Comments

Marc - October 03, 2013 @ 12:09

protected override void OnStart()
        {
            DragonID = "Golden Dragon " + DragonNumber + " - " + Symbol.Code;

            Count = BuyWait;
            BuyVolume = LotSize;
            OpeningBalance = Account.Balance;

            MaxLong = MaxLongTrades;
            MaxShort = MaxShortTrades;

            cog = Indicators.GetIndicator<BelkhayatePRC>(cogDegree, cogPeriod, Inner, Middle, Outer);
            hull = Indicators.GetIndicator<HMA>(HullPeriod);


            if (atr1Period > 0 && atr2Period > 0)
            {
                atr1 = Indicators.AverageTrueRange(2, MovingAverageType.Simple);
                atr2 = Indicators.AverageTrueRange(120, MovingAverageType.Simple);
            }

            Message(1, "Dragon awakening...");

nobulart - October 03, 2013 @ 13:29

Thanks for pointing that out. Will upload a corrected version with the ATR filters enabled and working as intended.

Cerunnos - October 03, 2013 @ 13:55

Great work. Obviously you are trading with gold - me too :-) 
But I was of the opinion that due to the fact that the COG-bands are dynamic, it is impossible to test this strategy historically. Backtesting is therefore still possible?

nobulart - October 03, 2013 @ 14:16

Backtesting is definitely possible and seems to be quite accurate. The COG repaints quite heavily, but that works in our favour in this case. I'll upload a timelapse video of a single trade that I recorded which illustrates the repainting and entry mechanism quite well.

nobulart - October 03, 2013 @ 15:06

Added a YouTube video of a single short trade here.

Marc - October 03, 2013 @ 15:45

I think:
money management does not work.

merçi

nobulart - October 03, 2013 @ 16:18

Money Management does not smoothly increase lot sizes. It uses and integer (div) result to increase the lot size in steps with each multiple of the opening account balance.

opening balance $1000  - lot size 10oz

equity > $2000 - 20oz

equity > $3000 - 30oz

and so on... Make sense?

Marc - October 03, 2013 @ 18:44

résultat backtesting

par exemple eur/jpy

  [Parameter("Lot Size", DefaultValue = 10000, MinValue = 1)]

     

starting capital $1000  = Volume: 10000.(ok)

////////////////////////////////////////////////////////////////////////////////////////

résultat backtesting

  [Parameter("Lot Size", DefaultValue = 10000, MinValue = 1)]

     

starting capital $ 50000  = Volume: 10000(?)

 

backtesting gold :
for bactest: depart 1000 euros (volume = 10oz)
the above 2800 euros (volume = 10oz ...!)

 

khorshidi07 - October 03, 2013 @ 22:26

Hello

first thanks my freind  nobulart for this Robot.

2- this robot open position very late in my CAlgo(with default parameters)

for faster, what change do in  parameters?

thank you for help

nobulart - October 03, 2013 @ 23:36

Hi @hosseinkhorshidi. Reduce the hull moving average period to around 4-5 to enter trades more quickly. If you are running the bot on a 10 minute chart with a 130 period COG and a 6 period hma, you could also try switching to a 5 minute chart with. 260 period COG and a 12 period hma to achieve a similar result. In this way you can achieve higher "resolutions for tuning trade entries. The COG period is by far the most important parameter. Sometimes, changing the COG period by a single bar can have a dramatic influence on performance. Play around with it. Every market has sweet spots just waiting to be discovered. 

nobulart - October 03, 2013 @ 23:40

@tradermatrix the mm function chooses lot sizes based on account equity, not on balance (easily changed of course). In your example is it possible that whilst your account balance was > €2000, you equity was still < €2000 due to open trades not yet closed?

nobulart - October 03, 2013 @ 23:44

I've found COG periods of around 130, 260 and 480 to be interesting starting points on 1,3,5,10 and 15 minute charts. Give them a try. 

nobulart - October 04, 2013 @ 10:08

Doing a run this morning and it does indeed look as though the MM function is no longer working. I must have introduced a bug at some point in the past few days. I will post a bugfix within the next few hours.

nobulart - October 04, 2013 @ 20:40

Money management is now working as intended.

nobulart - October 04, 2013 @ 22:00

Added a Maximum Lot Size parameter.

phosphor - October 05, 2013 @ 03:58

I got an error on trying to build the robot:

"Error: 'cAlgo.Indicators.BelkhayatePRC' does not contain a definition for 'ix' and no extension method 'ix' accepting a first argument of type 'cAlgo.Indicators.BelkhayatePRC' could be found (are you mis"

It compiled after I deleted the line:

t1ix = (int)cog.ix;

since this variable does not seem to be used anywhere.

 

nobulart - October 05, 2013 @ 09:32

Hi @phosphor. I have made slight modifications to the indicators. The versions that I used are included in the download package. Use those. 

Marc - October 06, 2013 @ 16:21

nobular hello!
thank you for this robot and have corrected MM.


I think 

 [Parameter("Minimum Profit (pips)", DefaultValue = 1, MinValue = 0)]

        public int MinimumPips { get; set; }

  Parameter"Dynamic Targets":yes

does not work.

cordially

nobulart - October 06, 2013 @ 16:54

Hi @tradermatrix. Thank you. Hope you'll share your profitable recipes with us :-)

Minimum Profit - Only used when Dynamic Targetsare enabled. Specifies the minimum number of pips to be won when targets are being adjusted to track the Target Level line. [ Default = 1 ]

 Do you have dynamic targets enabled? If not, does this explain why it doesn't seem to work? 

nobulart - October 08, 2013 @ 14:54

The 0.7 bug fix exposed an even more significant problem which would prevent more than a couple of trades being placed. Please upgrade to 0.8

Marc - October 08, 2013 @ 18:36

Minimum Profit- Only used when Dynamic Targetsare enabled. Specifies the minimum number of pips to be won when targets are being adjusted to track the Target Level line. [ Default = 1 ]

Do you have dynamic targets enabled? If not, does this explain why it doesn't seem to work: yes

nobular hello!

I have also noticed a bug:
   [Parameter ("Martingale recursion", DefaultValue = 2, MinValue = 1, MaxValue = 4)] public int MartingaleMax {get; set;}
does not work

cordially

nobulart - October 09, 2013 @ 10:28

Thanks @tradermatrix. Looks like I might have broken the recursion mechanism with my recent bugfixes. So it goes. I'll post a fix soon.

nobulart - October 09, 2013 @ 17:05

 I couldn't find anything specifically wrong with the Martingale system, but I did make several small cleanups to the code which might have resolved any issue there. In testing this version the Martingale functionality seems to be working as I intended. It's worth noting that this is a Martingale-derived strategy. It doesn't adhere strictly to the Martingale strategy as I interpret it, but that largely because this bot may have several temporally overlapping trades running concurrently, and knowing when to double up and when not to becomes a little trickier. My method uses why I think of as layered Martingales. When a trade is lost the Martingale recursion level is incremented by 1. Winning trades wil decrement the recursion level by 1. Every time a new trade is openend the current recursion level is used to determine lot size and target distance. With a sufficiently high recursion level and deep enough pockets this will create symmetrical valleys in your balance/equity chart.

It is not a strict Martingale strategy though. If any would like to attempt implementing a strict Martingale (or an improvement on the existing one) in the code, I'd be interested in including it in my production bot. I'm sharing this because I'm hopeful that there are some out there who could suggest refinements or improvements (as well as bugs, of course).

Marc - October 09, 2013 @ 20:14

Hi @nobulart

the bug is here;

  [Parameter("Martingale Recursions", DefaultValue = 2, MinValue = 1, MaxValue = 4)]
        public int MartingaleMax { get; set; }

  [Parameter("Debug Level", DefaultValue = 0, MinValue = 0, MaxValue = 3)]
        public int Debug { get; set; }


   private int LongPositions = 0, ShortPositions = 0, MaxLong = 0, MaxShort = 0;
        private int BuyVolume = 0, TakeProfit = 0, Count = 0, MartingaleActive = 0, Quantity = 0;
        

"MartingaleActive"  : must change line

 private int LongPositions = 0, ShortPositions = 0, MaxLong = 0, MaxShort = 0, MartingaleActive = 0;

 private int BuyVolume = 0, TakeProfit = 0, Count = 0,, Quantity = 0;

good luck...

nobulart - October 09, 2013 @ 22:40

Hi @tradermatrix. I'm not sure that I understand the change here. Both of your examples, in my understanding, do the same thing: they both initialize the MartingaleActive variable to 0 when the bot starts up. Since it only happens once, I'm not as to why putting the initialization on one line or the other matters? Could you perhaps try to explain a little? 

le français est votre langue maternelle? peut-être poster votre réponse en français et je vais google traduction.

aisaac - October 13, 2013 @ 12:35

good morning, congratulations for the robot, you can make a request to add the optimization function to Calgo? so it would be easier to find the right set for the robot.

nobulart - October 13, 2013 @ 13:21

Thank you @aisaac. I agree. An optimization function similar to that found in MetaTrader would be most useful, and I hope that Spotware are giving some serious consideration to adding this functionality to cAlgo. I'm in the process of porting this bot to MetaTrader because of this. The Dragon has huge potential, but a more comprehensive backtesting system is required to fully exploit it.

nobulart - October 13, 2013 @ 14:21

I see that plans for optimization are already underway. http://ctdn.com/forum/calgo-support/1399

marthonGT - October 14, 2013 @ 16:02

Thanks a lot!

Your robot gave me great guidance with the coding that I had trouble with as I am not a programmer. I found several snippets that helped me to understand how I can achieve my goals in the robot which I am building to learn this whole stuff.  :-o

After building your robot successfully and out of curiosity wanted to run a backtest and shortly after the log tab filled up with the message:

"Crashed in Calculate with ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

and it seemed that it stucked here in an infinite loop! (EURUSD, 1 hour time frame, starting capital 1000GBP)

nobulart - October 14, 2013 @ 17:35

Hello @marthonGT. Thank you for the kind words :-) The error is generated by the BelkhayatePRC indicator during startup because, as I understand it, it doesn't have any data to feed back to the bot until the number of bars elapsed equals the COG period. I've looked for ways to suppress the error messages, but haven't put a great deal of effort into it because it doesn'y adversely affect the operation of the bot. If you (or anyone) comes up with a suitable means of cleaning this error "noise" I'd love to know how to do it. Thanks!

nobulart - October 14, 2013 @ 17:38

...and if you'd care to share you EURUSD test parameters with me I'll take a look and see if I can reproduce the infinite loop situation. You can email them to me at info[at]nobulart[dot]com

marthonGT - October 15, 2013 @ 15:36

I run a backtest again after reading your answer! and indeed it is not an infinite loop. sorry fo the mislead! I did not give enough time to the bot yesterday.  :-/ So far the bots that I came across usually run a whole year backtest in a few minutes. Yours need much (much+much) more for that. For example I started yours at 10:51:33.286 The crash message appaered from 10:51:33.717 till 10:54:14.499. Only after that appeared the orange color within the bar in the top.

I did have a look into the Indicator but that is way over my head! Altough I gave a shot to figure it somehow out and I came to the conclusion that the problem is within "syx" specificaly "sum += MarketSeries.Close[index - n];" where "index - n" comes to negative which means that the indicator is trying to look for data that will happen only in the future. But at the end, I have no idea if "i0" should get higher value or index should be declared with MarketSeries.Close.Count, because I didn't get the math and neither the whole indicator alltogether.   :'(  My programming knowledge isn't on that level (yet)
 

 

nobulart - October 15, 2013 @ 17:55

The backtesting performance hit comes from the Belkhayate indicator as well. Regression math is pretty processor intensive stuff, even for a linear regression. I've been considering building the needed parts of the indicators into the bot which would optimize things somewhat.

Thanks for the thoughts on silencing the errors. I'll have another attempt at sorting it out soon.

gb1980be - October 19, 2013 @ 12:56

Hi Nobulart.

Your dragon is a famous beast. A bit complex for me, but very well done. I can control it on gbpjpy m5. But on gold, I never exceed my initial capital. Could you send me private mail to talk about the settings for gold m1? You probably find what doesn't work for me. You are the master of the dragon, so I think it will be a breeze for you :-)

Mail : gb1980forex -at- gmail . com

Good job.

 

Cerunnos - October 19, 2013 @ 19:31

Hello Nobulart!
Congratulate you for this great project. I'm trading also with gold and still have not found the correct settings for the time frame m1. Would be great if you could send me to cerunnos32@gmx.at .
Thanks in advance!

nobulart - October 21, 2013 @ 03:03

I've added a sample gold recipe to the top of the page. It should provide a useful starting point for developing a more robust strategy.

Cerunnos - October 21, 2013 @ 08:23

Thanks a lot !

fomega - October 21, 2013 @ 17:38

Error: Unable to load

fomega - October 21, 2013 @ 17:40

Error: Unable to load assembly: Algo file 'C:\Users\Windows\Documents\cAlgo\Sources\Indicators\Hull Moving Average.algo' does not exist.

nobulart - October 21, 2013 @ 18:31

@fomega Please read the install instructions linked at the top of every robot and indicator page, and the instructions contained in the first paragraphs at the top of this page.

Cerunnos - October 21, 2013 @ 19:00

Hi fomega,
try the following path:

//#reference: ..\Indicators\HMA.algo
//#reference: ..\Indicators\BelkhayatePRC.algo

fomega - October 21, 2013 @ 19:51

@nobulart, I've already downloaded and created the indicators...
@Cerunnos,I try your new reference but error still remain...

nobulart - October 21, 2013 @ 23:10

@fomega If you haven't already done so Build the indicators. Make sure to delete the original two references from the top of the Goldern Dragon.cs source file, and then click on the Add Reference button at the top of the editor. Navigate to your My Documents > cAlgo > Source > Indicators folder and select the BelkhayatePRC.algo file. Repeat this process for the Hull Moving Average.algo file. Build the Dragon.

Old Account - October 21, 2013 @ 23:12

I get this error when im trying to backtest 

Crashed in Calculate whit Exception: <Index were too close to the area. It can't be a not-negative and less than the size of the collection.". Parametername: Index

The part of the error whitin the <>were translated from norwegian som i'm not shure if they are right.

 

Old Account - October 21, 2013 @ 23:14

Found a typo in the last post

 

I get this error when im trying to backtest 

Crashed in Calculate whit Exception: <Index were too close to the area. It can't be a not-negative and less than the size of the collection>. Parametername: Index

The part of the error within the <>were translated from norwegian som i'm not shure if they are right.

nobulart - October 22, 2013 @ 00:48

@MRSV - Please read the discussion of this error a little further up in the comments.

Old Account - October 22, 2013 @ 12:28

Oh, sorry

The robot used so long time to get started whit the backtest, so i toughtithad stoped. My bad

Amazing robot BTW

nobulart - October 22, 2013 @ 17:45

@MRSV Thanks :-) Glad you got it working.

iRobot - November 05, 2013 @ 22:36

Hi nobulart,

congrats on this great work and thanks for sharing it!

Could I suggest 1 simple improvement on stoploss?:

Could this robot have a functionality of stoploss automatically set at the 0.5x distance of target profit (but no less than some specific amount in pips (like 5pips)?

For example:

1) Long trade EUR/USD, spot 1.35, target price 1.354, stoploss 1.348.

2) Long trade EUR/USD, spot 1.35, target price 1.3508, stoploss 1.3495 (if min stoploss is set at 5)

 

Many thanks for your reply.

nobulart - November 06, 2013 @ 14:09

Hi @iRobot

That would be quite easy to implement. I'm currently working on an extensive re-write of the risk management side which includes stop loss settings quite similar to what you've described.

iRobot - November 11, 2013 @ 14:16

Hi nobulart,

any success? Thx

nobulart - November 12, 2013 @ 10:08

Hi @iRobot. Sorry, not yet. Other committments have kept me from being able to work on this for the past week. Gotta pay the piper for today before I can focus on the retirement plans again.

iRobot - November 13, 2013 @ 18:35

Hi nobulart. Could you get in contact with me? vivorobot@gmail.com

I'd like to discuss some things with you.

Victor - November 16, 2013 @ 00:44

Got a lot of errors: Index seems to be out of range in Calculate.

 

Kate - November 19, 2013 @ 02:37

Backtesting can be a bit faster if you do not call ChartRefresh() on every tick. Call i when you not in backtesting mode only (check IsBacktesting property).

rickster87 - November 19, 2013 @ 14:33

First off, thank you Nobulart for sharing this algo! Has anyone had any luck with running this live? I'm seeing good returns when backtesting GBPJPY @ 5min and EURUSD @ 10min.

@Kate, where would you add "IsBacktesting" in the code?

Also is anyone running this algo on a VPS?

Kate - November 20, 2013 @ 13:54

if (IsBacktesting) ChartRefresh()

Victor - November 20, 2013 @ 19:33

... but love this one. Not because of the results, cause they're like all the results from all other robots: unreliable because of the need to use martingale.

But the wave pattern and the trading system really are nice and nifty coded. My compliments.

Scientist - January 17, 2014 @ 03:09

Hello @nobulart

Please help me to find the problem: no matter what i do, i can not get it build!, or to get it build with no errors.

I have downloaded both indicators and have them build as well. no errors here.
So manually adding the references to the top of the code instead of first 2 lines, but it says that:

1)the file of the   BelkhayatePolynomialRegression is missing, but its is not!
or
2) builds it with 23 errors
Error CS0618: 'cAlgo.API.Internals.IAccount.Positions' is obsolete: 'Use Positions instead'
Error CS0618: 'cAlgo.API.Internals.ITrade.ModifyPosition(cAlgo.API.Position, double?, double?)' is obsolete: 'Use ModifyPosition instead'

 

I'd appreciated if You could have just send me all the needed files from Your directory to coldfrog@mail.ru
ill try to set it running, can You?

Spotware Team - January 17, 2014 @ 11:16

Hello,

Those are actually warnings not errors. We will fix that in the future releases. 
You can use the downloaded cBot without even building it.
The new method of downloading and installing cBots and Indicators does not require you to build them unless you need to modify the code.

 

chiripacha - February 10, 2014 @ 20:17

Hi@nobulart,

I managed to start the "beast" to fight the USDEUR upt to now successfully. I could transfer almost all of the old API's but the following not. Although The Golden Dragon is working ok I'd like to know the new forms. Could you show me the transformed sentences.

Thks

chiripacha

ps In calgo I'm a greenhorn

Error CS0618: "cAlgo.API.Requests.MarketOrderRequest" ist veraltet: "Use ExecuteMarketOrder instead"

Error CS0618: "cAlgo.API.Internals.ITrade.Close(cAlgo.API.Position)" ist veraltet: "Use ClosePosition instead"

Error CS0618: "cAlgo.API.Requests.MarketOrderRequest" ist veraltet: "Use ExecuteMarketOrder instead"

Error CS0618: "cAlgo.API.Requests.MarketOrderRequest" ist veraltet: "Use ExecuteMarketOrder instead"

oddieee - March 06, 2014 @ 12:53

Hi all,

the posted gold/usd settings show huge losses in recent months in backtesting. Does anyone have solution to prevent such losses or have a functioning, relatively stable strategy for golden dragon on any pair?please send some ideas in email oddieeee@gmail.com

Thanks!

Psynzo - April 10, 2014 @ 18:44

Hi, really nice bot well played :)

My only one problem is the "Buy wait on Loss" seem to not work in backtesting. do you have a solution ? :)

(oddieee the Buy wait loss could be ur solution to :p )

alibuc - May 09, 2014 @ 06:02

Hey, thanks for developing this bot and sharing!

ThePhantomRaven - May 19, 2014 @ 08:35

Thank you for developing an amazing bot.

I have updated the two new reference and the bot was working fine one day. (except buy wait on loss was not triggering)

Next day I got this error and can not use the bot anymore.

I attempted reinstalling.

Error CS0246: The type or namespace name 'BelkhayatePRC' could not be found (are you missing a using directive or an assembly reference?)

I wonder if it has anything to do with the cAlgo update.

Again thanks for the great bot and looking forward to further update.

maithai - June 08, 2014 @ 09:49

@nobulart - i get different results when backtesting, which is incredibly frustrating especially when you think its almost on the sweet spot. is there a way to do something about this in calgo?

ThePhantomRaven - June 28, 2014 @ 03:14

This is such a great robot.

It would be great if you could fix the Martingale Recursion problem.

I know you are very busy.

Im also trying to fix the martingale problem my self but I have just started learning C# code.

Thank you very much for your time developing the robot and sharing with us.

Also I thought it might improve if Belkhayate timing indicator is used as well?

Just an idea but I'm a newbie so I'm not sure.

aisaac - September 13, 2014 @ 17:37

good morning, is possible update the code ?  

when load the indicator with manage references, rename the indicator Belkhayate Polynomial Regression in BelkhayatePRC

and when build in build result return this error.

 

 

Error CS0618: 'cAlgo.API.Internals.IAccount.Positions' è obsoleto: 'Use Positions instead'

Error CS0618: 'cAlgo.API.Internals.ITrade.ModifyPosition(cAlgo.API.Position, double?, double?)' è obsoleto: 'Use ModifyPosition instead'

Error CS0618: 'cAlgo.API.Internals.ITrade.ModifyPosition(cAlgo.API.Position, double?, double?)' è obsoleto: 'Use ModifyPosition instead'

 

ecc......

thanks

Kaworu - November 10, 2014 @ 15:52

hi

a little bit of help here. ive downloaded the bot and successfully installed it but when i try to run it, it seems that it doesnt take any trades. can someone point it out to me what i may be doing wrong here?

 

thanks

Kaworu - December 03, 2014 @ 12:14

nobody is using this bot anymore?

I've been playing with this for weeks as evidently stated from my last post. my pair is eurusd and nzdusd

ive noticed that i get more trades on a single day than a week, can somebody explain that to me?

ive also noticed that the bot enters trades within the CoG even though ive stated that it should always enter on Target Entry 2

I'd probably try and fiddle with the bot's coding this weekend to see if it fits my strategy as well.

Luckyman86 - December 13, 2014 @ 19:28

Hi Kaworu - im currently trading XAU/USD with a tweaked version of this on a 5min . Only been live for a short period of time. If you would like to get in touch and share ideas let me know happy do to so. 

Alex 

 

 

Kaworu - December 19, 2014 @ 04:14

im actually conceptualizing a new strategy that id like to include in this ea

im trading usd-jpy/eur/gbp/nzd and the volatility on these 3 is surprising at times. so what im trying to do is if a certain bar suddenly reaches a certain point/level in the chart at a given time, it will open a trade going that direction.

but right now, the ea works fine in 5mins at 240 period,  3degrees and HMA 3.

anadin - January 22, 2015 @ 10:43

Sorry for being late to the party but it would seem the indicators are not in the download? 

anadin - January 22, 2015 @ 13:32

I did download the linked ones but their names are different and the description seems to imply that the two indicators would come with the bot.

rtzzzzzz - February 15, 2015 @ 21:34

1. Download the file from this thread and double-click.

2. In cTrader find the Robot and choose to edit in cAlgo (this will open it in cAlgo)

3. In cAlgo navigate to Indicators and rename the indicator Belkhayate Polynomial Regression into BelkhayatePRC (right-click and rename)

4. Link references to both as described http://ctdn.com/forum/whats-new/2713

I succeeded in compiling it ... no idea if it works as of today ... it's sunday :P

 

Luckyman86 - February 24, 2015 @ 10:31

"Buy wait on loss" does not work back testing. Does anyone know how to fix this ? I'm been testing this bot live through a VPS for a few months and it's producing great results and the buy wait on loss seems to work live ! Would just be good to have a backtest with results reflecting this indicator working 

Eduardo_Cerejo - July 28, 2015 @ 03:16

Getting a build error:

Error CS0246: The type or namespace name 'HMA' could not be found (are you missing a using directive or an assembly reference?)

Does anyone know how to fix this?

ironmine - October 03, 2015 @ 05:57

Hi Nobulart!
 

Your code provides functionality to choose whether to trade or not on Friday. Can you please add also the function to choose which hours to trade and which not?

Thank you very much for your cBot and your hard work.

ironmine - October 04, 2015 @ 03:31

Hello Nobulart!

Can you please also provide an option to let positions be closed automatically after a predetermined period of time?

Thanks again!
 

GS66 - December 18, 2015 @ 20:07

This is a "monster" algo :-) and clearly Nobulart has made an awesome work.  Users should use more forward test in demo then backtesting. Possible variants to an already fantastic bot: Insert the shift forward  parameter for n. of bars to the Polynomial regression, this would greatly reduce the repaint. Link the profit target to the newly forwarded PRC. 

 

 

 

 

rodbryant300 - October 31, 2016 @ 18:38

Hey Nobulart

Your Bot is really good but Im having one issue with the bot. I keep getting error failed "Trading_Bad_Stops". How can I fix this?

rodbryant300 - November 02, 2016 @ 02:02

Hey GS66

Could you show how to put what you mentioned into the code?

noormizzy - November 09, 2016 @ 14:34

anyone still using it ?

rodbryant300 - November 10, 2016 @ 22:03

Currently I am using it and it has made decent profit. Out of 70 trades only lost 3 but those were doing this election, markets going crazy. The only problem im having is the repaint. The equity drawdown might be too high for most around 15% but that depends on whats in your account.

halij663 - May 20, 2017 @ 17:15

hy,

please can you make this cbot with systeme Alembex not with Martingale and thank you when you make this for all

this is systeme Alembex here:https://ctdn.com/algos/cbots/show/251

sonay0201@gmail.com - November 09, 2017 @ 21:41

thanks

anthony21xu - September 18, 2018 @ 15:40

Hi, i know you have been busy & non active in a while. After optimizing so many settings with my broker's commision & all. i finally found several settings i like. But when running it. doesn't make any entry At all. Please help on what i got wrong... is there a code change to open position?

4.17