This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)]
public class GMMASingle : Robot
{
private GMMA _gmma;
protected override void OnStart()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
_gmma = Indicators.GetIndicator<GMMA>();
}
protected override void OnBar()
{
Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN
if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) {
ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null);
}
if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) {
ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null);
}
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{ [Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)] public class GMMASingle : Robot { private GMMA _gmma; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate _gmma = Indicators.GetIndicator<GMMA>(); } protected override void OnBar() { Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null); } if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) { ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null); } } protected override void OnStop() { // Handle cBot stop here } }}
Hi there,
Here is a visualization of your problem using the debugger
Your Indicator data series have NaN values because you do not assign anything to them when the time does not match the higher timeframe time. Hence the problems in your logic.
I do not understand why you have created a separate indicator for this and have to manage all this complexity. You could just initialize the moving averages inside your cBot and use them.
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{ [Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)] public class GMMASingle : Robot { private GMMA _gmma; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate _gmma = Indicators.GetIndicator<GMMA>(); } protected override void OnBar() { Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null); } if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) { ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null); } } protected override void OnStop() { // Handle cBot stop here } }}
Hi there,
Here is a visualization of your problem using the debugger
Your Indicator data series have NaN values because you do not assign anything to them when the time does not match the higher timeframe time. Hence the problems in your logic.
I do not understand why you have created a separate indicator for this and have to manage all this complexity. You could just initialize the moving averages inside your cBot and use them.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for the screenshot. I see the problem now.
I changed my cBot code as following and it seems to print higher time frame values correctly.
However, how can I display, for example, this _longEma2 onto my bachtest chart?
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{ [Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)] public class GMMASingle : Robot { private GMMA _gmma; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate _gmma = Indicators.GetIndicator<GMMA>(); } protected override void OnBar() { Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null); } if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) { ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null); } } protected override void OnStop() { // Handle cBot stop here } }}
Hi there,
Here is a visualization of your problem using the debugger
Your Indicator data series have NaN values because you do not assign anything to them when the time does not match the higher timeframe time. Hence the problems in your logic.
I do not understand why you have created a separate indicator for this and have to manage all this complexity. You could just initialize the moving averages inside your cBot and use them.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for the screenshot. I see the problem now.
I changed my cBot code as following and it seems to print higher time frame values correctly.
However, how can I display, for example, this _longEma2 onto my bachtest chart?
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{ [Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)] public class GMMASingle : Robot { private GMMA _gmma; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate _gmma = Indicators.GetIndicator<GMMA>(); } protected override void OnBar() { Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null); } if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) { ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null); } } protected override void OnStop() { // Handle cBot stop here } }}
Hi there,
Here is a visualization of your problem using the debugger
Your Indicator data series have NaN values because you do not assign anything to them when the time does not match the higher timeframe time. Hence the problems in your logic.
I do not understand why you have created a separate indicator for this and have to manage all this complexity. You could just initialize the moving averages inside your cBot and use them.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for the screenshot. I see the problem now.
I changed my cBot code as following and it seems to print higher time frame values correctly.
However, how can I display, for example, this _longEma2 onto my bachtest chart?
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
Thank you for your reply. I want to test my GMMA strategy with multi-timeframe.
My cBot staretegy is 1hour resolution and should be able to access to the above custom indicator(multi-timeframe GMMA)'s TimeFrame.Hour4 Last(n) values.
Can you me an example on how to code this correctly?
Hi there,
I am sorry but I cannot write the code for you. If you have specific questions, I am happy to answer them. At the moment I do not see a reason to leave the data series values to NaN.
Best regards,
Panagiotis
Hello Panagiotis,
What do you mean by “At the moment I do not see a reason to leave the data series values to NaN.” ?
I made some mistakes in my code?
Can you share the cBot code as well so that I can tell you exactly where the problem is?
Hi Panagiotis,
Yes, I can share the cBot code to you.
here it is.
using System;using System.Collections.Generic;using System.Linq;using System.Text;using cAlgo.API;using cAlgo.API.Collections;using cAlgo.API.Indicators;using cAlgo.API.Internals;using cAlgo.Indicators;namespace cAlgo.Robots{ [Robot(AccessRights = AccessRights.FullAccess, TimeZone = TimeZones.TokyoStandardTime)] public class GMMASingle : Robot { private GMMA _gmma; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate _gmma = Indicators.GetIndicator<GMMA>(); } protected override void OnBar() { Print(_gmma.LongEma1.Last(1)," ",_gmma.LongEma4.Last(1)); // <--- prints NaN NaN if (_gmma.LongEma1.IsRising() && _gmma.LongEma4.IsRising()) { ExecuteMarketOrder(TradeType.Buy, Symbol.Name, 100, "GMMA", null, null); } if (_gmma.LongEma1.IsFalling() && _gmma.LongEma4.IsFalling()) { ExecuteMarketOrder(TradeType.Sell, Symbol.Name, 100, "GMMA", null, null); } } protected override void OnStop() { // Handle cBot stop here } }}
Hi there,
Here is a visualization of your problem using the debugger
Your Indicator data series have NaN values because you do not assign anything to them when the time does not match the higher timeframe time. Hence the problems in your logic.
I do not understand why you have created a separate indicator for this and have to manage all this complexity. You could just initialize the moving averages inside your cBot and use them.
Best regards,
Panagiotis
Hi Panagiotis,
Thank you for the screenshot. I see the problem now.
I changed my cBot code as following and it seems to print higher time frame values correctly.
However, how can I display, for example, this _longEma2 onto my bachtest chart?
It's not possible to add them on the chart from the cBot but you could use your GMMA indicator for this purpose
Hi Panagiotis,
So, in this my case scenario, we need to use my custom GMMA indicator during backtest.
The problem is how to solve the NaN values things.
I'd like to get TimeFrame.Hour4 moviing average values in my 1 hour backtest resolution.
How can I do this correctly?
So, in this my case scenario, we need to use my custom GMMA indicator during backtest.
No you just need to use for visualization purposes. To solve the NaN issue requires some complicated code to be written. I cannot provide you guidance except than actually writing the code for, something I cannot afford to do at the moment.
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
PanagiotisCharalampous
11 Apr 2024, 11:45
Hi there,
This happens because you only assign values to indicator data series, when the index of each higher timeframe changes. Hence for the rest of the array elements the value stays NaN. The solution to this depends on what you want to achieve. For example, why do you
@PanagiotisCharalampous