Topics
Replies
BJORNBERNAU
22 Feb 2022, 09:43
( Updated at: 21 Dec 2023, 09:22 )
RE: RE:
BJORNBERNAU said:
firemyst said:
HI @BJORNBERNAU
Running through Visual studio on a chart:
most of the data series in the indicator itself is NaN as you can see above.
In your bot you never get the latest indicator values before checking the latest indicator values.
It could the "lazy loading" of indicators from cbots as @Panagiotis mentioned in your thread here from Aug 3, 2020:
Also see the last post in this thread:
So you need to force the indicator to call the calculate method before you access any of the indicator's data series.
Again, thank you.
I've just posted a broader inquiry on this issue.
https://ctrader.com/forum/indicator-support/37673
A new problem arises when I define a VAR as you suggest. How then is it converted into a IndicatorDataSeries which is defined as a parameter in the program? In doing so the Indicator doesn't work anymore.
And do we really have to go that far as to define the LAZY class to use this system?
Thank you!
This is what I tried. I don't know if it is in accordance with your recommendations.
if (high == 1)
{
HIGHstartCountIndexZERO += 1;
}
var sell_ONE = Bars.HighPrices.Last(0);
if (high == 0)
{
sell_ONE = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 != 0)
{
sell_ONE = Bars.HighPrices.Last(0);
}
var liq_ONE = Bars.HighPrices.Last(0);
if (high == 0)
{
liq_ONE = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 == 0)
{
liq_ONE = Bars.HighPrices[index - 0];
}
}
@BJORNBERNAU
BJORNBERNAU
22 Feb 2022, 09:40
( Updated at: 21 Dec 2023, 09:22 )
RE:
firemyst said:
HI @BJORNBERNAU
Running through Visual studio on a chart:
most of the data series in the indicator itself is NaN as you can see above.
In your bot you never get the latest indicator values before checking the latest indicator values.
It could the "lazy loading" of indicators from cbots as @Panagiotis mentioned in your thread here from Aug 3, 2020:
Also see the last post in this thread:
So you need to force the indicator to call the calculate method before you access any of the indicator's data series.
Again, thank you.
I've just posted a broader inquiry on this issue.
https://ctrader.com/forum/indicator-support/37673
A new problem arises when I define a VAR as you suggest. How then is it converted into a IndicatorDataSeries which is defined as a parameter in the program? In doing so the Indicator doesn't work anymore.
And do we really have to go that far as to define the LAZY class to use this system?
Thank you!
@BJORNBERNAU
BJORNBERNAU
21 Feb 2022, 16:30
RE:
firemyst said:
Glancing at your code, a possible problem is you never actually set the last value of either data series.
You only ever populate [index - 2] of either sell_One or liq_one, never [index].
Therefore:
s2.liq_one.last(0) is NAN
s2.sell_one.last(0) is NAN
s2.liq_one.last(1) is NAN
s2.sell_one.last(1) is NAN
so the .Last(0) values are both the same, hence the reason they both print out and don't alternate.
Similarly, the .Last(1) values are both the same too.
Hello Firemyst,
And thank you for putting your time into this.
I actually tried this and in fact, there are indeed given IndicatorDataSeries as expected, they are not finalised as double.NAN as suggested. Adding printing snippets to the signal code, with the following script
if (high4 <= high2)
if (high3 <= high2)
if (high2 > BBT2)
if (high2 >= high1)
if (high2 >= close0)
{
high = 1;
}
if (high == 1)
{
HIGHstartCountIndexZERO += 1;
}
if (high == 0)
{
sell_ONE[index - 2] = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 != 0)
{
sell_ONE[index - 2] = Bars.HighPrices[index - 2];
Print(index, " SELL ", sell_ONE);
}
if (high == 0)
{
liq_ONE[index - 2] = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 == 0)
{
liq_ONE[index - 2] = Bars.HighPrices[index - 2];
Print(index, " LIQ ", liq_ONE);
}
}
liberates full data sets as I understand them. Alternating nicely. But they are not transferred correctly into the robot. Which is my current problem.
21/02/2022 14:26:10.032 | 22 SELL IndicatorDataSeries (Count: 21, LastValue: 1,16132)
21/02/2022 14:26:10.032 | 27 LIQ IndicatorDataSeries (Count: 26, LastValue: 1,1626)
21/02/2022 14:26:10.032 | 47 SELL IndicatorDataSeries (Count: 46, LastValue: 1,16144)
21/02/2022 14:26:10.032 | 54 LIQ IndicatorDataSeries (Count: 53, LastValue: 1,16922)
21/02/2022 14:26:10.032 | 95 SELL IndicatorDataSeries (Count: 94, LastValue: 1,15754)
21/02/2022 14:26:10.032 | 105 LIQ IndicatorDataSeries (Count: 104, LastValue: 1,16087)
21/02/2022 14:26:10.032 | 107 SELL IndicatorDataSeries (Count: 106, LastValue: 1,16092)
21/02/2022 14:26:10.032 | 118 LIQ IndicatorDataSeries (Count: 117, LastValue: 1,16134)
21/02/2022 14:26:10.032 | 144 SELL IndicatorDataSeries (Count: 143, LastValue: 1,15979)
21/02/2022 14:26:10.032 | 153 LIQ IndicatorDataSeries (Count: 152, LastValue: 1,16164)
21/02/2022 14:26:10.032 | 190 SELL IndicatorDataSeries (Count: 189, LastValue: 1,1563)
21/02/2022 14:26:10.032 | 200 LIQ IndicatorDataSeries (Count: 199, LastValue: 1,15684)
Cancelling out the “index-2” and setting it to "zero" - e.g.
liq_ONE[index - 0] = Bars.HighPrices[index - 0];
in both the Indicator and Robot liberates this, several SELL after one another and then flipping back to LIQ.
20/01/2022 01:00:00.000 | Backtesting started
20/01/2022 04:00:00.000 | LIQ 128 IndicatorDataSeries (Count: 128, LastValue: 1,13549)
20/01/2022 11:00:00.000 | LIQ 135 IndicatorDataSeries (Count: 135, LastValue: 1,13476)
21/01/2022 12:00:00.000 | LIQ 160 IndicatorDataSeries (Count: 160, LastValue: 1,13391)
21/01/2022 17:00:00.000 | LIQ 165 IndicatorDataSeries (Count: 165, LastValue: 1,1346)
24/01/2022 21:00:00.000 | LIQ 193 IndicatorDataSeries (Count: 193, LastValue: 1,13198)
28/01/2022 17:00:00.000 | LIQ 285 IndicatorDataSeries (Count: 285, LastValue: 1,11643)
31/01/2022 11:00:00.000 | LIQ 303 IndicatorDataSeries (Count: 303, LastValue: 1,11747)
31/01/2022 18:00:00.000 | LIQ 310 IndicatorDataSeries (Count: 310, LastValue: 1,12101)
31/01/2022 22:00:00.000 | SELL 314 IndicatorDataSeries (Count: 314, LastValue: 1,12354)
01/02/2022 11:00:00.000 | SELL 327 IndicatorDataSeries (Count: 327, LastValue: 1,12614)
01/02/2022 14:00:00.000 | SELL 330 IndicatorDataSeries (Count: 330, LastValue: 1,12617)
02/02/2022 16:00:00.000 | SELL 356 IndicatorDataSeries (Count: 356, LastValue: 1,13048)
03/02/2022 19:00:00.000 | SELL 383 IndicatorDataSeries (Count: 383, LastValue: 1,14436)
04/02/2022 10:00:00.000 | SELL 398 IndicatorDataSeries (Count: 398, LastValue: 1,14602)
04/02/2022 14:00:00.000 | SELL 402 IndicatorDataSeries (Count: 402, LastValue: 1,14655)
07/02/2022 15:00:00.000 | SELL 427 IndicatorDataSeries (Count: 427, LastValue: 1,14398)
07/02/2022 19:00:00.000 | SELL 431 IndicatorDataSeries (Count: 431, LastValue: 1,14186)
09/02/2022 06:00:00.000 | SELL 466 IndicatorDataSeries (Count: 466, LastValue: 1,14269)
09/02/2022 13:00:00.000 | SELL 473 IndicatorDataSeries (Count: 473, LastValue: 1,14295)
09/02/2022 16:00:00.000 | SELL 476 IndicatorDataSeries (Count: 476, LastValue: 1,14317)
09/02/2022 20:00:00.000 | SELL 480 IndicatorDataSeries (Count: 480, LastValue: 1,14326)
10/02/2022 12:00:00.000 | SELL 496 IndicatorDataSeries (Count: 496, LastValue: 1,14359)
10/02/2022 16:00:00.000 | SELL 500 IndicatorDataSeries (Count: 500, LastValue: 1,14074)
10/02/2022 19:00:00.000 | LIQ 503 IndicatorDataSeries (Count: 503, LastValue: 1,14645)
11/02/2022 16:00:00.000 | LIQ 524 IndicatorDataSeries (Count: 524, LastValue: 1,13888)
11/02/2022 19:00:00.000 | LIQ 527 IndicatorDataSeries (Count: 527, LastValue: 1,13966)
15/02/2022 13:00:00.000 | LIQ 569 IndicatorDataSeries (Count: 569, LastValue: 1,13459)
15/02/2022 16:00:00.000 | LIQ 572 IndicatorDataSeries (Count: 572, LastValue: 1,1322)
15/02/2022 19:00:00.000 | LIQ 575 IndicatorDataSeries (Count: 575, LastValue: 1,13586)
16/02/2022 11:00:00.000 | LIQ 591 IndicatorDataSeries (Count: 591, LastValue: 1,13775)
16/02/2022 22:00:00.000 | LIQ 602 IndicatorDataSeries (Count: 602, LastValue: 1,13821)
18/02/2022 12:00:00.000 | LIQ 640 IndicatorDataSeries (Count: 640, LastValue: 1,13611)
21/02/2022 00:59:00.000 | Backtesting finished
@BJORNBERNAU
BJORNBERNAU
01 Sep 2021, 09:55
RE: CORRECT SOLUTION
XABBU is perfectly right!
Clicking on the dots right to message in top of log make possible restoring values.
But what is the function that lets the values disappear in log?
@BJORNBERNAU
BJORNBERNAU
15 Jan 2021, 17:07
RE:
PanagiotisCharalampous said:
Hi BJORNBERNAU,
Price alerts are not available via the API. You need to develop your own custom solution, either using message boxes or custom win forms.
Best Regards,
Panagiotis
SHOULD HAVE BEEN WRITTEN HERE
Thank you!
But I really cannot see how I can apply tick data in INDICATOR, onTICK seem reserved for Robots.
How would you construct a tick signal and compare it to Bars.OpenTimes.Last(0) ?
@BJORNBERNAU
BJORNBERNAU
15 Jan 2021, 14:19
( Updated at: 21 Dec 2023, 09:22 )
RE:
PanagiotisCharalampous said:
Hi BJORNBERNAU,
Is authentication needed
You need to ask your email provider on what is required in order to use their smtp service.
Also, I wonder how it is possible to avoid playing sound on every tick, but rather only on bar.
You need to check if Bars.OpenTimes.Last(0) has changed since the last tick and send the email only then.
Best Regards,
Panagiotis
Well,
thank you.
Is it possible to make price alerts like the one in cTrader for price levels, but for a custom indicator signal ?
Thank you!
But I really cannot see how I can apply tick data in INDICATOR, onTICK seem reserved for Robots.
How would you construct a tick signal and compare it to Bars.OpenTimes.Last(0) ?
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 15:56
if (!double.IsNaN(S2.B.Last(1)))
This works well!
Inspiring...
But,
FIRST
where is the reference to .Last(), it is not displayed in the https://ctrader.com/api/reference/bars/last
And it doesn't work with the auto dot.notation path in C#. How is it referenced?
SECOND
I still wonder whether it is possible in any easily accessible manner to present the INDEX-array in the bot program, for referencing purposes?
In cBOT I understand it is represented as COUNT.
Thank you!
And again, thank you for the clear cut answers!
Björn Bernau
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 15:15
IF values and Market Data in Cbot
Yes,
this is the path I was suspecting.
However, how do you compare a market data value, that is derived from an double array, index + value, with a NAN value?
The market data is then composed in a way that it does not allow for boolean checks. IF statements can't be used to compare Market data with a NAN-value.
How is the market data-value, just reduced to the value, excluding the index?
Thank your.
Björn
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 13:30
transferring signals
Also,
it is possible to transfer a signal as 1 or 0, and then use it in a boolean expression.
But if marketseries are used, then these are a double array.
As such market data cannot be used in a boolean IF expression.
How do we convert market data, so as to only represent price or index in cbot?
Björn
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 13:26
INDEX
Yes, thanks,
surely I have a lot to learn.
Another issue:
Is there a way to use INDEX in cBOT, i.e. in terms of COUNT or similar?
OR
is there a way to ONLY relay index count to cbot from indicator?
Björn
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 12:22
( Updated at: 21 Dec 2023, 09:22 )
INDICATOR vs ROBOT data
INDICATOR
ROBOT - the same periods show only two signals
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 12:16
( Updated at: 21 Dec 2023, 09:22 )
Zeroing out with double.NAN
Thank you!
Incidentally, I am impressed by the diligence, speed and specifics with which you are supporting.
This would mean, by "zeroing out B" when the SIGNAL = 0, would cancel the signal or rather - align - the indicator signal wit the trade signal,
but e.g. a
double d = double.NaN;
if (high > 0)
{
SIGNAL = 1;
B[index] = Bars.HighPrices[index];
}
if (high <= 0)
{
SIGNAL = 0;
B[index] = d;
}
does unfortunately not change the matter.
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 11:37
( Updated at: 21 Dec 2023, 09:22 )
ERRATIC SIGNALS
Yes - true!
A microscopic step for mankind - a giant leap for a man. ... Thank you!
But the signals are still erratic. See that the Signals (yellow points) are displayed clearly in the robot, but no trades are taken in several instances, e.g. count 5838, indicated by pink point. How is this? It seems, these signals are not consistently transferred after all.
Björn
@BJORNBERNAU
BJORNBERNAU
03 Aug 2020, 10:04
SIGNAL from CUSTOM INDICATOR
Thanks again Panagiotis,
sorry but this "SIGNAL" is liberating a constant "zero". It does not transfer this signal equaling "one" in any instance.
Cordially,
Björn
@BJORNBERNAU
BJORNBERNAU
01 Aug 2020, 14:52
RE:
PanagiotisCharalampous said:
Hi Björn,
Your mistake is here
S1 = Indicators.GetIndicator<aCBOTbaseBOLLINGER>(B, BandPeriod, Std, MAType);
I guess this is what you wanted to code instead
S1 = Indicators.GetIndicator<aCBOTbaseBOLLINGER>(Source, BandPeriod, Std, MAType);
Best Regards,
Panagiotis
Yes indeed!
Thank you, l am now entangled in the next issue, as posted.
Björn
@BJORNBERNAU
BJORNBERNAU
22 Feb 2022, 09:59 ( Updated at: 21 Dec 2023, 09:22 )
RE: RE: RE:
BJORNBERNAU said:
Converting the HIGH sighnal to VAR does not help either.
public override void Calculate(int index)
{
liquidator(index);
}
private void liquidator(int index)
{
var high = 0;
double high0 = Bars.HighPrices[index - 0];
double high1 = Bars.HighPrices[index - 1];
double high2 = Bars.HighPrices[index - 2];
double high3 = Bars.HighPrices[index - 3];
double high4 = Bars.HighPrices[index - 4];
double close0 = Bars.ClosePrices[index - 0];
var BBT1 = boll.Top[index - 1];
var BBT2 = boll.Top[index - 2];
if (high4 <= high2)
if (high3 <= high2)
if (high2 > BBT2)
if (high2 >= high1)
if (high2 >= close0)
{
high = 1;
}
if (high == 1)
{
HIGHstartCountIndexZERO += 1;
}
if (high == 0)
{
sell_ONE[index - 2] = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 != 0)
{
sell_ONE[index - 2] = Bars.HighPrices[index - 2];
// Print(index, " ", sell_ONE);
}
if (high == 0)
{
liq_ONE[index - 2] = d;
}
if (high == 1)
if (HIGHstartCountIndexZERO % 2 == 0)
{
liq_ONE[index - 2] = Bars.HighPrices[index - 2];
// Print(index, " ", liq_ONE);
}
}
@BJORNBERNAU