data keeps changing MarketSeries.Close.LastValue
data keeps changing MarketSeries.Close.LastValue
23 Apr 2018, 00:31
Hi,
I'm building an indicator but I find it extreamely hard to find and fix problems because the MarketSeries.Close.LastValue data keeps changing. Here is a test that every time is a new data and not a few pips different like we expect if the data is saved periodically every Tick but very big changes
22/04/2018 22:29:14.482 | MarketSeries=1.23711; M1 MarketData= 1.23711 22/04/2018 22:29:25.480 | MarketSeries=1.21842; M1 MarketData= 1.21842
using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; using cAlgo.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class TestDataIndicator : Indicator { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } [Output("Main")] public IndicatorDataSeries Result { get; set; } private MarketSeries M1; protected override void Initialize() { M1 = MarketData.GetSeries(TimeFrame.Minute); } public override void Calculate(int index) { if (index == 0) { Print("MarketSeries=" + MarketSeries.Close.LastValue + "; M1 MarketData= " + M1.Close.Last(0)); } } } }
How can I use fixed data to test indicator?
Thanks in advance.
Replies
ceakuk
23 Apr 2018, 14:15
RE: RE:
I'm trying to modify parameters to my indicator(not this)
my indicator creates custome renko chart with dynamic pip size. however everytime i check on the renko it is very different everytime because of changing data. if i change my parameters i can not know how they affect the renko chart because the data also changes. thanks
@ceakuk
PanagiotisCharalampous
23 Apr 2018, 14:42
Hi ceakuk,
Currently there is no way to get a fixed range of market data. We plan to add this as an option of the MarkerSeries.GetData() function in a future release of cTrader. If you could share your indicator so that I can reproduce your problem then I might be able to suggest a different approach.
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
23 Apr 2018, 15:15
Hi ceakuk,
Yes, I believe this is possible. You could create another indicator that reads values from csv data and use it as an imput to your current indicator.
Best Regards,
Panagiotis
@PanagiotisCharalampous
ceakuk
23 Apr 2018, 16:48
RE:
Thanks a lot even though I have no idea how to import data.
the only question I have is this
public override void Calculate(int index) { }
Usually index belong to every tick in Market series I guess. if i import data, should i do a for loop every time i have index=0,1 2... or just once at if(index==0)
or will the index now change to reflect the length of my new csv data. Thanks
@ceakuk
ceakuk
23 Apr 2018, 18:50
RE:
Dear Panagiotis,
Unfortunately what you propose does not exist. These is no way to import data to calgo indicator. I see no link to that anywhere. thanks
Panagiotis Charalampous said:
Hi ceakuk,
Yes, I believe this is possible. You could create another indicator that reads values from csv data and use it as an imput to your current indicator.
Best Regards,
Panagiotis
@ceakuk
PanagiotisCharalampous
24 Apr 2018, 09:14
Hi ceakuk,
The fact that there is no link does not mean that this is not possible. Practically, you could read the data on the Initialize() function, store them in memory and then assign them to the appropriate Result index in the Calculate() function. However this requires some coding to be achieved. You could always use some professional help if you don't know how to do it and if you would like this to be implemented.
Best Regards,
Panagiotis
@PanagiotisCharalampous
ceakuk
24 Apr 2018, 13:41
RE:
Thanks a lot. However I got a way around it. In case someone else has the same problem, here is how I do it.
Sice for example hourly H2 data is longer than say H1 or Minutes30 etc
I switch to higher time frame like H2 and do this
if (index == 0) Print("tak=" + MarketSeries.OpenTime.Last(0) + " " + MarketSeries.OpenTime.Last(0).Ticks);
now that I have time "tik" in Ticks as the bigining I switch to my desired lower time eg H1.
I decide how long I want it say 50 days
long tak = MarketSeries.OpenTime.Last(0) that i got earlier in above code; long tik = tak + (number of days * 864000000000L);//1 day=864000000000L ticks if(MarketSeries.OpenTime.Last(0) >= tak && MarketSeries.OpenTime.Last(0<=tik ) { //ALL YOUR CALCULATE LOGIC GOES HERE //IF PRINT START & PRINT END ARE SHOWN IN LOG THEN YOUR DATA IS WITHIN THE BOUNDARIES if (MarketSeries.OpenTime.Last(0) == tak) { //begining Print("start=" + MarketSeries.OpenTime.Last(0)); } if (MarketSeries.OpenTime.Last(0).Ticks == tiktak) { Print("end=" + MarketSeries.OpenTime.Last(0); } }
@ceakuk
PanagiotisCharalampous
23 Apr 2018, 12:46
Hi ceakuk,
Could you please explain to me what is the purpose if the following condition?
What are you trying to achieve?
Best Regards,
Panagiotis
@PanagiotisCharalampous