Topics
Replies
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
10 Mar 2020, 08:27
Hi scotpip,
Can you please try cleaning your Backtesting Cache (C:\Users\UserAppData\Roaming\broker cTrader\BacktestingCache) and and let us know if it resolves the issue?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 16:31
Hi Tj11,
Green and Red arrows indicate deposits and withdrawals respectively. See the legend.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 16:21
Hi BenjaminR,
See below
MarketData.GetBars(AnotherTimeFrame, Symbol.Name);
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 14:46
Hi Tj11,
You can write a function with a switch statement that does the conversion. See an example below
private TimeFrame GetTimeFrameFromString(string timeframeString)
{
switch (timeframeString)
{
case "Hour":
return TimeFrame.Hour;
// .
// .
// .
// .
// .
// .
// .
// .
}
return TimeFrame.Hour;
}
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 12:11
Hi noeyamn,
You did not answer my question. Why do you add references manually? I installed SQLite using Package Manager and I have no problems. See below
Everything seems fine and the cBot builds without a problem.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 11:56
Hi light96,
Can you please post the cBot code and steps to reproduce the problem?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 09:50
Hi Peter,
Please note the following.
1) If your account size is smaller than the strategy provider's account then the equity to equity ratio might not be able to be kept due to restrictions like minimum volume allowed to be traded. From what I can see from the screenshots, your account is substantially smaller from your strategy provider's account while the strategy provider is opening positions using the minimum volume. This can result to greater exposure for your account.
2) Greater exposure can also be caused by different leverage settings. Please make sure you are using the same leverage as your strategy provider.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Mar 2020, 09:25
Hi Peter,
For execution issues, you should contact your broker.
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
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous