
Topics
Replies
PanagiotisCharalampous
09 Nov 2017, 15:06
Hi tmc.
This is probably happening because the ReferencedIndicator is not the one attached to the chart. Would like to tell us what you are trying to achieve so that we can propose a workaround?
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Nov 2017, 14:40
Hi myinvestmentsfx,
Multithreading in general was not and is not a problem for cAlgo. The discussion you posted inquires whether cAlgo application itself is multithreaded, more specifically if it runs the bots on separate threads than the main application, causing synchronization issues. The answer to this question is no, cAlgo is not running cBots in separate threads, except the Timer class, therefore there should not be any synchronization issues.
However, this does not mean that you cannot use multithreading techniques within your cBot. As long as your programming techniques are correct, then you should not experience any problems. If you want, you can post the issues you face one by one and we can discuss them.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Nov 2017, 10:03
Hi obaum1@gmail.com,
Slippage is unavoidable in the case of market execution. Market range orders, used in cTrader, ensure only the fact that your orders will be executed in the range requested, based on the available liquidity. So if the total slippage of your order, based on market conditions during execution time, is outside the market range, then your order will be filled partially only for the part that falls within your market range.
Currently FIX API does not include Marker Range and Stop Limit Orders but we plan to add them in the future.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
09 Nov 2017, 09:44
Hi guys,
Indeed cAlgo works with .Net Framework 4.0 for compatibility reasons. We will upgrade the framework in a later version.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 16:11
Hi myinvestmentsfx,
cAlgo does not crash, you just get a build error. You will get the same message if you open your indicator in Visual Studio.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 14:41
Hi itmfar,
With some more coding, you can develop something more proper, that could also take dates as input. But it will need somebody to devote time for this to developed. If i find some free time soon, then I might prepare something for you.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 13:00
Hi itmfar,
Thanks now it is more clear what you are trying to achieve. You can try the following approach
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } protected override void Initialize() { } public override void Calculate(int index) { if (IsLastBar) { ChartObjects.RemoveAllObjects(); for (int i = MarketSeries.Close.Count - 20; i < MarketSeries.Close.Count - 10; i++) ChartObjects.DrawVerticalLine("v" + i, i, Colors.White); } } } }
Let me know if this works for you.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 11:29
Hi irmfar,
It will repeat the last result since you are instructing the indicator to print only when it is at the last bar. You should change the condition as follows
public override void Calculate(int index) { if (!IsLastBar) Print(" print only once for each bar at the moment" + index); }
Let me know if this helps.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 10:50
( Updated at: 21 Dec 2023, 09:20 )
Hi itmfar,
I created an example based on your code and it seems to be working as expected. See code sample and screenshot below
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewIndicator : Indicator { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } private int secondGap; private int firstGap; protected override void Initialize() { secondGap = MarketSeries.Close.Count - 10; firstGap = MarketSeries.Close.Count - 20; } public override void Calculate(int index) { if (index > firstGap && index < secondGap) ChartObjects.DrawVerticalLine("v" + index, index, Colors.White); } } }
Let me know if I misunderstood something.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 10:35
Hi itmfar,
Calculate function is invoked once for each bar and then for each tick for the last bar. The reason this happens is that for each tick the values for the last bar change therefore the indicator might need to be recalculated. If you want to skip recalculation for the last bar, you might consider using the IsLastBar property of the Indicator.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 10:20
Hi mto1995,
PercentK is a DataSeries so it is not a single value but a collection. So you need to define which value you want to access. See below an example on how to get the last value of the DataSeries
protected override void OnTick() { var a = Indicators.StochasticOscillator(9, 3, 9, MovingAverageType.Simple); if (a.PercentK.Last() <= 80) { // close position } }
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Nov 2017, 09:29
Dear Trader,
Thanks for posting your suggestion in our forum. We appreciate the time you spent to share your thoughts with us. Your suggestion has been considered by our team for some time now but we still cannot commit to a definite answer, if it is going to be developed and when. However, seeing that there is interest for such a feature increases the chances of adding this into our backlog.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Nov 2017, 12:58
We have this in mind, don't worry :)
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Nov 2017, 12:40
Hi ycomp,
Yes we are aware of it. But we are currently in the process of designing a new community platform that will be much more improved than the current one, therefore our development efforts are focused on that direction.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Nov 2017, 11:46
Hi Nicola,
From a first sight, you could put it in the end of the foreach loop, so that the position is partially closed just after the modification. However, if you are not experienced in C# programming, I would strongly advise you to collaborate with a professional programmer to make such changes, to avoid the risk of unintended results. There is a lot of code in the cBot and will require proper testing to verify that your change does exactly what you wanted to achieve.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Nov 2017, 11:10
Hi animegalaxi,
Thanks for posting in our forum! See below an example of how you can close approximately 2/3 of a position. Note that the closing volume should always adhere to the Symbol's volume step requirements, therefore the exact 2/3 is not always achievable.
var steps = Positions[0].Volume / Symbol.VolumeStep; var stepsToClose = (int)(steps * 2 / 3); ClosePosition(Positions[0], Symbol.VolumeStep * stepsToClose);
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
07 Nov 2017, 10:13
Hi ycomp,
Currently there is no such option. However Trading API will return the same error code as Accounts API. See a similar discussion you had a while ago here.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
06 Nov 2017, 18:07
Hi andi21,
Sorry I meant to say symbol and selected timeframe. So it actually updates only the market series displayed on the chart.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
06 Nov 2017, 17:18
Hi andi21,
We had a look at the issue. The reason that it behaves like this, ut is because MarketSeries for the selected symbol are updated on scrolling on the chart while other MarketSeries for other symbols are not. We will fix the issue in a future release of cAlgo where we will add a method to get series for a specified time span.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
10 Nov 2017, 09:23 ( Updated at: 21 Dec 2023, 09:20 )
Hi swingfish,
Yes it is possible to start cTrader from command line. Just navigate to cTrader's folder and run cTrader.exe. See below an example from my computer
Currently passing parameters is not available.
Best Regards,
Panagiotis
@PanagiotisCharalampous