Please provide us with the exact steps you follow to reproduce this behavior so that we can explain what happens. If you can record a video, it would be helpful.
Price feeds are a responsibility of the broker. Please talk to them.
Regarding the dates, months change on UTC+3 timezone. So if you want to see the starting date as the first day of the month, you need to change your timezone to UTC+3.
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
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.
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.
Thank you for reporting this issue. Unfortunately we were not able to reproduce this behavior. Could you pleasesend us some troubleshooting information the next time this happens? Please paste a link to this discussion inside the text box before you submit it.
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
Do OnTick() and OnBar() get triggered? Do your methods still get called? Does the code get blocked somewhere else?
The bot uses both OnBar() and onTimer() but it's a choice i can make in a setting to make via a setting.
the bot does print a status text on the chart its deployed, and this does stop updating, so i guess the OnBar,OnTick and OnTimer are not called anymore.
when i stop the bot it takes much longer for it to stop, and when i start it again it does work just fine for some time.
and yes like you wrote it surely has somethings to do with my terrible code, i just don't know how to diagnose it.
it does write a file, calculates exposure and displays it, keeps profit/loss in a variable thats written to the filesystem.
it also has a feature to auto-hedge and other things, but all those things are disabled via settings and are never called.
i could add some printouts but those would create alot of log-traffic and the whole loop is running rather quickly as it really just writes the file OnBar only (this is to prevent too much harddisc traffic) and otherwise just recalculates the risk values based on realtime data such as equity/balance/and so on.
Hi swingfish,
Any change it gets stuck in a loop or gets locked by waiting sore resource to be released e.g an open file? Just throwing ideas around since I have no idea about the specifics of your cBot.
You need to provide more specific information regarding what you are doing. As a starting point, try connecting using the FIX API Example application. If the connection is successful, then compare it with your implementation and find what you are doing different. If you cannot connect using the FIX API Example, please provide us with more information (host name, account, credentials, messages exchanged etc) so that we can test it as well.
PanagiotisCharalampous
14 Apr 2024, 08:15
Dear Matt,
Please provide us with the exact steps you follow to reproduce this behavior so that we can explain what happens. If you can record a video, it would be helpful.
Best regards,
Panagiotis
@PanagiotisCharalampous