Topics
Replies
firemyst
07 Feb 2020, 11:10
RE:
PanagiotisCharalampous said:
Hi firemyst,
I would just use a boolean flag indicating if the Calculate() method has been executed.
Best Regards,
Panagiotis
Thanks for your suggestion @Panagiotis, but I don't follow?
If we start our indicator and the current index is 7160, we want Calculate() to do all the indexes up to 7160, which it will. But it will be called 7159 times. On index 7160 we don't want Calculate() to run any more as the TimerEvent will be taking over with the current and latest data.
The below is what I currently have (which seems to work), so not sure how you're thinking of implementing the flag?
public override void Calculate(int index)
{
//Only do the following if we're on the current symbol's chart
if (_symbols[_currentSymbolsIndex] == Symbol.Name)
{
//Put this here to make sure we only calculate the history. The TimerEvent will do all the current stuff.
if (index >= _firstIndex[_currentSymbolsIndex])
return;
// rest of work here for calculating historic values
}
}
private void TimerEvent()
{
int arrayLength = _symbols.Length;
Parallel.For(0, arrayLength, x =>
{
_index[x] = _marketSeries[x].ClosePrices.Count - 1;
//do some work and calculations for the indicator
});
}
@firemyst
firemyst
07 Feb 2020, 10:06
RE:
PanagiotisCharalampous said:
Hi firemyst,
1) Timer event should work as well.
2) We had to make this change to fix other issues with indicators not being updated after reconnections
Best Regards,
Panagiotis
So what's the best way then to have the "calculate" method called so it draws indicators based on all previous values, and then switch over to the Timer Event to run everything that's current?
For example, we load an indicator. In the Initialize method should we then get the current index of the current chart's symbol?
_index = _marketSeries.ClosePrices.Count - 1;
_firstIndex = _index;
Then in the calculate method check if index > _index and if so, return?
if (index > _index) return;
Meanwhile, in the TimerEvent method,
_index = _marketSeries.ClosePrices.Count - 1;
if (_index <= _firstIndex) return;
Or is there another, suggested way we should do this?
@firemyst
firemyst
07 Feb 2020, 02:21
RE:
PanagiotisCharalampous said:
Hi firemyst,
In 3.7 all output series are cleared after initialization. All value assignments in output series should take place inside Calculate method.
Best Regards,
Panagiotis
This is a HUGE functionality change.
We have numerous indicators that monitor several symbols at once, and to ensure we always have their latest values, we run the timer every second or two, which provides consistency. We do this because there could be loooooooooooong gaps between ticks when the calculate method is actually called - eg, the other symbols being monitored on the current chart might have had numerous ticks in the space of one tick from the current symbol.
1) So if you're saying all value assignments should take place inside calculate, how does Spotware suggest we populate output series for all indicators that use the timer method for getting values ( as described above ) instead of calculate?
This is the basic gist of what we currently do:
private void TimerEvent()
{
int arrayLength = _symbols.Length;
Parallel.For(0, arrayLength, x =>
{
_index[x] = _marketSeries[x].ClosePrices.Count - 1;
Symbol s = Symbols.GetSymbol(_marketSeries[x].SymbolName);
//do stuff
//update histogram value
if (_symbols[x] == Symbol.Name)
{
Result[_index[x]] = _overallSignal[x];
// ....
}
//do more stuff
//update chart text with other symbols this indicator is watching simultaneously
_chartText[x] += " blah blah blah blah ";
});
//concatenate and write text on indicator
}
2) I'm curious as to why this decision was made? Isn't the point of an initialize routine to allow for the initialization of variables and settings?
Thank you.
@firemyst
firemyst
05 Feb 2020, 15:52
( Updated at: 21 Dec 2023, 09:21 )
RE:
We're now up to Version 3.7 of cTrader Desktop and this issue still isn't resolved?
Spotware, this isn't looking good that indicators supplied with your product aren't working properly, and haven't been working for several versions now.
@firemyst
firemyst
05 Feb 2020, 12:02
RE:
firemyst said:
With API 3.7:
MarketData.GetSeries
is now obsolete, but there's no suggested replacement? How do we now get a different symbol and timeframe's data other than the currently viewed chart? Eg, if I'm viewing the US30 on an M1 chart, and want to get data from the GER30 M1, how do we now do this? It used to be MarketData.GetSeries(_symbol, _timeFrame);
Also, when will the online API guide be updated? I can't find the new "bars" interface in it.
Thank you.
I just found it.
I believe it's now:
MarketData.GetBars(Bars.TimeFrame, _symbol);
However, if I'm wrong or there's something else I should be using, please let me know.
Thanks!
@firemyst
firemyst
22 Jan 2020, 00:59
RE:
PanagiotisCharalampous said:
Hi firemyst,
You can use Chart.DrawTrendLine() for this.
Best Regards,
Panagiotis
Thanks @Panagiotis! That's what I needed. Only tricky part was remembering to set the 2 datetime parameters (x-axis) to the same value.
@firemyst
firemyst
21 Jan 2020, 03:56
RE:
PanagiotisCharalampous said:
Hi firemyst,
This is by design. The form does not display the parameter value as modified during execution. It shows only the default value.
Best Regards,
Panagiotis
Hi @Panagiotis:
This isn't entirely true. If a user edits the parameters during execution, they are remembered. Take the above indicator code for example.
Add the indicator to a chart.
Now open the indicator, edit the value, and close the properties window.
Then, open the properties window back up of the indicator and the value is there. Eg, it's "saved" when changed manually by the user.
So it doesn't only show the "default" value, right?
Thus if it can save the value during execution by the user by changing the value in the properties manually, then it should be able to be saved when changed programmatically by the indicator itself.
@firemyst
firemyst
12 Jan 2020, 17:36
RE: RE:
firemyst said:
PanagiotisCharalampous said:
Hi firemyst,
Because this part of the code was not executed. The indicator is initialized only after it has been added on the chart. If you need the parameter to show a value, you need to put a default value.
Best Regards,
Panagiotis
I'm confused@Panagiotis, because I do add it to the chart as I said in the comments in the code. Let me repeat them here:
//Unexpected behavior in cTrader? //Add this indicator to any chart. //Leave the parameter blank. It should "set" the value to "Hello" in the Initialize method. //Call up the parameter window again for this indicator //the value "Hello" isn't displayed even though it has been set. //Why not?
After it's added to the chart, if you call up the indicator to view the properties, it's blank.
Hence why the cTrader window says, "Modify indicator" instead of "Add indicator" (when it's first being addedto the chart).
Any updates @Panagiotis? Have you been able to reproduce the issue with the code I've provided above?
@firemyst
firemyst
07 Jan 2020, 11:02
RE:
PanagiotisCharalampous said:
Hi firemyst,
Because this part of the code was not executed. The indicator is initialized only after it has been added on the chart. If you need the parameter to show a value, you need to put a default value.
Best Regards,
Panagiotis
I'm confused@Panagiotis, because I do add it to the chart as I said in the comments in the code. Let me repeat them here:
//Unexpected behavior in cTrader?
//Add this indicator to any chart.
//Leave the parameter blank. It should "set" the value to "Hello" in the Initialize method.
//Call up the parameter window again for this indicator
//the value "Hello" isn't displayed even though it has been set.
//Why not?
After it's added to the chart, if you call up the indicator to view the properties, it's blank.
Hence why the cTrader window says, "Modify indicator" instead of "Add indicator" (when it's first being addedto the chart).
@firemyst
firemyst
07 Jan 2020, 10:59
RE: RE:
PanagiotisCharalampous said:
firemyst said:
@Panagiotis / Spotware:
Does this answer still hold true?
I want to retrieve historical spread data in indicator and bot code, and I can't seem to find a way to get historical spread values, or (at the very least) historical bid/ask prices on each historical candle close
Is there a way to do this?
Thank you.
Hi firemyst,
To find the historical spread just check the difference the historical bid/ask prices when running backtesting using tick data.
Best Regards,
Panagiotis
Sorry for the confusion -- I meant is it possible to get this data programmatically? Eg, in cbot code what can I do to get the historical data in real time if it's possible? For example, if I'm on the H1 timeframe, and currently at the 11am candle, if I want to obtain the spread in the cbot code at the close of the 8am candle, how would I do it?
Thank you.
@firemyst
firemyst
05 Jan 2020, 07:58
@Panagiotis / Spotware:
Does this answer still hold true?
I want to retrieve historical spread data in indicator and bot code, and I can't seem to find a way to get historical spread values, or (at the very least) historical bid/ask prices on each historical candle close
Is there a way to do this?
Thank you.
@firemyst
firemyst
02 Jan 2020, 05:22
RE: RE: precision if stopLoss or takeProfit is specified in pips
thomas.abele said:
PanagiotisCharalampous said:
Hi FireMyst,
Backtesting is a simulation of the trading on your machine. It does not communicate with the server and it does not account for all possible parameretes of a cBot's runtime. The specific error is sent by the server where the checks are a bit more strict. I would advise you to test your cBots on a demo account as well before moving to a live trading account.
Best Regards,
Panagiotis
Hi Panagiotis,
I saw for most Symbols the precision for stopLoss or takeProfit specified in pips is 1 digit. But for e.g. XAUUSD it is 0 digits.
Is there a way to find out programatically what the precision is?
Kind Regards,
Thomas
@Thomas:
Is Symbol.Digits what you're looking for? https://ctrader.com/api/reference/internals/symbol
@firemyst
firemyst
19 Dec 2019, 08:40
RE:
PanagiotisCharalampous said:
Hi FireMyst,
As far as I know it is the close price which is considering only the bid price.
Best Regards,
Panagiotis
Thanks @Panagiotis.
Any chance your team is going to include this popular indicator in an upcoming release of cTrader?
@firemyst
firemyst
16 Dec 2019, 10:56
RE:
PanagiotisCharalampous said:
Hi zedodia,
Do you have specific steps that will allow us to reproduce this problem?
Best Regards,
Panagiotis
HI @Panagiotis:
I haven't seen any updates on this, so have sent you an email with a video attached on another way to reproduce the issue.
The email has "https://ctrader.com/forum/ctrader-support/22249?page=1" in the subject.
@firemyst
firemyst
10 Dec 2019, 14:54
RE:
PanagiotisCharalampous said:
Hi firemyst,
I have checked this is the past and it seems to be an issue with the way the values are calculated for each bar in the real time and what happens when some ticks are missed. I haven't tried to solve it but I would try to recalculate the value of each closed bar when the bar changes and the OHLC data for the previous bar is finalized.
Best Regards,
Panagiotis
Thanks @Panagiotis.
That gives me a good starting point.
@firemyst
firemyst
10 Dec 2019, 14:38
RE:
PanagiotisCharalampous said:
Hi firemyst,
Supertrend is a custom indicator and if you are using the one available in the forum, it has a lot of defects. This is one of them.
Best Regards,
Panagiotis
If I post the code would you be able to have a quick look and see what the problem is? I'd like to know how I can alter the code to overcome this defect. Or at least what's causing it and why it happens.
@firemyst
firemyst
05 Dec 2019, 06:31
RE:
gowens.c@gmail.com said:
Also to note: they allowed US citizens to use cTrader, Spotware did, until about 3 or 4months ago. Why?
I want someone from Spotware to answer my question
Out of curiosity, did you ever receive a response? I don't see any in this thread, but that's not to say they didn't message you separately. I know a few people in the USA who would like to use cTrader.
Thanks :-)
@firemyst
firemyst
05 Dec 2019, 02:11
( Updated at: 21 Dec 2023, 09:21 )
RE:
PanagiotisCharalampous said:
Hi FireMyst,
https://ctrader.com/forum/ctrader-support/22129 Yes
https://ctrader.com/forum/ctrader-support/21482 No
https://ctrader.com/forum/ctrader-support/21540 No
https://ctrader.com/forum/calgo-support/21534 No
Please join our Telegram group where we report such updates e.g.
Best Regards,
Panagiotis
HI @Panagiotis:
Thank you for the updates. I think you need to at least update thread 22129 then to indicate to everyone it has been resolved :-)
As for Telegram - we have the forums - how hard is it to create a separate forum and/or a read-only thread and include the updates there? Users should not have to download another application and join yet another Spotware group in that application to now find out the latest updates.
Or is Spotware going to put a Directory on their website that tells users what they should do and where they should go to get certain information?
- Spotware.com -> product information, sales information, download actual products
- Facebook -> latest sales/marketing promotions
- cTrader.com -> forums and latest API announcements
- Telegram -> latest change release logs
etc etc etc.
Getting a bit ridiculous don't you think?
How many 3rd party applications, services, and systems does Spotware want us to sign up to in order to use and get information on their products?
@firemyst
firemyst
10 Feb 2020, 04:45
RE:
koktos632 said:
I do all the time as long as the index you're modifying isn't the current index as per the parameter in the Calculate method. This is because unless you implement locking, the calculate method could try and update the index the same time you are.
Here's a quick code example of what you might put in both the Calculate and your other methods to control the locking.
Create your own "_lockObject" at the global class level.
The below code will try to enter and perform the actions within the try/finally block. It will wait for the amount of milliseconds specified to acquire the lock. If it can't, it will skip the code; otherwise the code will execute.
@firemyst