
Topics
Replies
PanagiotisCharalampous
26 Aug 2022, 08:50
Hi Vadivelan,
Unfortunaltely the code you sent references some external libraries therefore we won't be able to build it. If you have paid for this cBot, then the first thing you should do is to contact the developer.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 14:46
Hi there,
Please provide the complete cBot code and backtesting parameters so that we can reproduce the issue.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 14:41
Hi there,
This issue will be resolved in an upcoming update.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 12:29
Hi there,
We are aware of the issue and it will be fixed soon.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 09:55
Hi noolohp,
it will then direct that Bars.Opentime[i] must be 1 bar ahead of Bars.Last(1).OpenTime and not as the result shows.
No that is not how it works. Bars.Last(1).OpenTime is not equal to Bars.OpenTime[i]. Last() methods counts backwards therefore Bars.Last(1).OpenTime = Bars.OpenTime[Bars.Count - 2]
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 09:09
Hi there,
Try making your objects interactive. See below
var text = Chart.DrawText($"{lastOsci1}" + $".{barHighValue}", $"{lastOsci1}", Bars.Last(1).OpenTime, barHighValue, Color.Red);
text.IsInteractive = true;
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 09:06
Hi TaoCTID,
Can you share your cBot code so that we can explain what happens?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 09:03
Hi peshay,
Please have a look at the thread below. It might be helpful
https://ctrader.com/forum/ctrader-support/36294#post-9
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 08:59
Hi noob7,
Did you try checking executionEvent.Position.HasStopLoss and executionEvent.Position.HasTakeProfit?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 08:51
Hi noolohp,
he results always show that Bars.Last(1).OpenTime is 1 bar ahead of Bars.OpenTime[i]
Correct. The proble here is that sometimes i is > 1, therefore it points to an older date. There is clearly a logical error in your code. You need to debug it and understand what is wrong.
Moreover, with regards to the mentioned code is there any possible alteration, in your opinion, to align the two value ?
No, because I have no idea what you are trying to do. I can only explain what you are doing which is probably not aligned with your intentions.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
25 Aug 2022, 08:41
Hi there,
You can check the sample cBots in cTrader. like the Sample cBot Reference SMA
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// -------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SamplecBotReferenceSMA : Robot
{
[Parameter("Source")]
public DataSeries Source { get; set; }
[Parameter("SMA Period", DefaultValue = 14)]
public int SmaPeriod { get; set; }
private SampleSMA sma;
protected override void OnStart()
{
sma = Indicators.GetIndicator<SampleSMA>(Source, SmaPeriod);
}
protected override void OnTick()
{
Print("{0}", sma.Result.LastValue);
}
}
}
and the Sample RSI cBot
// -------------------------------------------------------------------------------------------------
//
// This code is a cTrader Automate API example.
//
// This cBot is intended to be used as a sample and does not guarantee any particular outcome or
// profit of any kind. Use it at your own risk.
//
// All changes to this file might be lost on the next application update.
// If you are going to modify this file please make a copy using the "Duplicate" command.
//
// The "Sample RSI cBot" will create a buy order when the Relative Strength Index indicator crosses the level 30,
// and a Sell order when the RSI indicator crosses the level 70. The order is closed be either a Stop Loss, defined in
// the "Stop Loss" parameter, or by the opposite RSI crossing signal (buy orders close when RSI crosses the 70 level
// and sell orders are closed when RSI crosses the 30 level).
//
// The cBot can generate only one Buy or Sell order at any given time.
//
// -------------------------------------------------------------------------------------------------
using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo
{
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SampleRSIcBot : Robot
{
[Parameter("Quantity (Lots)", Group = "Volume", DefaultValue = 1, MinValue = 0.01, Step = 0.01)]
public double Quantity { get; set; }
[Parameter("Source", Group = "RSI")]
public DataSeries Source { get; set; }
[Parameter("Periods", Group = "RSI", DefaultValue = 14)]
public int Periods { get; set; }
private RelativeStrengthIndex rsi;
protected override void OnStart()
{
rsi = Indicators.RelativeStrengthIndex(Source, Periods);
}
protected override void OnTick()
{
if (rsi.Result.LastValue < 30)
{
Close(TradeType.Sell);
Open(TradeType.Buy);
}
else if (rsi.Result.LastValue > 70)
{
Close(TradeType.Buy);
Open(TradeType.Sell);
}
}
private void Close(TradeType tradeType)
{
foreach (var position in Positions.FindAll("SampleRSI", SymbolName, tradeType))
ClosePosition(position);
}
private void Open(TradeType tradeType)
{
var position = Positions.Find("SampleRSI", SymbolName, tradeType);
var volumeInUnits = Symbol.QuantityToVolumeInUnits(Quantity);
if (position == null)
ExecuteMarketOrder(tradeType, SymbolName, volumeInUnits, "SampleRSI");
}
}
}
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
24 Aug 2022, 11:14
Hi Stanley,
Please send us some troubleshooting information and paste the link to this discussion in the text box.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
24 Aug 2022, 10:24
Hi there,
Thanks, you don't need to reproduce the entire logic inside the cBot. You just need to reference the indicator and check the values.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
24 Aug 2022, 08:34
Hi noolohp,
as per my understanding Bars.OpenTime[] starts from [0] and surplus each time new bar is opened so with i++ the value of Bars.OpenTimes[i] should be the same as Bars.Last(1).OpenTime
But you run the loop from the beginning for each bar, therefore the condition (see below) that prints the curreBarOpenTime might become true before the last bar is reached.
if (isCurrentBarRed && isPreviousBarRed && !isRedDriven)
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
24 Aug 2022, 08:29
Hi there,
It is not clear what are you trying to achieve here. What do you want the cBot to do? In general, Calculate is called on once for each bar for historical data and on each tick for the current bar.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
23 Aug 2022, 14:20
Hi noolohp,
I am not sure why you expect the two values to match. Here you always pring the last value
Print("method " + Bars.Last(1).OpenTime);
and here you print a value based on the i counter
Print(curreBarOpenTime);
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
23 Aug 2022, 14:15
Hi nsvtrade,
You need to double click on the pop up window, not on the taskbar icon.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
23 Aug 2022, 08:03
Hi peshay,
What graphics card do you have?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
22 Aug 2022, 10:47
Hi peshay,
Thanks for reporting this problem. Can you record a video demonstrating this behavior?
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous
PanagiotisCharalampous
26 Aug 2022, 09:32
Hi Vadivelan,
Sure, if it is an easy fix, I will help.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous