Topics
Replies
firemyst
06 May 2019, 12:11
( Updated at: 21 Dec 2023, 09:21 )
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Probably this is what is happening but I cannot confirm if I do not execute this myself :)
Best Regards,
Panagiotis
Here you go. Still doing it in cTrader 3.5 Beta. It says "-536" at the top, but at the bottom the "balance" is below 9000 and the equity is all over the place:
Here is the code so you can run it yourself:
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 TestBot : Robot { private string _positionLabel = String.Empty; private MarketSeries _marketSeries; protected override void OnStart() { _marketSeries = MarketData.GetSeries(Symbol, MarketSeries.TimeFrame); DataSeries series = _marketSeries.Close; _positionLabel = (MarketSeries.TimeFrame) + " " + Symbol.Code + " Test Bot"; } protected override void OnTick() { if (SumOfLongEntryConditions() >= 5) Print("Hello"); else Print("Oh no!"); if (Positions.Count < 1) ExecuteMarketOrder(TradeType.Buy, Symbol, 100000, "test", 10, null); } private int SumOfLongEntryConditions() { int _sumOfLongEntryConditions = 4; return _sumOfLongEntryConditions; } } }
I'll be eagerly awaiting :-)
@firemyst
firemyst
06 May 2019, 12:05
( Updated at: 21 Dec 2023, 09:21 )
Error in Intellisense and perhaps a bug?
HI SpotWare:
1) See the red-lines in screen capture. How come the property says "{ get; }", yet the description says "Get or sets"? It can't set if there's no "set" implementation.
2) See the compile error. I have this code under a Bot instance of "EURUSD", so how come SymbolName isn't valid in the current context if that's what we're supposed to use?
See screen capture:
3) If I replace "SymbolName" with "Symbol" on line 32, the compiler doesn't spit out an error message about using "Symbol.Code" on line 21 even though it's not there according to Intellisense. If it's 'deprecated', the compiler should at least say so:
Thank you.
@firemyst
firemyst
02 May 2019, 06:37
RE:
DonaldD said:
Hi guys,
I am planning to develop some more indicators for cTrader (both paid and free) and I was wondering which indicators do you think are missing and would be worth adding to cTrader ecosystem? Suggestions as well as documentation about the indicators would be highly appreciated!
Donald
* John Ehlers Hilbert Sine Wave and Oscillator or at leasts something similar to https://emini-watch.com/trading-indicators/hilbert-sine-wave/
@firemyst
firemyst
02 May 2019, 05:32
RE:
tgjobscv said:
F**king error:
cTrader.exe - aplikation error - the exception unknown software exception (0xe0434352) occurred in the application at location at location 0x753f1cda.
What now ?
How fix ?
Regards.
Have you tried debugging your code, and running it line-by-line in Visual Studio to see exactly where it occurs in your code? Or at least rule out that it's not your code specifically causing the error?
@firemyst
firemyst
02 May 2019, 05:31
As a side note, you might get some responses if you add a bit more details to the requirements you're wanting.
For example:
1) do you want this "shift" to be parameterized so it can be easily configured/adjusted without having to recompile code each time?
2) what exactly do you mean by "Shift"? What you think you are referring to might be different than what the reader understands.
etc etc.
@firemyst
firemyst
25 Apr 2019, 12:31
( Updated at: 21 Dec 2023, 09:21 )
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Can you post the cBot code?
Best Regards,
Panagiotis
HI @Panagiotis:
I think I figured out what is happening. Look at these screen captures and hopefully you agree. :-)
1) The equity chart is above $10,500. On the top portion though, it shows " +51" profit.
2) Under the "History tab" I have one trade that's profitable at $530.21.
3) Under the "Events tab" It shows the first position that was opened/closed, then a second position that's opened, and still opened. You can see the details.
4) Here is the Trading Info.
So it looks to me like what cTrader is saying (which is confusing) is:
1) I have a balance of over $10,500 AUD when the backtesting completes.
2) However, at the point at where the backtesting stopped, if the last position was to be closed out, I would only be up +$51 AUD overall because my current position is in a loss (bought at 0.86748 and last tick as indicated on chart is 0.86512 == -0.00236). But because it isn't closed, that's why my "balance" is over $10,500.
I'm not sure if all those pips/numbers add up to bring it down to only +51, but it seems reasonable.
Are you able to confirm if that's intended functionality? If so, I wonder if there's a better way to convey that difference? Like maybe somehow indicate the current balance, but then in parenthesis say, "(+$51 if last open position is closed)"?
If you agree/confirm the above functionality, that's great, and appreciate you looking into it. :-)
If not, let me know and I'll see if I can find a simple portion of the code to reproduce the results.
@firemyst
firemyst
25 Apr 2019, 11:26
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Can you post the cBot code?
Best Regards,
Panagiotis
HI @Panagiotis:
No I am not posting this code unless I manage to come up with simpler code that reproduces the issue.
Maybe it's an issue related to the bug I reported here:
https://ctrader.com/forum/calgo-support/16336
?
@firemyst
firemyst
19 Apr 2019, 07:59
RE: RE: RE:
virtuesoft said:
Hi,
I no longer use the code above. It is a lot easier to calculate the volume now that Symbol.PipSize has been added to the API.
Here is the code I am now using...
private void CalculateVolume() { // Our total balance is our account balance plus any reserve funds. We do not always keep all our money in the trading account. double totalBalance = Account.Balance + ReserveFunds; // Calculate the total risk allowed per trade. double riskPerTrade = (totalBalance * RiskPercent) / 100; // Add the stop loss, commission pips and spread to get the total pips used for the volume calculation. double totalPips = StopLoss + CommissionPips + Symbol.Spread; // Calculate the exact volume to be traded. Then round the volume to the nearest 100,000 and convert to an int so that it can be returned to the caller. double exactVolume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2); _volume = (((int)exactVolume) / 100000) * 100000; // Finally, check that the calculated volume is not greater than the MaxVolume parameter. If it is greater, reduce the volume to the MaxVolume value. if (_volume > MaxVolume) _volume = MaxVolume; }
I believe lines 13 onwards in post #5 should now be changed to:
double exactVolume = Math.Round(riskPerTrade / (Symbol.PipValue * totalPips), 2); //Choose your own rounding mode exactVolume = (int)Symbol.NormalizeVolumeInUnits(exactVolume, RoundingMode.Down); // Finally, check that the calculated volume is not greater than the MaxVolume parameter. If it is greater, reduce the volume to the MaxVolume value. if (exactVolume > MaxVolume) exactVolume = MaxVolume;
@firemyst
firemyst
15 Apr 2019, 03:05
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Can you please share with us the cBot code so that we can reproduce these results?
Best Regards,
Panagiotis
No worries. I didn't know if you wanted it public or sent privately. Anyway, here you go. Set the timeframe to H1 (1 hour). I just tried again with EURUSD and AUDJPY pairs on both PepperStone and IC Markets for March 7-8, 2019 with similar results:
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 TestBot : Robot { [Parameter(DefaultValue = 1000)] public int PositionSize { get; set; } private string _positionLabel = String.Empty; private double _stopLossInPips = 50; private double _runningTotalGainLoss = 0; private readonly double StopBotWhenLossesFallBelow = -1000; protected override void OnStart() { _positionLabel = (MarketSeries.TimeFrame) + " " + Symbol.Code + " Test Bot"; Positions.Closed += Positions_Closed; Positions.Opened += Positions_Opened; } private void Positions_Closed(PositionClosedEventArgs args) { Position p = args.Position; _runningTotalGainLoss += p.NetProfit; if (_runningTotalGainLoss < StopBotWhenLossesFallBelow) { Print("WARNING! Running total {0} has fallen below StopBotWhenLossesFallBelow {1} threshold! Stopping bot for {2}!", String.Format("{0:$#,###.00}", _runningTotalGainLoss), String.Format("{0:$#,###.00}", StopBotWhenLossesFallBelow), _positionLabel); Stop(); return; } } private void Positions_Opened(PositionOpenedEventArgs args) { Position p = args.Position; double stopLossMultiplier = 0.8; TradeResult r = p.ModifyStopLossPrice(p.EntryPrice * stopLossMultiplier); } protected override void OnTick() { // Put your core logic here if (Positions.Count == 0) { string commentString = _positionLabel + "; Short Buy; " + String.Format("{0:#,###}", PositionSize) + "; TSL in Pips:" + String.Format("{0:#,###.00000}", _stopLossInPips) + "; Approx Time:" + DateTime.Now.ToString("yyyyMMdd HH:mm:ss"); Print("{0}", commentString); TradeResult r = ExecuteMarketOrder(TradeType.Sell, Symbol, PositionSize, _positionLabel, _stopLossInPips, null, null, "blah", true); } } } }
@firemyst
firemyst
12 Apr 2019, 13:26
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Try to round the TSL to one decimal place.
Best Regards,
Panagiotis
Rounding the Stop Loss to 1 decimal point worked.
It still doesn't answer the question though -- why does it work in backtesting?
If such functionality isn't going to work in a "live" account, it shouldn't work while backtesting in a demo account.
Is this a cTrader bug or known issue?
@firemyst
firemyst
11 Apr 2019, 03:05
RE:
Panagiotis Charalampous said:
Hi FireMyst,
Try to round the TSL to one decimal place.
Best Regards,
Panagiotis
Thank you. I will try it today and let you know.
I have a question though -- it works perfectly while backtesting. No orders rejected. Why would that be the case?
That seems like a big flaw and major functional inconsistency if we can submit orders with stop losses in pips with 2-4 decimal places while backtesting in a demo account, but they're rejected by the same broker when not backtesting in the same demo account.
@firemyst
firemyst
11 Apr 2019, 02:56
( Updated at: 21 Dec 2023, 09:21 )
Any updates?
Panagiotis Charalampous said:
Hi Daniel,
Currently cAlgo does not offer any of the two functionalities. However, they are both in our backlog therefore you should expect them in a future release of cAlgo.
Best Regards,
Panagiotis
@Hi Panagiotis:
Any further updates on this functionality? It would be really fantastic to especially have the color zones on indicators.
Also, I hope cTrader implements it as well as ProRealTime as they do an awesome job. Here's a screen capture showing an example for your team so you can see how well your competition does it. What I especially like is how configurable their color-zone configuration is. For instance here, notice how I have one value greater-than the other:
Here's another showing the further power and flexibility I hope cTrader implements. Notice the different color zones I have, and the different conditions with the %B Bollinger Bands:
Please keep us posted on cTrader's progress.
Thanks!
@firemyst
firemyst
10 Apr 2019, 08:35
RE:
Anka Software said:
Adding a Positions.Modified event handler, causes the robot to hang in backtester.
Just for clarification, would you be able to post the sample of your code that adds the handler so the rest of us can see how you're doing it?
Ex:
protected override void OnStart() { //Events Positions.Opened += Positions_Opened; Positions.Closed += Positions_Closed; //blah blah blah }
@firemyst
firemyst
06 May 2019, 12:20 ( Updated at: 19 Mar 2025, 08:57 )
RE:
Panagiotis Charalampous said:
Sent. Let me know if you don't receive it.
NOTE! : the attached CS file as some characters in UNICODE format, so if you open the text file in something other than Visual Studio or Notepad++, they may be lost, and they may be part of what's causing the issue.
Description with how to reproduce the issue is embedded within the code with comments.
Thank you.
@firemyst