atrader's avatar
atrader
"A lie gets halfway around the world before the truth has a chance to get its pants on." - Sir Winston Churchill
atrader's avatar

Info

Username:atrader
Name:atrader
Member since: 10 Oct 2012

Favorite symbols:

EURUSD

About

None

Signature

"A lie gets halfway around the world before the truth has a chance to get its pants on." - Sir Winston Churchill

Last Algorithm Comments

@Super Profit:  18 Sep 2013, 12:42


Hi, I updated the code. I modified to have an entry for take profit as well and also fixed stop loss for the sell signal. Thanks for the comments.

@Fibonacci Robot:  17 Sep 2013, 10:54


You have the files included in the zip that you downloaded. You need to put them in the cAlgo/Sources/Indicators folder which is inside your documents folder. Build the indicators and then in the robot view click the button "Add Reference" and add both indicators.  

@Heikin-Ashi Smoothed:  31 Jul 2013, 14:49


The instructions from the "How to install link" didn't help?

@TradingNewsRobot with Trailing Stop Loss:  30 Jul 2013, 11:41


No, I was wrong, it should be UTC. see /algos/robots/show/199 (original code)

@TradingNewsRobot with Trailing Stop Loss:  30 Jul 2013, 11:37


Server.Time used to be broker time and now it is UTC. So, I think it should be set to broker time UTC+3. /forum/whats-new/993

@Fisher:  22 May 2013, 17:25


Please download it again, I made some modifications. Thanks for pointing that out.

Last Forum Posts

@Risk based lot sizes:  28 Jan 2014, 18:02


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

namespace cAlgo.Robots
{
    [Robot]
    public class OnePercentRiskBot : Robot
    {
        private Rates _rate = Rates.Direct;

        [Parameter(DefaultValue = "Volume on Risk")]
        public string MyLabel { get; set; }

        [Parameter("0:Buy 1:Sell", DefaultValue = 0)]
        public int TType { get; set; }

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

        [Parameter("Take Profit", DefaultValue = 10, MinValue = 0, MaxValue = 500)]
        public int TakeProfit { get; set; }

        // Modify DefaultValue, MinValue, MaxValue
        [Parameter("Risk Percentage", DefaultValue = 1, MinValue = 0.01, MaxValue = 5)]
        public double RiskPercent { get; set; }


        protected TradeType Trade_Type
        {
            get
            {
                return
                    TType == 0 ? TradeType.Buy : TradeType.Sell;
            }
        }

        protected override void OnStart()
        {
            Positions.Opened += PositionsOnOpened;
            // Initialize _rate variable
            SetRate();
            int volume = GetVolume();
            Print("Volume = {0}", volume);
            ExecuteMarketOrder(Trade_Type, Symbol, volume, MyLabel);
        }

        private void PositionsOnOpened(PositionOpenedEventArgs args)
        {
            double risk = 0;
            foreach (Position position in Positions)
            {
                Symbol symbol = MarketData.GetSymbol(position.SymbolCode);
                if (position.StopLoss != null)
                {
                    double stopLoss = Math.Abs(position.EntryPrice - (double) position.StopLoss)/symbol.PipSize;
                    risk += stopLoss*symbol.PipValue*position.Volume - position.Commissions*2;
                }
            }
            Print(risk);
        }

        private int GetVolume()
        {
            double risk = RiskPercent/100.0;
            double volume;

            switch (_rate)
            {
                case Rates.Direct:
                    volume = Account.Equity*risk/(StopLoss*Symbol.PipValue);
                    break;
                case Rates.Indirect:
                    double stopLossPrice = Trade_Type == TradeType.Buy
                                               ? Symbol.Ask + StopLoss*Symbol.PipSize
                                               : Symbol.Bid - StopLoss*Symbol.PipSize;
                    volume = Account.Equity*risk*stopLossPrice/(StopLoss*Symbol.PipValue);
                    break;
                default: // pending
                    volume = 0;
                    break;
            }

            return (int) Symbol.NormalizeVolume(volume);
        }

        private void SetRate()
        {
            switch (Symbol.Code)
            {
                case "EURUSD":
                case "GBPUSD":
                case "AUDUSD":
                case "NZDUSD":
                    _rate = Rates.Direct;
                    break;
                case "USDJPY":
                case "USDCHF":
                case "USDCAD":
                    _rate = Rates.Indirect;
                    break;
                default:
                    _rate = Rates.Cross;
                    break;
            }
        }

        #region Nested type: Rates

        private enum Rates
        {
            Direct,
            Indirect,
            Cross
        };

        #endregion
    }
}

Maybe this is a start...

@Risk on all open positions:  28 Jan 2014, 11:18


Sorry that would be subtract because commissions are negative so:

risk += stopLoss * symbol.PipValue * position.Volume - position.Commissions*2;

@Risk on all open positions:  28 Jan 2014, 11:16


Add position.Commissions * 2 to the risk

risk += stopLoss * symbol.PipValue * position.Volume + position.Commissions*2;

@Risk on all open positions:  24 Jan 2014, 12:25


protected override void OnStart()
{
    double risk = 0;
    foreach (var position in Positions)
    {
        Symbol symbol = MarketData.GetSymbol(position.SymbolCode);
        if (position.StopLoss != null)
        {
            var stopLoss = Math.Abs(position.EntryPrice - (double)position.StopLoss) / symbol.PipSize;
            risk += stopLoss * symbol.PipValue * position.Volume;
        }

    }

    Print(risk);
    Stop();
}

I think that should work.

@Stop robot on expiring date:  21 Jan 2014, 16:43


You mean like this:

DateTime stopDate = new DateTime(2014, 01, 31);
if (Server.Time.Date == stopDate)
{
    Stop();
}

Add this in the beginning of the OnStart method so that it will prevent it from starting.

@Optimisation:  21 Jan 2014, 11:46


http://vote.spotware.com/forums/229166-ideas-and-suggestions-for-ctrader-and-calgo/suggestions/5356525-optimization

jobenb said:

Hi Spotware

First of all - Congrats on a platform with outstanding possibilities and potential.

We really need to be able to optimise our algos. It is really annoying not to be able to optimise and to try and do it manually is a complete waste of time.

Please can you tell us when we can expect a new version of cAlgo that will have the ability to optimise?

Thank you!

@Pop Quizzzzzzzz:  07 Jan 2014, 11:17


try:

double r = 5.0 / 100;
Print(r);

@How can I disable trade signals?:  19 Dec 2013, 11:17


It looks like the super profit indicator /algos/indicators/show/249

@BELKHAYATE PRC:  10 Dec 2013, 10:24


You can use DrawText to display text on the chart. If you choose H4 or above you can see the 2011 chart.

zemotoca said:

There configuring BELKHAYATE PRC indicator to display its parameters at the time for a stipulated period (120 periods for example), but it is presented in a chart since 2011?

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.
Average Daily Range
  2
  5
  3396
free  14 Nov 2013
A measure of volatility for the currency pair. The average daily range is the average of the daily range (High - Low) over a given number of days. It can be calculated over different periods.  
Draw Objects
  4
  5
  2854
free  12 Apr 2013
Draw Objects on the chart using unicode characters.
Super Profit
  19
  5
  14469
free  18 Sep 2013
Trend indicator with trigger alerts. 
Dom Cycle
  1
  0
  2478
free  29 Mar 2013
Dom Cycle.
Fisher
  3
  0
  3595
free  22 May 2013
free  12 Oct 2012
The Empirical Mode Decomposition Indicator (EMD. According to the article "Empirical Mode Decomposition" in the March 2010 Issue of Stocks and Commodities magazine, by John F. Ehlers and Ric Way, when the Trend (Red) rises above the Average Peaks(Green), the market is in an uptrend, when it is below the Average Valleys(Blue), the market is in a downtrend, and when it's between the two, the market is in cycle mode.    
JMA
  0
  5
  3014
free  10 Oct 2012
Jurik Moving Average.  
Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
free  10 Dec 2013
Modified robot to work on two symbols see /forum/cbot-support/2045?page=1#2 The robot starts by making a trade in the direction of the last two completed bars if the same. Sets take profit initially and then trails with stop loss. The subsequent trades, up to a max number of trades (input), are in the same direction of the first trade are entered based on the current price compared to the last entry price. If a trade is deleted manually the robot will start from the beginning. Currently not supported in backtesting (GetSymbol not supported)  
free  28 Jun 2013
This is a collaborative work  based on a forum post : /forum/cbot-support/1109 Any suggestions welcome. 
forex
  10
  0
  2524
free  19 Apr 2013
Regarding /forum/cbot-support/753. 
free  17 Apr 2013
Concerning this post: /forum/cbot-support/745