Topics
14 Jun 2013, 16:45
 5241
 8
07 May 2013, 12:38
 3295
 5
17 Dec 2012, 15:26
 0
 9372
 12
Replies

hichem
04 Jun 2013, 14:29

RE:
Sir2 said:

Hi:

I would like to install and run several cAlgo instances in parallel under the same Windows 8 user account.  For example: cAlgoA1 and cAlgoA2 for broker A and cAlgoB1 and cAlgoB2 for broker B.  Is there any way to keep this 4 installations independent (directories, settings, etc.).

Thanks in advance.

You can use a Virtual Machine such as : VMWare or Windows Virtual PC


@hichem

hichem
03 Jun 2013, 00:15

RE:
Delta_Gamma said:

Hi,


When I tried renaming it, I get the error:

 

A reference to C:\Users\myPc\Documents\cAlgo\Sources\Indicators\AdaptiveCG.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.

 

Sorry, I'm new to C# programming.

 

Thanks for the help.

dont just rename the algo file. you should first extract its content.


@hichem

hichem
02 Jun 2013, 14:47

The Algo file is a zip file. Extract it, inside of it you will find one or more assembly files. rename those files to the corresponding classes inside of them. reference them in Visual Studio.


@hichem

hichem
31 May 2013, 13:19

using cAlgo.API;
using cAlgo.API.Requests;
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace cAlgo.Robots
{
	[Robot]
	public class SIGLEVEL : Robot
	{
		private Position position;
		[Parameter(DefaultValue = 10000, MinValue = 1000)]
		public int InitialVolume
		{
			get;
			set;
		}
		[Parameter("Trade on bounce", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
		public int Tbounce
		{
			get;
			set;
		}
		[Parameter("Trade on breakout", DefaultValue = 0, MinValue = 0, MaxValue = 1)]
		public int Tbreak
		{
			get;
			set;
		}
		[Parameter("Stop Loss (pips)", DefaultValue = 20, MinValue = 0)]
		public int StopLoss
		{
			get;
			set;
		}
		[Parameter("TakeProfit (pips)", DefaultValue = 20, MinValue = 0)]
		public int TakeProfit
		{
			get;
			set;
		}
		[Parameter("Trailing Stop (pips)", DefaultValue = 20, MinValue = 0)]
		public int TrailingStop
		{
			get;
			set;
		}
		[Parameter("Breakeven (pips)", DefaultValue = 0, MinValue = 0)]
		public int Breakeven
		{
			get;
			set;
		}
		[Parameter("Trigger (pips)", DefaultValue = 5, MinValue = 0)]
		public int Trigger
		{
			get;
			set;
		}
		[Parameter("Start time (Hour)", DefaultValue = 0, MinValue = 0, MaxValue = 24)]
		public int Starttime
		{
			get;
			set;
		}
		[Parameter("Stop time (Hour)", DefaultValue = 24, MinValue = 0, MaxValue = 24)]
		public int Stoptime
		{
			get;
			set;
		}
		[Parameter(DefaultValue = 1, MinValue = 0, MaxValue = 50)]
		public int RiskPct
		{
			get;
			set;
		}
		[Parameter(DefaultValue = 500, MinValue = 100, MaxValue = 500)]
		public int Leverage
		{
			get;
			set;
		}
		[Parameter("Robot Code", DefaultValue = 0, MinValue = 222)]
		public int code
		{
			get;
			set;
		}
		protected override void OnStart()
		{
			string text = "SIG LEVEL";
			string message = "PLEASE UPDATE ME.Contact cAlgoFx";
			double num = 2013.0;
			double num2 = 8.0;
			double num3 = 30.0;
			double num4 = (double)base.Server.Time.Year;
			double num5 = (double)base.Server.Time.Month;
			double num6 = (double)base.Server.Time.Day;
			bool flag = num4 > num || (num4 >= num && num5 > num2) || (num4 >= num && num5 >= num2 && num6 > num3);
			if (flag)
			{
				base.Print(message, new object[0]);
				base.Stop();
			}
			base.ChartObjects.DrawText("SIG LEVEL", text, StaticPosition.BottomLeft, new Colors?(Colors.Lime));
			double num7 = base.MarketSeries.High.Maximum(base.MarketSeries.High.Count);
			double num8 = base.MarketSeries.Low.Minimum(base.MarketSeries.Low.Count);
			double num9 = base.Symbol.PipSize * 100.0;
			double num10 = Math.Floor(num8 / num9) * num9;
			for (double num11 = num10; num11 <= num7 + num9; num11 += num9)
			{
				base.ChartObjects.DrawHorizontalLine("line_" + num11, num11, Colors.Blue, 1.0, LineStyle.Solid);
			}
		}
		protected override void OnBar()
		{
			if (base.Trade.IsExecuting)
			{
				return;
			}
			int num = base.Account.Positions.Count((Position position) => position.Label == this.code.ToString() && position.SymbolCode == base.Symbol.Code);
			int index = base.MarketSeries.Low.Count - 2;
			int index2 = base.MarketSeries.High.Count - 2;
			int index3 = base.MarketSeries.Low.Count - 3;
			int index4 = base.MarketSeries.High.Count - 3;
			int index5 = base.MarketSeries.Close.Count - 3;
			int index6 = base.MarketSeries.Open.Count - 2;
			int index7 = base.MarketSeries.Close.Count - 2;
			double num2 = base.MarketSeries.Open[index6];
			double num3 = base.MarketSeries.Close[index7];
			double num4 = base.MarketSeries.High[index2];
			double num5 = base.MarketSeries.Low[index];
			double arg_114_0 = base.MarketSeries.High[index4];
			double arg_126_0 = base.MarketSeries.Low[index3];
			double arg_139_0 = base.MarketSeries.Close[index5];
			double arg_14A_0 = base.MarketSeries.High.LastValue;
			double arg_15B_0 = base.MarketSeries.Low.LastValue;
			double lastValue = base.MarketSeries.Close.LastValue;
			double arg_17E_0 = base.MarketSeries.Open.LastValue;
			double num6 = (double)base.Server.Time.Hour;
			double a = base.Account.FreeMargin * (double)this.RiskPct / 100.0 / (double)(this.InitialVolume / this.Leverage);
			double num7 = Math.Max(1.0, Math.Min(50.0, Math.Round(a)));
			double num8 = base.Symbol.PipSize * 100.0;
			Math.Floor(lastValue / num8);
			bool flag = num6 >= (double)this.Starttime && num6 < (double)this.Stoptime;
			bool flag2 = (base.Symbol.Digits == 4 && Math.Truncate(num2) > Math.Truncate(num5) && Math.Truncate(num3) > Math.Truncate(num5)) || (base.Symbol.Digits == 5 && Math.Truncate(num2 * 100.0) > Math.Truncate(num5 * 100.0) && Math.Truncate(num3 * 100.0) > Math.Truncate(num5 * 100.0));
			bool flag3 = (base.Symbol.Digits == 4 && Math.Truncate(num2) < Math.Truncate(num4) && Math.Truncate(num3) < Math.Truncate(num4)) || (base.Symbol.Digits == 5 && Math.Truncate(num2 * 100.0) < Math.Truncate(num4 * 100.0) && Math.Truncate(num3 * 100.0) < Math.Truncate(num5 * 100.0));
			bool flag4 = (base.Symbol.Digits == 4 && Math.Truncate(num2) < Math.Truncate(num4) && Math.Truncate(num3) > Math.Truncate(num5)) || (base.Symbol.Digits == 5 && Math.Truncate(num3 * 100.0) > Math.Truncate(num5 * 100.0));
			bool flag5 = (base.Symbol.Digits == 4 && Math.Truncate(num2) > Math.Truncate(num5) && Math.Truncate(num3) < Math.Truncate(num4)) || (base.Symbol.Digits == 5 && Math.Truncate(num3 * 100.0) < Math.Truncate(num5 * 100.0));
			if (num < 1 && flag)
			{
				if ((flag2 && this.Tbounce > 0) || (flag4 && this.Tbreak > 0))
				{
					MarketOrderRequest request = new MarketOrderRequest(TradeType.Buy, (int)((double)this.InitialVolume * num7))
					{
						Label = this.code.ToString(),
						SlippagePips = new int?(1),
						StopLossPips = new int?(this.StopLoss),
						TakeProfitPips = new int?(this.TakeProfit)
					};
					base.Trade.Send(request);
					return;
				}
				if ((flag3 && this.Tbounce > 0) || (flag5 && this.Tbreak > 0))
				{
					MarketOrderRequest request2 = new MarketOrderRequest(TradeType.Sell, (int)((double)this.InitialVolume * num7))
					{
						Label = this.code.ToString(),
						SlippagePips = new int?(1),
						StopLossPips = new int?(this.StopLoss),
						TakeProfitPips = new int?(this.TakeProfit)
					};
					base.Trade.Send(request2);
				}
			}
		}
		protected override void OnTick()
		{
			int num = base.Account.Positions.Count((Position position) => position.Label == this.code.ToString() && position.SymbolCode == base.Symbol.Code);
			if (num < 1)
			{
				return;
			}
			foreach (Position current in base.Account.Positions)
			{
				if (current.Label == this.code.ToString() && current.SymbolCode == base.Symbol.Code)
				{
					if (current.TradeType == TradeType.Sell)
					{
						if (current.Pips >= (double)this.Trigger && this.Breakeven > 0)
						{
							double num2 = current.EntryPrice - (double)this.Breakeven * base.Symbol.PipSize;
							double num3 = num2;
							double? stopLoss = current.StopLoss;
							if (num3 < stopLoss.GetValueOrDefault() && stopLoss.HasValue)
							{
								base.Trade.ModifyPosition(current, new double?(num2), current.TakeProfit);
							}
						}
						if (current.Pips >= (double)this.Trigger && this.Breakeven < 1)
						{
							double num4 = base.Symbol.Ask + (double)this.TrailingStop * base.Symbol.PipSize;
							double num5 = num4;
							double? stopLoss2 = current.StopLoss;
							if (num5 < stopLoss2.GetValueOrDefault() && stopLoss2.HasValue)
							{
								base.Trade.ModifyPosition(current, new double?(num4), current.TakeProfit);
							}
						}
					}
					else
					{
						if (current.Pips >= (double)this.Trigger && this.Breakeven > 0)
						{
							double entryPrice = current.EntryPrice;
							double? stopLoss3 = current.StopLoss;
							double num6 = entryPrice;
							if (stopLoss3.GetValueOrDefault() < num6 && stopLoss3.HasValue)
							{
								base.Trade.ModifyPosition(current, new double?(entryPrice), current.TakeProfit);
							}
						}
						if (current.Pips >= (double)this.Trigger && this.Breakeven < 1)
						{
							double num7 = base.Symbol.Bid - (double)this.TrailingStop * base.Symbol.PipSize;
							double? stopLoss4 = current.StopLoss;
							double num8 = num7;
							if (stopLoss4.GetValueOrDefault() < num8 && stopLoss4.HasValue)
							{
								base.Trade.ModifyPosition(current, new double?(num7), current.TakeProfit);
							}
						}
					}
				}
			}
		}
		protected override void OnPositionOpened(Position openedPosition)
		{
			this.position = openedPosition;
			//openedPosition.SymbolCode == base.Symbol.Code;
			if (this.position.TradeType == TradeType.Sell)
			{
				if (this.position.Pips < 0.0)
				{
					if (this.position.StopLoss.HasValue)
					{
						double? stopLoss = this.position.StopLoss;
						double entryPrice = this.position.EntryPrice;
						double? num = stopLoss.HasValue ? new double?(stopLoss.GetValueOrDefault() - entryPrice) : null;
						double num2 = base.Symbol.PipSize * (double)this.StopLoss;
						if (num.GetValueOrDefault() <= num2 || !num.HasValue)
						{
							return;
						}
					}
					base.Trade.ModifyPosition(this.position, new double?(this.position.EntryPrice + base.Symbol.PipSize * (double)this.StopLoss), this.position.TakeProfit);
					return;
				}
			}
			else
			{
				if (this.position.Pips < 0.0)
				{
					if (this.position.StopLoss.HasValue)
					{
						double entryPrice2 = this.position.EntryPrice;
						double? stopLoss2 = this.position.StopLoss;
						double? num3 = stopLoss2.HasValue ? new double?(entryPrice2 - stopLoss2.GetValueOrDefault()) : null;
						double num4 = base.Symbol.PipSize * (double)this.StopLoss;
						if (num3.GetValueOrDefault() <= num4 || !num3.HasValue)
						{
							return;
						}
					}
					base.Trade.ModifyPosition(this.position, new double?(this.position.EntryPrice - base.Symbol.PipSize * (double)this.StopLoss), this.position.TakeProfit);
				}
			}
		}
		protected override void OnError(Error error)
		{
			base.Print("{0}", new object[]
			{
				error.Code
			});
		}
	}
}

 


@hichem

hichem
27 May 2013, 16:30

Hello,

One of the great problems when developing a serious robot is handling failed requests and server connectivity issues. cAlgo doesn't provide great tools when it comes to that.

 

Please consider providing more facilities to handling asynchrounous failed requests. For example adding an eventArg that contains the failed request in the OnError method.

 

Thanks


@hichem

hichem
20 May 2013, 13:15

RE: RE: RE:
kyro747 said:
hichem said:
kyro747 said:

Hi guys,

 

Is it possible to creat a cRobot that is protected so it can run but the code not be seen by the broker/others?

 

Thanks

For now the .algo file is just a zip file containing an assembly file.

Contact me in private for a solution to totally protect your Robot code.

Thanks hicheck, I cannot find a private message option?

Send to support@scyware.com


@hichem

hichem
20 May 2013, 10:49

RE:
kyro747 said:

Hi guys,

 

Is it possible to creat a cRobot that is protected so it can run but the code not be seen by the broker/others?

 

Thanks

For now the .algo file is just a zip file containing an assembly file.

Contact me in private for a solution to totally protect your Robot code.


@hichem

hichem
07 May 2013, 16:38

RE:
cAlgo_Fanatic said:

If the label of the position is the same as the label of the pending order it means the pending order was filled.

Ok thanks.


@hichem

hichem
07 May 2013, 16:24

RE:
cAlgo_Fanatic said:

You can use Labels for this. Use the OnTick event to check for the positions with the label set when the order was created. Please see the examples here.

That solve how to retrieve the previously created pendingOrders (by label). If those PendingOrders get opened, when their PriceLevel hit, the OnPositionOpened dosn't get called. How to know if a pending order has been opened ?


@hichem

hichem
07 May 2013, 12:07

RE:
cAlgo_Fanatic said:

Take profit has to be above the entry price for a buy order and below the entry price for a sell order.

In this case I should be getting the Technical errors due to another reason than the validity of the condition you mentioned.

Because right after I recieve a technical error when trying to set a TP on a position (with a valid TP values according to your last post), I retry again with the same values and it passes with no technical errors.

 

Do you have an idea why is that ?


@hichem

hichem
07 May 2013, 10:40

RE:
cAlgo_Fanatic said:

Technical errors are due to invalid values. Therefore, most probably the Take Profit you are setting cannot be applied to all open orders. You would have to modify the code to calculate the value for take profit instead of assigning the same value to all. 

What are the possible invalid values of the Take profit ? apart from the entry price


@hichem

hichem
02 May 2013, 16:02

RE:

Hello, 

You can go through the tutorials and the sample robots delivered with cAlgo.

There many examples from which you can learn.


@hichem

hichem
27 Apr 2013, 17:28

RE:
pparpas said:

I am in the process of finding the best possible automated platform that covers my needs. By using cAlgo, is there any way to debug robots by using Visual Studio? I have made many trials using Visual Studio and trying to attach the debugger to calgo process with no luck.

 

Debugging a robot in Visual Studio is possible. But you should compile the robot to a .dll file with Visual Studio. Then you should reference the generated .dll in cAlgo and after executing the robot in cAlgo you should attach VS debugger.


@hichem

hichem
26 Apr 2013, 15:24

RE:
adrian said:

log errors do not fit in one line on the log tab, where is the actual log file located?

Here is how to copy the Print() output to a text log file

 

First include System.IO

using System.IO;

Then decalre :

StreamWriter FileWriter ;

Then override the Print Method like this

protected  new void  Print(object value)
		{
			
			if(FileWriter == null)
			{
				var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);//getting location of user's Desktop folder  
				var filePath = Path.Combine(desktopFolder, "log.txt"); 
	            FileWriter = File.AppendText(filePath);
	            FileWriter.AutoFlush = true;
			}
			FileWriter.WriteLine(value);
			base.Print(value);
		}



then clean in OnStop

 protected override void OnStop()
        {
           FileWriter.Close();
        }



 

 


@hichem

hichem
25 Apr 2013, 16:58

RE:
cAlgoFx said:

Hello,

Please use the current version on EURUSD and USDJPY only.We registered best results on both pairs so far.

 

Kind regards

Hello how one can download your Robot ?


@hichem

hichem
25 Apr 2013, 12:54

RE:
umermaster said:

Hello Guys,

 

I have developed a system on cAlgo that i would now like to sell to other people. But what i do not want is for them to get their hands on the code. Is there a way to encapsulate/hide or secure the actual .cs file? I mnow there can be workarounds for this but does cTrader provide direct security feature which can be used?

 

Hoping to get some positive feedback.

 

Thanks.

Master

Hello,

Actually the .algo file is not protected against reverse engineering or decompiling. the most efficient way to protect your system would be to isolate the source code in a .dll, obfuscate it, and then make a robot .cs file that calls the code inside the .dll file

 


@hichem

hichem
13 Apr 2013, 14:36

RE:
damon153058 said:

I need a programmer

Hello, 

Please send your request to support@scyware.com.

We will be glade to help.

Best regards.


@hichem

hichem
05 Apr 2013, 07:26

RE:
moneymax said:

Hi

Would be great to be able to connect to myfxbook for stats or something similar.  Anything on the cards?

Thanks

You can create a c# class to parse XML or JSON  data coming from myfxbook : http://www.myfxbook.com/api

Then call that class from withing a robot.


@hichem

hichem
04 Apr 2013, 14:51

RE:
cAlgo_Fanatic said:

To find the 5% of the Account balance it is Account.Balance * 0.05.

One lot is 100000, so to trade one lot you will set the volume to 100000.

 

 

 

Makes sense but : Account.Balance * 0.05 is 5% of the balance. What is the volume of a trade that should respect a StopLoss risking 5% of the balance. ?


@hichem

hichem
04 Apr 2013, 11:40

RE:
cAlgo_Fanatic said:

Hello,

This gives you the maximum allowed trading volume given the account equity.

It rounds to 10000. So, if the calculation result is 4936423 it would round it to 4930000.

Please clarify what you mean by the "equivalent volume for a lot size = 5"

 

If I want to risk only 5% of my balance, then the volume of my position would be calculated as 4930000 * 0.05 ?

For my second question I wanted to find an equivalent to lot sizes as in Metatrader.  In cAlgo What is the difference between lot sizes and volumes?

 

Thnks for the great support.


@hichem