Replies
thenewlearner
18 Apr 2021, 15:32
RE:
thanks amusleh
the thing which is strange is this code works for m1 and m5 but not m15 or h1. So that is confusing for me.
I was expecting might be the history in ctrader is not up-to-date (like metatrader there is a history tab and some time you just need to download the history yourself)
If you have time, then can you tell exactly what to modify in the code to work.
Thanks once again
amusleh said:
This line is the issue:
sb.Append(((Bars.Last(i).High + Bars.Last(i).Low) / 2).ToString());
It throws argument out of range because you don't check the number of available values inside bars collection.
You have to check if there is that many bars or not via Bars Count property before trying to access a value via an index or last method.
And for working with URIs I recommend you to use .NET UriBuilder instead of StringBuilder.
To debug your indicator/cBot use Print method or attach Visual Studio debugger and set break points.
@thenewlearner
thenewlearner
19 Apr 2021, 12:34
RE:
Thanks a lot
now it does not throw error..
But main issue is still present i.e. trying to load more history then available. i.e. if i do the count of hourly history bars = 128 for gbpusd, But I require 269 bars of data is required.
I searched on the forum and it appears LoadMoreHistory does not work.
Any suggestion
Regards
@thenewlearner