Topics
Replies
PanagiotisCharalampous
15 Feb 2018, 10:44
Hi DelTrader,
Most probably your condition is not fulfilled
if (myPositionsSymbol1.Length <= (MaxOpenTradesSymbol1 - 1) && Symbol1Spread <= MaxSpreadSymbol1) {
However we cannot advise further if we don't know what this condition is supposed to do and what do the parameters mean. For example, we don't know what MaxOpenTradesSymbol1 or LabelSymbol1
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
15 Feb 2018, 10:25
Hi JoaoRMartins,
This is a known issue and it is going to be resolved in the next release of the API.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
15 Feb 2018, 10:13
Hi dordkash@gmail.com,
You have the following condition in OnBar()?
if (Symbol.Bid - MarketSeries.High.Last(1) > Symbol.PipSize) ExecuteMarketOrder(TradeType.Buy, Symbol, VOL, label, buypips, tp);
This code is executed as soon as a bar closes and a new one is created. This means that the first tick of the new bar should be 1 pip higher that the highest price of the last bar. Ever if the last tick of the previous bar was the highest price recorded for that bar, it is very unlikely that the first tick of the new bar will be 1 pip higher.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
14 Feb 2018, 11:04
Hi dordkash@gmail.com,
Your code is located in the OnBar method. It is highly unlikely that the bid price will become higher by one pip from the previous high. Maybe you would like to reconsided your logic.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
14 Feb 2018, 10:29
Hi thegreat.super,
Unfortunately, it is not easy to help you if I don't have the same conditions as you. I have provided a link above that explains what this exception means. Probably a variable is used somewhere without being initialized first or having a null value. If you try to debug this cBot using Visual Studio, then it will be easy to find out where the exception is thrown and fix it.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
14 Feb 2018, 10:06
Hi swingfish,
If you want to remove TP and SL from a position, you need to modify it and set the relevant fields to null. See below
ModifyPosition(position, null, null);
A suggestion to improve your cBot's performance is to keep track of the open volume during position opening and closing so that you can avoid the loop that counts it.
Let me know if this helps you
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 15:52
Hi Elias,
You can develop your cBot based on the example above. If you need professional help developing your cBot you can contact a Consultant or post a Job.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 14:44
Hi luoyefengxing,
Please send us the cBot code and the backtesting configuration so that we can check and tell you why it stopped.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 12:51
Hi Elias,
It is not very clear what you are trying to do since the code you have posted seems to be a mixup of a cBot and an Indicator. If you want to call the MACD Crossover indicator in a cBot, see a simple example below.
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 NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } private MacdCrossOver _macdCrossOver; protected override void OnStart() { _macdCrossOver = Indicators.MacdCrossOver(28,12,9); } protected override void OnTick() { } protected override void OnStop() { // Put your deinitialization logic here } } }
Let me know if this is what you are looking for.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 11:15
Hi luoyefengxing,
Thanks for posting in our forum. Why do you say that cBot uses data only in 2014? What makes you think that?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 11:10
Hi Alexander,
The cBot stops because of this condition
if (StoppedByRobot == false) { Print("Sorry"); Stop(); }
What was your intention writing this part?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 10:30
Hi Alexander,
Can I have your exact backtesting configuration (broker, timeframe, start and end dates, cbot parameters, starting volume etc) so that I can reproduce and see if I can advise you on this?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 10:15
Hi dordkash@gmail.com,
Can you share your cBot code? Also please provide some more information on what the cBot is supposed to do.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 10:02
Hi swingfish,
Did you try it and noticed any performance issues? What you describe is a simple loop therefore not much things can be done from an algorithmic perspective. I would advise you to use ModifyPositionAsync to modify your TP and SL to improve the speed of execution of your bulk changes.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 09:51
Hi boutainachakir13,
Try to perform a clean installation and let me know if this resolves the problem.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 09:47
Hi tmc.
We have added this issue to the backlog to be addressed.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
13 Feb 2018, 09:33
Hi waisuklondon@gmail.com,
Thanks for posting in our forum. What do you mean to convert an indicator to a cBot? Do you mean to access the indicator through a cBot, read its values and trade based on them?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Feb 2018, 12:10
Hi juangmez87,
Stop Limit Order is currently not available in cAlgo.API. It will be added in a future release.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Feb 2018, 11:49
Hi itmfar,
I was with the impression that you wanted to place orders only on the D sign, Here it is for S sign as well
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Collections.Generic; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)] public MovingAverageType maType { get; set; } private StochasticOscillator _stochastic; private readonly List<bool> _ssdRising = new List<bool>(); [Parameter("Source")] public DataSeries Source { get; set; } protected override void OnStart() { _stochastic = Indicators.StochasticOscillator(9, 3, 9, maType); } protected override void OnBar() { _ssdRising.Add(_stochastic.PercentD.IsRising()); if (_ssdRising.Count > 1) { FindSSCrossovers(Source.Count - 1); DrawLinesSSD(Source.Count - 1); } } private void FindSSCrossovers(int index) { if (_stochastic.PercentD.HasCrossedAbove(_stochastic.PercentK, 0)) { ChartObjects.DrawText("MAXss1" + index, "S⮟", index, Source[index], VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Yellow); ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "lalbelmax", 120, 200); } else { ChartObjects.RemoveObject("MAXss1" + index); } if (_stochastic.PercentK.HasCrossedAbove(_stochastic.PercentD, 0)) { ChartObjects.DrawText("Minss1" + index, "S⮝", index, Source[index], VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.Yellow); ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "lalbelmax", 120, 200); } else { ChartObjects.RemoveObject("Minss1" + index); } } private void DrawLinesSSD(int index) { if (_ssdRising[_ssdRising.Count - 2] != _ssdRising[_ssdRising.Count - 1] && _stochastic.PercentD[index] > 60 && _ssdRising[_ssdRising.Count - 1] == false) { ChartObjects.DrawText("maxrssd" + index, "D⮟", index, Source[index], VerticalAlignment.Top, HorizontalAlignment.Center, Colors.White); ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, "lalbelmax", 120, 200); } else { ChartObjects.RemoveObject("maxrssd" + index); } if (_ssdRising[_ssdRising.Count - 2] != _ssdRising[_ssdRising.Count - 1] && _stochastic.PercentD[index] < 40 && _ssdRising[_ssdRising.Count - 1] == true) { ChartObjects.DrawText("minrssd" + index, "D⮝", index, Source[index], VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.White); ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, "lalbelmax", 120, 200); } else { ChartObjects.RemoveObject("minrssd" + index); } } protected override void OnStop() { // Put your deinitialization logic here } } }
Let me know if this works.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
15 Feb 2018, 10:49
Hi megamemo,
It is not very clear to us what you are looking for. Do you need a cBot that implements OCO? Please elaborate so that we can help you.
Best Regards,
Panagiotis
@PanagiotisCharalampous