Leonardo Hermoso
Leonardo Hermoso's avatar

Info

Username:hermoso
Name:Leonardo Hermoso
Member since: 23 Jul 2012
Country:Brazil

Favorite symbols:

EURUSD, USDCHF

About

None

Signature

None

Last Algorithm Comments

@Fibonacci Robot:  27 Mar 2014, 00:20


@fwends you are right my friend! I ll ask in the forum to see what happened!

Im rewriting this codes, in a few day ill repost it!

@Fibonacci Robot:  18 Mar 2014, 02:09


Did you try to double click the file? .algo file will install the indicators

@MaxMin Bands:  23 Jul 2012, 18:42


Hello, tks a lot for this code. I having a problem here. How do i call custom indicators inside my robot? I dont know hot to initialize this. tks

Last Forum Posts

@About brokers:  05 Mar 2014, 18:08


What about traders first talk?

Why not have a session to discuss this? This is happening more often, i had the same problem with *MODERATED* with a open position and it goes to stoploss...  I complained and  they refunded me!

This must be a fair game... I think part of fair things is to everybody to know and follow the rules, we must exchange information about bad broker or bad pratices, and i cannot see a better place than here!

So thinks TRADERS FIRST, not brokers!

@Withdrawal via code:  21 Feb 2014, 05:33


Is there a way to realize this? Can i set something like this

if (Account.balance > 50000)

          Net = Account.balance -50000;

          Dealer.Withdrawal(Net,"Neteller",AccountNumber);

Tks in advance

@Trade Manager:  14 Feb 2014, 06:21


yes, its possible!

@robot communication:  14 Feb 2014, 00:13


You can use ZEROMQ is the easy and reliable way to do 

here is an example: 

Server Side:

using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using ZMQ;

         List<string> fields = new List<string> 
        {
            "Open",
            "High",
            "Low",
            "Close"
        };   

     protected override void OnStart()
        {
            int total = 0;
            using (var context = new Context(1))
            {
                using (Socket worker = context.Socket(SocketType.DEALER))
                {
                    worker.StringToIdentity(Symbol.Code, Encoding.Unicode);
                    worker.Connect("tcp://127.0.0.1:5999");



                    while (true)
                    {
                        string request = worker.Recv(Encoding.Unicode);
                        if (request.Equals("FIM"))
                            total++;
                        // Print(total);



                        for (int idx = 0; idx < fields.Count(); idx++)
                        {
                            if (request.Equals(fields[idx]))
                            {
                                var valor_ = valor(request, Convert.ToInt32(worker.Recv(Encoding.Unicode)));

                                worker.Send(valor_, Encoding.Unicode);
                                break;
                            }
                        }


                    }                    

                }

            }


        }

         private String valor(string request, int periodo)
        {

            if (String.Equals(request, "Open"))
                return Convert.ToString(MarketSeries.Open.Last(periodo));
            if (String.Equals(request, "High"))
                return Convert.ToString(MarketSeries.High.Last(periodo));
            if (String.Equals(request, "Low"))
                return Convert.ToString(MarketSeries.Low.Last(periodo));
            if (String.Equals(request, "Close"))
                return Convert.ToString(MarketSeries.Close.Last(periodo));
            Print("cagada");
            return Convert.ToString(0);
        }

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

Client Side

         protected override void OnStart()
        {

            using (var context = new Context(1))
            {
                using (Socket requester = context.Socket(SocketType.ROUTER))
                {
                    requester.Bind("tcp://*:5999");
                    System.Threading.Thread.Sleep(1000);
                    double high = consulta(context,requester,"USDJPY","High",100)
                }
            }

}

         private double consulta(ZMQ.Socket requester, string Ativo, String Series, int periodo)
        {

            requester.SendMore(Ativo, Encoding.Unicode);
            requester.SendMore(Series, Encoding.Unicode);
            requester.Send(Convert.ToString(periodo), Encoding.Unicode);
            requester.Recv();
            string buffer = requester.Recv(Encoding.Unicode);
            return Convert.ToDouble(buffer);

        }

}

you can get zeromq via nuget.. create a new project in visual studio download via nuget and then reference it in your calgo project outside de visual studio,, you do this just to get the files

as clrzmq is a wrapper of the libzmq the libzmq must be in the calgo path... control alt del... the click with the right button on calgo process... then go to file or folder(sorry my windows is in pt-br) something like that.. then copy the libzmq to this folder

This is an example of as many robots as you want exchanging quotes... pay attetion in this topology the router must wait for the dealers to connect... i really sugest you to go to http://zguide2.zeromq.org/

here are my references


//#reference: ..\..\x64\Release\clrzmq.dll
//#reference: ..\..\x64\Release\clrzmq-ext.dll

i hope this helps you

@PLEASE HELP Crashed in OnTick with NullReferenceException:  11 Feb 2014, 01:15


The error is in this two lines

        //Local declaration
            TriState _Close_BUY_Positions = new TriState();
            TriState _Close_SELL_Positions = new TriState();

You try to instance a object from a class TriState but there is no reference to it! You must use "add reference"  and look for the dll file that contains the TriState Class and then declare it.

using TriState or whatever the classname is!"

ninosgr said:

Can anyway help me with this code please? I built it with Quant as I am not a programmer, thus I cannot find the solution.

Thanks in advance!!!

10/02/2014 17:58:14.864 | Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object.

//+------------------------------------------------------------------+
//+                     Code generated using StrategyTune ver. 1.1.8 |
//+------------------------------------------------------------------+

using System;
using System.Threading;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.API.Requests;
using cAlgo.Indicators;


namespace cAlgo.Robots
{
    [Robot()]
    public class Prototype : Robot
    {

        [Parameter("StopLoss", DefaultValue = 0)]
        public double _StopLoss { get; set; }
        [Parameter("Take_Profit", DefaultValue = 0)]
        public double _Take_Profit { get; set; }
        [Parameter("OpenPositions", DefaultValue = 1)]
        public double _OpenPositions { get; set; }

        //Global declaration
        private MacdHistogram i_MACD;
        private MacdHistogram i_MACD_2;
        double? _Arithmetic_2;
        bool _Compare_4;
        bool _Sell;
        bool _Buy;

        DateTime LastTradeExecution = new DateTime(0);

        protected override void OnStart()
        {
            i_MACD = Indicators.MacdHistogram(MarketSeries.Median, 34, 5, 9);
            i_MACD_2 = Indicators.MacdHistogram(MarketSeries.Median, 34, 5, 9);

        }

        protected override void OnTick()
        {
            if (Trade.IsExecuting)
                return;

            //Local declaration
            TriState _Close_BUY_Positions = new TriState();
            TriState _Close_SELL_Positions = new TriState();

            //Step 1
            _Arithmetic_2 = (_OpenPositions - (1));

            //Step 2

            //Step 3
            _Compare_4 = ((i_MACD.Histogram.Last(0) - (i_MACD_2.Histogram.Last(1))) > 0);

            //Step 4
            if (_Compare_4)
                _Close_BUY_Positions = _ClosePosition(2, Symbol.Code, 0.1);
            if (!_Compare_4)
                _Close_SELL_Positions = _ClosePosition(1, Symbol.Code, 0.1);

            //Step 5
            if (!(!(Number_of_Open_Trades(1) == _Arithmetic_2) && _Compare_4))
                _Sell = Sell(1, 0.1, 1, _StopLoss, 1, _Take_Profit, 5, 1, 0, "");
            if (!(!(Number_of_Open_Trades(2) == _Arithmetic_2) && !_Compare_4))
                _Buy = Buy(2, 0.1, 1, _StopLoss, 1, _Take_Profit, 5, 1, 0, "");

        }

        bool NoOrders(string symbolCode, double[] magicIndecies)
        {
            if (symbolCode == "")
                symbolCode = Symbol.Code;
            string[] labels = new string[magicIndecies.Length];
            for (int i = 0; i < magicIndecies.Length; i++)
            {
                labels[i] = "FxProQuant_" + magicIndecies[i].ToString("F0");
            }
            foreach (Position pos in Positions)
            {
                if (pos.SymbolCode != symbolCode)
                    continue;
                if (labels.Length == 0)
                    return false;
                foreach (var label in labels)
                {
                    if (pos.Label == label)
                        return false;
                }
            }
            foreach (PendingOrder po in PendingOrders)
            {
                if (po.SymbolCode != symbolCode)
                    continue;
                if (labels.Length == 0)
                    return false;
                foreach (var label in labels)
                {
                    if (po.Label == label)
                        return false;
                }
            }
            return true;
        }

        TriState _OpenPosition(double magicIndex, bool noOrders, string symbolCode, TradeType tradeType, double lots, double slippage, double? stopLoss, double? takeProfit, string comment)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            if (noOrders && Positions.Find("FxProQuant_" + magicIndex.ToString("F0"), symbol) != null)
                return new TriState();
            if (stopLoss < 1)
                stopLoss = null;
            if (takeProfit < 1)
                takeProfit = null;
            if (symbol.Digits == 5 || symbol.Digits == 3)
            {
                if (stopLoss != null)
                    stopLoss /= 10;
                if (takeProfit != null)
                    takeProfit /= 10;
                slippage /= 10;
            }
            int volume = (int)(lots * 100000);
            if (!ExecuteMarketOrder(tradeType, symbol, volume, "FxProQuant_" + magicIndex.ToString("F0"), stopLoss, takeProfit, slippage, comment).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            return true;
        }

        TriState _SendPending(double magicIndex, bool noOrders, string symbolCode, PendingOrderType poType, TradeType tradeType, double lots, int priceAction, double priceValue, double? stopLoss, double? takeProfit,
        DateTime? expiration, string comment)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            if (noOrders && PendingOrders.__Find("FxProQuant_" + magicIndex.ToString("F0"), symbol) != null)
                return new TriState();
            if (stopLoss < 1)
                stopLoss = null;
            if (takeProfit < 1)
                takeProfit = null;
            if (symbol.Digits == 5 || symbol.Digits == 3)
            {
                if (stopLoss != null)
                    stopLoss /= 10;
                if (takeProfit != null)
                    takeProfit /= 10;
            }
            int volume = (int)(lots * 100000);
            double targetPrice;
            switch (priceAction)
            {
                case 0:
                    targetPrice = priceValue;
                    break;
                case 1:
                    targetPrice = symbol.Bid - priceValue * symbol.TickSize;
                    break;
                case 2:
                    targetPrice = symbol.Bid + priceValue * symbol.TickSize;
                    break;
                case 3:
                    targetPrice = symbol.Ask - priceValue * symbol.TickSize;
                    break;
                case 4:
                    targetPrice = symbol.Ask + priceValue * symbol.TickSize;
                    break;
                default:
                    targetPrice = priceValue;
                    break;
            }
            if (expiration.HasValue && expiration.Value.Ticks == 0)
                expiration = null;
            if (poType == PendingOrderType.Limit)
            {
                if (!PlaceLimitOrder(tradeType, symbol, volume, targetPrice, "FxProQuant_" + magicIndex.ToString("F0"), stopLoss, takeProfit, expiration, comment).IsSuccessful)
                {
                    Thread.Sleep(400);
                    return false;
                }
                return true;
            }
            else if (poType == PendingOrderType.Stop)
            {
                if (!PlaceStopOrder(tradeType, symbol, volume, targetPrice, "FxProQuant_" + magicIndex.ToString("F0"), stopLoss, takeProfit, expiration, comment).IsSuccessful)
                {
                    Thread.Sleep(400);
                    return false;
                }
                return true;
            }
            return new TriState();
        }

        TriState _ModifyPosition(double magicIndex, string symbolCode, int slAction, double slValue, int tpAction, double tpValue)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            var pos = Positions.Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (pos == null)
                new TriState();
            double? sl, tp;
            if (slValue == 0)
                sl = null;
            else
            {
                switch (slAction)
                {
                    case 0:
                        sl = pos.StopLoss;
                        break;
                    case 1:
                        if (pos.TradeType == TradeType.Buy)
                            sl = pos.EntryPrice - slValue * symbol.TickSize;
                        else
                            sl = pos.EntryPrice + slValue * symbol.TickSize;
                        break;
                    case 2:
                        sl = slValue;
                        break;
                    default:
                        sl = pos.StopLoss;
                        break;
                }
            }
            if (tpValue == 0)
                tp = null;
            else
            {
                switch (tpAction)
                {
                    case 0:
                        tp = pos.TakeProfit;
                        break;
                    case 1:
                        if (pos.TradeType == TradeType.Buy)
                            tp = pos.EntryPrice + tpValue * symbol.TickSize;
                        else
                            tp = pos.EntryPrice - tpValue * symbol.TickSize;
                        break;
                    case 2:
                        tp = tpValue;
                        break;
                    default:
                        tp = pos.TakeProfit;
                        break;
                }
            }
            if (!ModifyPosition(pos, sl, tp).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            return true;
        }

        TriState _ModifyPending(double magicIndex, string symbolCode, int slAction, double slValue, int tpAction, double tpValue, int priceAction, double priceValue, int expirationAction, DateTime? expiration)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            var po = PendingOrders.__Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (po == null)
                new TriState();
            double targetPrice;
            double? sl, tp;
            if (slValue == 0)
                sl = null;
            else
            {
                switch (slAction)
                {
                    case 0:
                        sl = po.StopLoss;
                        break;
                    case 1:
                        if (po.TradeType == TradeType.Buy)
                            sl = po.TargetPrice - slValue * symbol.TickSize;
                        else
                            sl = po.TargetPrice + slValue * symbol.TickSize;
                        break;
                    case 2:
                        sl = slValue;
                        break;
                    default:
                        sl = po.StopLoss;
                        break;
                }
            }
            if (tpValue == 0)
                tp = null;
            else
            {
                switch (tpAction)
                {
                    case 0:
                        tp = po.TakeProfit;
                        break;
                    case 1:
                        if (po.TradeType == TradeType.Buy)
                            tp = po.TargetPrice + tpValue * symbol.TickSize;
                        else
                            tp = po.TargetPrice - tpValue * symbol.TickSize;
                        break;
                    case 2:
                        tp = tpValue;
                        break;
                    default:
                        tp = po.TakeProfit;
                        break;
                }
            }
            switch (priceAction)
            {
                case 0:
                    targetPrice = po.TargetPrice;
                    break;
                case 1:
                    targetPrice = priceValue;
                    break;
                case 2:
                    targetPrice = po.TargetPrice + priceValue * symbol.TickSize;
                    break;
                case 3:
                    targetPrice = po.TargetPrice - priceValue * symbol.TickSize;
                    break;
                case 4:
                    targetPrice = symbol.Bid - priceValue * symbol.TickSize;
                    break;
                case 5:
                    targetPrice = symbol.Bid + priceValue * symbol.TickSize;
                    break;
                case 6:
                    targetPrice = symbol.Ask - priceValue * symbol.TickSize;
                    break;
                case 7:
                    targetPrice = symbol.Ask + priceValue * symbol.TickSize;
                    break;
                default:
                    targetPrice = po.TargetPrice;
                    break;
            }
            if (expiration.HasValue && expiration.Value.Ticks == 0)
                expiration = null;
            if (expirationAction == 0)
                expiration = po.ExpirationTime;
            if (!ModifyPendingOrder(po, targetPrice, sl, tp, expiration).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            return true;
        }

        TriState _ClosePosition(double magicIndex, string symbolCode, double lots)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            var pos = Positions.Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (pos == null)
                new TriState();
            TradeResult result;
            if (lots == 0)
            {
                result = ClosePosition(pos);
            }
            else
            {
                int volume = (int)(lots * 100000);
                result = ClosePosition(pos, volume);
            }
            if (!result.IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            return true;
        }

        TriState _DeletePending(double magicIndex, string symbolCode)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            var po = PendingOrders.__Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (po == null)
                new TriState();
            if (!CancelPendingOrder(po).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            return true;
        }

        bool _OrderStatus(double magicIndex, string symbolCode, int test)
        {
            Symbol symbol = (Symbol.Code == symbolCode) ? Symbol : MarketData.GetSymbol(symbolCode);
            var pos = Positions.Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (pos != null)
            {
                if (test == 1)
                    return true;
                if (test == 3)
                    return pos.TradeType == TradeType.Buy;
                if (test == 4)
                    return pos.TradeType == TradeType.Sell;
            }
            var po = PendingOrders.__Find("FxProQuant_" + magicIndex.ToString("F0"), symbol);
            if (po != null)
            {
                if (test == 2)
                    return true;
                if (test == 3)
                    return po.TradeType == TradeType.Buy;
                if (test == 4)
                    return po.TradeType == TradeType.Sell;
                if (test == 5)
                    return po.OrderType == PendingOrderType.Limit;
                if (test == 6)
                    return po.OrderType == PendingOrderType.Stop;
            }
            return false;
        }

        int TimeframeToInt(TimeFrame tf)
        {
            if (tf == TimeFrame.Minute)
                return 1;
            else if (tf == TimeFrame.Minute2)
                return 2;
            else if (tf == TimeFrame.Minute3)
                return 3;
            else if (tf == TimeFrame.Minute4)
                return 4;
            else if (tf == TimeFrame.Minute5)
                return 5;
            else if (tf == TimeFrame.Minute10)
                return 10;
            else if (tf == TimeFrame.Minute15)
                return 15;
            else if (tf == TimeFrame.Minute30)
                return 30;
            else if (tf == TimeFrame.Hour)
                return 60;
            else if (tf == TimeFrame.Hour4)
                return 240;
            else if (tf == TimeFrame.Daily)
                return 1440;
            else if (tf == TimeFrame.Weekly)
                return 10080;
            else if (tf == TimeFrame.Monthly)
                return 43200;
            return 1;
        }

        TriState Sell(double magicIndex, double Lots, int StopLossMethod, double stopLossValue, int TakeProfitMethod, double takeProfitValue, double Slippage, double MaxOpenTrades, double MaxFrequencyMins, string TradeComment)
        {
            double? stopLossPips, takeProfitPips;
            int numberOfOpenTrades = 0;
            var res = new TriState();

            foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol))
            {
                numberOfOpenTrades++;
            }

            if (MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades)
                return res;

            if (MaxFrequencyMins > 0)
            {
                if (((TimeSpan)(Server.Time - LastTradeExecution)).TotalMinutes < MaxFrequencyMins)
                    return res;

                foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol))
                {
                    if (((TimeSpan)(Server.Time - pos.EntryTime)).TotalMinutes < MaxFrequencyMins)
                        return res;
                }
            }

            int pipAdjustment = (int)(Symbol.PipSize / Symbol.TickSize);

            if (stopLossValue > 0)
            {
                if (StopLossMethod == 0)
                    stopLossPips = stopLossValue / pipAdjustment;
                else if (StopLossMethod == 1)
                    stopLossPips = stopLossValue;
                else
                    stopLossPips = (stopLossValue - Symbol.Bid) / Symbol.PipSize;
            }
            else
                stopLossPips = null;

            if (takeProfitValue > 0)
            {
                if (TakeProfitMethod == 0)
                    takeProfitPips = takeProfitValue / pipAdjustment;
                else if (TakeProfitMethod == 1)
                    takeProfitPips = takeProfitValue;
                else
                    takeProfitPips = (Symbol.Bid - takeProfitValue) / Symbol.PipSize;
            }
            else
                takeProfitPips = null;

            Slippage /= pipAdjustment;

            long volume = Symbol.NormalizeVolume(Lots * 100000, RoundingMode.ToNearest);

            if (!ExecuteMarketOrder(TradeType.Sell, Symbol, volume, "FxProQuant_" + magicIndex.ToString("F0"), stopLossPips, takeProfitPips, Slippage, TradeComment).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }

            LastTradeExecution = Server.Time;
            return true;
        }


        TriState Buy(double magicIndex, double Lots, int StopLossMethod, double stopLossValue, int TakeProfitMethod, double takeProfitValue, double Slippage, double MaxOpenTrades, double MaxFrequencyMins, string TradeComment)
        {
            double? stopLossPips, takeProfitPips;
            int numberOfOpenTrades = 0;
            var res = new TriState();

            foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol))
            {
                numberOfOpenTrades++;
            }

            if (MaxOpenTrades > 0 && numberOfOpenTrades >= MaxOpenTrades)
                return res;

            if (MaxFrequencyMins > 0)
            {
                if (((TimeSpan)(Server.Time - LastTradeExecution)).TotalMinutes < MaxFrequencyMins)
                    return res;

                foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol))
                {
                    if (((TimeSpan)(Server.Time - pos.EntryTime)).TotalMinutes < MaxFrequencyMins)
                        return res;
                }
            }

            int pipAdjustment = (int)(Symbol.PipSize / Symbol.TickSize);

            if (stopLossValue > 0)
            {
                if (StopLossMethod == 0)
                    stopLossPips = stopLossValue / pipAdjustment;
                else if (StopLossMethod == 1)
                    stopLossPips = stopLossValue;
                else
                    stopLossPips = (Symbol.Ask - stopLossValue) / Symbol.PipSize;
            }
            else
                stopLossPips = null;

            if (takeProfitValue > 0)
            {
                if (TakeProfitMethod == 0)
                    takeProfitPips = takeProfitValue / pipAdjustment;
                else if (TakeProfitMethod == 1)
                    takeProfitPips = takeProfitValue;
                else
                    takeProfitPips = (takeProfitValue - Symbol.Ask) / Symbol.PipSize;
            }
            else
                takeProfitPips = null;

            Slippage /= pipAdjustment;
            long volume = Symbol.NormalizeVolume(Lots * 100000, RoundingMode.ToNearest);

            if (!ExecuteMarketOrder(TradeType.Buy, Symbol, volume, "FxProQuant_" + magicIndex.ToString("F0"), stopLossPips, takeProfitPips, Slippage, TradeComment).IsSuccessful)
            {
                Thread.Sleep(400);
                return false;
            }
            LastTradeExecution = Server.Time;
            return true;
        }


        int Number_of_Open_Trades(double magicIndex)
        {
            int res = 0;
            foreach (Position pos in Positions.FindAll("FxProQuant_" + magicIndex.ToString("F0"), Symbol))
            {
                res++;
            }
            return res;
        }

    }
}

public struct TriState
{
    public static readonly TriState NonExecution = new TriState(0);
    public static readonly TriState False = new TriState(-1);
    public static readonly TriState True = new TriState(1);
    sbyte value;
    TriState(int value)
    {
        this.value = (sbyte)value;
    }
    public bool IsNonExecution
    {
        get { return value == 0; }
    }
    public static implicit operator TriState(bool x)
    {
        return x ? True : False;
    }
    public static TriState operator ==(TriState x, TriState y)
    {
        if (x.value == 0 || y.value == 0)
            return NonExecution;
        return x.value == y.value ? True : False;
    }
    public static TriState operator !=(TriState x, TriState y)
    {
        if (x.value == 0 || y.value == 0)
            return NonExecution;
        return x.value != y.value ? True : False;
    }
    public static TriState operator !(TriState x)
    {
        return new TriState(-x.value);
    }
    public static TriState operator &(TriState x, TriState y)
    {
        return new TriState(x.value < y.value ? x.value : y.value);
    }
    public static TriState operator |(TriState x, TriState y)
    {
        return new TriState(x.value > y.value ? x.value : y.value);
    }
    public static bool operator true(TriState x)
    {
        return x.value > 0;
    }
    public static bool operator false(TriState x)
    {
        return x.value < 0;
    }
    public static implicit operator bool(TriState x)
    {
        return x.value > 0;
    }
    public override bool Equals(object obj)
    {
        if (!(obj is TriState))
            return false;
        return value == ((TriState)obj).value;
    }
    public override int GetHashCode()
    {
        return value;
    }
    public override string ToString()
    {
        if (value > 0)
            return "True";
        if (value < 0)
            return "False";
        return "NonExecution";
    }
}

public static class PendingEx
{
    public static PendingOrder __Find(this cAlgo.API.PendingOrders pendingOrders, string label, Symbol symbol)
    {
        foreach (PendingOrder po in pendingOrders)
        {
            if (po.SymbolCode == symbol.Code && po.Label == label)
                return po;
        }
        return null;
    }
}

@dll referencing:  25 Jan 2014, 17:57


Exactly the same problem here!

@New Trading API:  31 Dec 2013, 04:53


lec0456 said:

isn't the code in the example wrong? It reads:

foreach (var position in Positions)
{
    ClosePosition(positions);
}

There is o variable positions, right? shouldn't it be:

foreach (var position in Positions)
{
    ClosePosition(position);
}

???

isn't the thing you wrote wrong? It reads:

There is o variable positions, right? shouldn't it be:

There is no variable positions, right?

@Backtesting as method:  11 Sep 2013, 21:26


This is a great feature and is a step ahead of others plataforms. cAlgo will be the first to have this feature!

@Robot Optimization:  11 Sep 2013, 21:25


No support for this. Look this topic

/forum/calgo-support/1479

I coding matlab to optimize my parameters, but this is do a work that are already done, ctrader guys must release a method that call the backtest and then we can interact trough my variables to find the best value, but this is not possible right now

@cAlgo robots running 24 hrs:  05 Sep 2013, 07:58


Take a look in aws http://aws.amazon.com/pt/ you can leave a instance running calgo 24h there!

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.

No uploaded.

Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.
Fibonacci Robot
  19
  3
  8335
free  09 Jan 2014
#DONT FORGET TO REFERENCE THE TWO FILES IN THE CODE This robot trades the fibonacci bands.    I had sucess trading 4H GBPJPY with  AtrPeriod = 21 ; emaPeriod = 54 ; velperiod = 10 With a little optimization you can get good results for others symbols and timeframe. If you find something good, please share! If the trend is bullish the robot place a buy order in the first fibo band and a sell in the second band and vice-versa.