Topics
Forum Topics not found
Replies
Invalid
27 Mar 2015, 09:29
RE:
Check if it is null instead of true.
MarketData.GetSymbol("holaamigos")!=null;
Or you can create an extension:
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { protected override void OnStart() { Print("Symbol exists: {0}", MarketData.SymbolExists("E33URGBP")); } } public static class Ext { public static bool SymbolExists(this MarketData marketData, string symbol) { return marketData.GetSymbol(symbol) != null; } }
@Invalid
Invalid
17 Feb 2015, 11:41
RE:
Hi Saxx. I didn't get you.
- Take your code. Convert at http://2calgo.com/.
- Copy converted code.
- Create new Indicator in cAlgo
- Paste the code from step 2
- Build
- Create instance
Which step failed on your side?
saxx said:
Hi Invalid ... I could publish the installation file ".calgo".
I can not run c2algo... unsupported format
Thank' s.
@Invalid
Invalid
07 Jan 2015, 15:26
Use MarketData.GetSymbol(string symbolCode)
ExecuteMarketOrder(TradeType.Sell,MarketData.GetSymbol("GBPJPY"), 1 000 000);
/api/reference/internals/marketdata/getsymbol-6503
@Invalid
Invalid
04 Nov 2014, 10:07
RE:
Hi jimmyh89. May be you have parameter of type long?
jimmyh89 said:
Hello,
So I've been trying to write my first bot,
I got rid of all the compilation errors one by one, but now, I have this message in red sayingunable to load assembly: unsupported parameter type 'int64'
It doesn't show me on which line the error is and I don't use any 'int64' in my code, only 'int' itself.
any ideas?
@Invalid
Invalid
03 Nov 2014, 15:39
RE:
Timer accepts two type of parameters:
1. seconds
2. TimeSpan. This one has methods like FromHours, FromMilliseconds
interval = TimeSpan.FromMilliseconds(111); interval=new TimeSpan(hours,minutes,seconds); interval=new TimeSpan(days,hours,minutes,seconds); interval=new TimeSpan(days,hours,minutes,seconds,milliseconds);
xlcharly said:
Hi to all.
Someone knows which is the min time interval that is possible to use in a bot?
I mean, I need to put an order as near as possible at a date time, say 10.00 am.
Which is the nearest time that I can give to the bot as entry time? Only in second (or 9.59.59) or I can use msec too?
Thanks.
@Invalid
Invalid
03 Nov 2014, 09:17
RE:
DateTime initialization is wrong.
Currently you use this one (Year, Month, Hour). You need to create a date time using (year, month, day, hour, minutes, seconds).
apresau said:
Hi,
I'm trying to code a simple indicator to insert vertical lines on the chart at specific hours.
However I don't understand time functions and am struggling to find tutorials / examples to illustrate
the various functions.
Any help with my broken code would me much appreciated.
Thanks
apresau
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class TimeMarkers : Indicator { [Parameter(DefaultValue = 12)] public int Hour_1 { get; set; } [Parameter(DefaultValue = 16)] public int Hour_2 { get; set; } private DateTime _Hour_1, _Hour_2; protected override void Initialize() { } public override void Calculate(int index) { _Hour_1 = new DateTime(Hour_1, 0, 0); _Hour_2 = new DateTime(Hour_2, 0, 0); if (Server.Time.Date.AddHours(0) == _Hour_1) ChartObjects.DrawVerticalLine("vLine_1", index, Colors.Red, 1, LineStyle.Lines); if (Server.Time.Date.AddHours(0) == _Hour_2) ChartObjects.DrawVerticalLine("vLine_2", index, Colors.Gold, 1, LineStyle.Lines); } } }
@Invalid
Invalid
28 Oct 2014, 12:20
RE:
Probably you have to ask for this feature
http://vote.spotware.com/forums/229166-ideas-and-suggestions-for-ctrader-and-calgo
tynamite said:
First of all, cAlgo is very fine...
But I would like to have the opportunity to combine the backtesting with a forward-test.
@Invalid
Invalid
24 Oct 2014, 12:38
RE: RE: RE: RE:
//OpenConnection(); - this should be done in OnStart string stm = "SELECT pid,hedge_level,current_upper_point,current_lower_point FROM " + logtable + " WHERE pid='" + position1.Label + "'"; using(MySqlCommand cmd1 = new MySqlCommand(stm, connection)) { using(var rdr = cmd1.ExecuteReader()) { if (rdr.HasRows) { while (rdr.Read()) { //currentHedgeLevel = rdr.GetInt32(1); currentupperpoint = Math.Round(rdr.GetDouble(2), 5); currentlowerpoint = Math.Round(rdr.GetDouble(3), 5); } } } } // CloseConnection(); - execute it in OnStop
alifarooq said:
OpenConnection(); string stm = "SELECT pid,hedge_level,current_upper_point,current_lower_point FROM " + logtable + " WHERE pid='" + position1.Label + "'"; MySqlCommand cmd1 = new MySqlCommand(stm, connection); rdr = cmd1.ExecuteReader(); if (rdr.HasRows) { while (rdr.Read()) { //currentHedgeLevel = rdr.GetInt32(1); currentupperpoint = Math.Round(rdr.GetDouble(2), 5); currentlowerpoint = Math.Round(rdr.GetDouble(3), 5); } } CloseConnection();can you tell how can i dispose this reader?
Invalid said:
Dispose DataReader when you exit from OnTick. Example:
using(MySqlDataReader Reader = cmd.ExecuteReader()) { // your cool stuff here }
alifarooq said:
When i execute the code this happens.
27/01/2014 00:20:02.471 | Crashed in OnTick with MySqlException: There is already an open DataReader associated with this Connection which must be closed first.
Spotware said:
Probably database is the bottleneck. You can try the following things:
- Do not establish database connection on every query. Instead of that you can establish database connection in OnStart method and drop it in OnStop method
- Install database on your machine, instead of connecting to remote one
- Try other database engines. There is a chance that this problem is specific for mysql.
@Invalid
Invalid
24 Oct 2014, 12:22
RE: RE:
Dispose DataReader when you exit from OnTick. Example:
using(MySqlDataReader Reader = cmd.ExecuteReader()) { // your cool stuff here }
alifarooq said:
When i execute the code this happens.
27/01/2014 00:20:02.471 | Crashed in OnTick with MySqlException: There is already an open DataReader associated with this Connection which must be closed first.
Spotware said:
Probably database is the bottleneck. You can try the following things:
- Do not establish database connection on every query. Instead of that you can establish database connection in OnStart method and drop it in OnStop method
- Install database on your machine, instead of connecting to remote one
- Try other database engines. There is a chance that this problem is specific for mysql.
@Invalid
Invalid
20 Oct 2014, 09:58
RE:
Most probably longPosition or shortPosition is null. Make sure both of them were opened successfully.
Ian_Drummond said:
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo.Robots { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class HedgeBot : Robot { [Parameter("Initial Volume", DefaultValue = 10000, MinValue = 0)] public int InitialVolume { get; set; } [Parameter("Take Profit", DefaultValue = 30)] public int TakeProfit { get; set; } [Parameter("Stop Loss", DefaultValue = 20)] public int StopLoss { get; set; } private const string label = "HedgeBot"; protected override void OnStart() { ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, label, StopLoss, TakeProfit); ExecuteMarketOrder(TradeType.Sell, Symbol, InitialVolume, label, StopLoss, TakeProfit); } protected override void OnTick() { var longPosition = Positions.Find(label, Symbol, TradeType.Buy); var shortPosition = Positions.Find(label, Symbol, TradeType.Sell); { if (longPosition.GrossProfit > 10) { ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume * 2, label, StopLoss, TakeProfit); } else if (shortPosition.GrossProfit > 10) { ExecuteMarketOrder(TradeType.Sell, Symbol, InitialVolume * 2, label, StopLoss, TakeProfit); } { return; } } } } }Can anyone please point out the error here?
The full error message is: Crashed in OnTick with NullReferenceException: Object reference not set to an instance of an object.
@Invalid
Invalid
13 Oct 2014, 09:26
( Updated at: 21 Dec 2023, 09:20 )
RE:
Try to install it from Extension and Updates (Tools->Extensions and Updates->Online)
badmonkeyface said:
Hi,
I've removed VS2012 and replaced with VS2013. When I click 'edit in visual studio' nothing happens. How do I re-run the integration?
Thanks.
@Invalid
Invalid
10 Oct 2014, 09:15
Hard to read in upper case
dear developers, thanks so much for giving us the best platform we have until today with ctrader, but the most important feature is need it , i suggest to put inside the chart in all the time frames percentage of the quotes move in each pairs , display inside the chart by pips and percentage moves similar to myforexbook quotes exemple here http://www.myfxbook.com/forex-market/currencies/240 ,when i trade i use myforexbook quotes in diferent time frames in combination with the chart , it will be nice for ctrader to display this feature in all the pairs in all the time frames in that way i will have to use my favorite platform only and not depend of any other system., exemple gbp-nzd inside the chat in the corresponding time frame i could see how much pips and percentage move the pair is doing with each moving of the chart , i hope i explain this feature correctly and make myself clear, thank .
@Invalid
Invalid
08 Apr 2015, 09:51
Change AccessRights in your attribute to Full Access.
Check here
@Invalid