Topics
Replies
Spotware
27 Aug 2017, 12:41
Dear slodder04,
Check here how access an indicator from a cBot.
Regarding the index of the candle, the last candle has index 0. See following code sample on how to get the last High value from MarketSeries
var lastHighValue = MarketSeries.High.Last(0);
Best Regards,
cTrader Team
@Spotware
Spotware
25 Aug 2017, 10:31
Dear yosifov,
You can use labels to distinguish between different position types. For example, when opening a position from a cBot, you can apply a label as follows
ExecuteMarketOrder(TradeType.Buy,Symbol,1000,"MyLabel");
and then when you are modifying these positions you can filter your positions using the label. See below
foreach(var position in Positions.Find("MyLabel")) { // Modify/Close positions }
Let us know if this helps.
Best Regards,
cTrader Team
@Spotware
Spotware
24 Aug 2017, 11:46
Dear hungtonydang,
It would be easier for somebody to help you if you provide some additional information. If possible please provide us with the following
1) The complete code for the cBot.
2) What values do you receive.
3) What would you expect to receive.
From what we can deduce from your code sample, you are using the value of the main line of a Bollinger Band. If this is the case, then it is not uncommon this value to be near the market price.
Best Regards,
cTrader Team
@Spotware
Spotware
22 Aug 2017, 14:47
Dear swingfish,
An easy way to achieve this is to construct an ideal trendline in your cBot and check the price on each tick. See below an example of creating such a trendline and getting the price in the OnTick() function. You need to put your trendline's chart coordinates (start price, start time, end price, end time) and the current price is printed in the cBot's log on each tick
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 TrendlinecBot : Robot { private double _startPrice; private double _endPrice; private double _slope; private DateTime _startDate; private DateTime _endDate; protected override void OnStart() { _startPrice = 1.15; _endPrice = 1.2; _startDate = DateTime.Now; _endDate = DateTime.Now.AddHours(1); TimeSpan diff = (_endDate - _startDate); _slope = (_endPrice - _startPrice) / diff.TotalSeconds; } protected override void OnTick() { TimeSpan diff = (DateTime.Now - _startDate); var trendlinePrice = _slope * diff.TotalSeconds + _startPrice; Print(trendlinePrice); } protected override void OnStop() { } } }
Let us know if this solution helps you,
Best Regards,
cTrader Team
@Spotware
Spotware
22 Aug 2017, 11:51
Dear Trader,
Thanks for posting your suggestion to the forum. We advise you to post your suggestions in the relevant Suggestions section, so that they are all gathered in one place for future reference. We will forward your suggestion to the relevant product team.
Best Regards,
cTrader Team
@Spotware
Spotware
21 Aug 2017, 16:35
Dear swingfish,
From what we understand, you need to get the current value of an indicator. Please see the following example that prints the value of the Simple Moving Average indicator on each tick
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); } } }
Let us know if the above helps or if you meant something different.
Best Regards,
cTrader Team
@Spotware
Spotware
21 Aug 2017, 16:30
Dear tradermatrix,
Could you please explain what do you mean by saying "manually pass an order"? Currently you can create an order from the interface or using cAlgo. Do you have any other way in mind? Regarding manually applying a label to an order, we don't have such plans currently.
This would make it possible to differentiate the various strategies or to correct a bug on a robot by adding commands with the same label
Why not to fix the bug in the first place? If you can explain a bit more the necessity of this feature, then we can consider it for future releases.
Best Regards,
cTrader Team
@Spotware
Spotware
28 Aug 2017, 09:36
Dear irmscher9,
MarketSeries.Low is a property with a type of DataSeries which contains a list of values. The index gets the value in the dataseries at the specified position. See an example here.
Best Regards,
cTrader Team
@Spotware