
Topics
Replies
PanagiotisCharalampous
12 Mar 2020, 11:46
Hi light96,
I tried reproducing this the last couple of days but could not. All my backtesting runs match the optimization runs. The fact that you are using GA method does not allow me to get the exact same results as you and reproduce. Any change you can narrow down the optimization range, run an exhaustive grid search and provide another example that will allow us to reproduce this?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Mar 2020, 09:45
Hi VertoTrading,
The fix has been released on Spotware cTrader Beta. It should be rolled out to brokers soon.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Mar 2020, 09:21
Hi calgodemo,
Here is a starting point
private void IndicatorArea_Click(ChartMouseEventArgs obj)
{
var text1 = new TextBlock
{
BackgroundColor = Color.Red,
Text = "Test",
Width = 30,
Height = 10,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top
};
text1.Margin = new Thickness(obj.MouseX, obj.MouseY, 0, 0);
IndicatorArea.AddControl(text1);
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Mar 2020, 08:08
Hi NE539,
Execution issues should be investigated by your broker.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 16:12
Hi screwmatrix863,
You can find a lot of them here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 14:59
Hi driftingprogrammer,
1.0.112
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 14:39
Hi travkinsm1,
Thanks, can you post the indicator as well?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 10:42
Hi noeyamn,
The problem seems to be that SQLite .Net dll is referencing other dll files which cannot be found when it is looking in the folder of cTrader application. The workaround is to add a folder in Documents e.g. "sqllite" and add SQLite.Interop.dll file there. The cBot can add this folder to Path environment variable so that this folder would be searched too. See below an example
using System;
using System.Data.SQLite;
using System.IO;
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.FullAccess)]
public class NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
AddSqlightFolderToPath();
var dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "mydatabase.db");
var con = new SQLiteConnection("Data Source=" + dbPath);
con.Open();
Print("DB connection: ", con.State);
}
private void AddSqlightFolderToPath()
{
var libPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "sqllite");
var path = Environment.GetEnvironmentVariable("PATH");
var pathItems = path.Split(';');
Print(libPath);
if (!pathItems.Contains(libPath))
Environment.SetEnvironmentVariable("PATH", path + ";" + libPath);
}
protected override void OnTick()
{
// Put your core logic here
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 08:44
Hi rsexton,
This is not an issue but a feature. Not many trading platforms offer this feature. At the moment our server does not support advanced protection, since it will increase the load on our servers significantly, and we do not plan to add it soon.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 08:40
Hi jcb79,
Please use the Suggestion section for suggestions.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
11 Mar 2020, 08:39
Hi Monkey007,
To check if there are any positions open, you can check the Positions collection. Regarding simultaneous opening, there is no straight forward general solution to this, it depends on your cBot's architecture. For example you can use a static variable as a flag.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 16:42
Hi scotpip,
Thanks, I managed to reproduce it. We will check.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 16:18
Hi there,
See below
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class MacdBot : Robot
{
private MacdHistogram _macd;
private Position _position;
[Parameter(DefaultValue = 10000, MinValue = 0)]
public int Volume { get; set; }
[Parameter("Period", DefaultValue = 9)]
public int Period { get; set; }
[Parameter("Long Cycle", DefaultValue = 26)]
public int LongCycle { get; set; }
[Parameter("Short Cycle", DefaultValue = 12)]
public int ShortCycle { get; set; }
[Parameter("Stop Loss", DefaultValue = 10)]
public double StopLoss { get; set; }
[Parameter("Stop Loss", DefaultValue = 10)]
public double TakeProfit { get; set; }
protected override void OnStart()
{
_macd = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
Positions.Opened += OnPositionsOpened;
}
void OnPositionsOpened(PositionOpenedEventArgs obj)
{
_position = obj.Position;
}
protected override void OnBar()
{
bool isLongPositionOpen = _position != null && _position.TradeType == TradeType.Buy;
bool isShortPositionOpen = _position != null && _position.TradeType == TradeType.Sell;
if (_macd.Histogram.LastValue > 0.0 && _macd.Signal.IsRising() && !isLongPositionOpen)
{
ClosePosition();
Buy();
}
if (_macd.Histogram.LastValue < 0.0 && _macd.Signal.IsFalling() && !isShortPositionOpen)
{
ClosePosition();
Sell();
}
}
private void ClosePosition()
{
if (_position != null)
{
_position.Close();
_position = null;
}
}
private void Buy()
{
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, Volume, "", StopLoss, TakeProfit);
}
private void Sell()
{
ExecuteMarketOrder(TradeType.Sell, Symbol.Name, Volume, "", StopLoss, TakeProfit);
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 15:19
Hi driftingprogrammer,
This happens because
Bars tempBars = MarketData.GetBars(TimeFrame.Minute15);
does not return any values in OnStart(). Unfortunately getting past bars from other timeframes is not supported at the moment in Optimization. You can only get bars from other timeframes that are constructed during the time the cBot is running. If your cBot logic allows it, here is a workaround to consider.
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 NewcBot : Robot
{
[Parameter(DefaultValue = 0.0)]
public double Parameter { get; set; }
protected override void OnStart()
{
}
protected override void OnBar()
{
Bars tempBars = MarketData.GetBars(TimeFrame.Minute15);
if (tempBars.Count > 0)
{
Print("Printing tick volume " + tempBars.Count);
}
}
protected override void OnStop()
{
// Put your deinitialization logic here
}
}
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 15:04
Hi pcarmesten,
This is certainly a coding mistake. You can read more about overflows here. If you can share some code and steps to reproduce, we might be able to pinpoint the problem.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 14:02
Hi travkinsm1,
Can we have the indicator and cBot code so that we can reproduce this?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 10:26
Hi donbona,
Thanks for the info. Please provide us with the strategy name, your broker and your trading account number so that we can have a look.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 09:33
Hi donbona,
Thanks, please note that the commissions are calculated based on the profit at the moment the commission is taken. So if your equity was higher at that moment, then the commission would have been higher as well. Can you check what the equity was at that moment?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Mar 2020, 08:47
Hi donbona,
Can you please explain to us where did you get these numbers from? It could be that you have a wrong profit number.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Mar 2020, 12:38
Hi ta.vanya.91,
Please contact your broker regarding this issue. Else provide some screenshots that demonstrate this behavior. There is no known issue with the History tab and we do not have access to your account to check this.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous