ExtSubscribe1() Question

Moderator: admin

ExtSubscribe1() Question

Postby imxuf92 » Tue Sep 13, 2016 6:50 pm

For a strategy I'm building, I need to access the historical data as calculated by the ExtSubscribe1 method. For example, if I pre-load and calc a 1000 period mva with the following code:

Code: Select all
   Source = ExtSubscribe1(1, "EUR/USD", "m5", 1100, true, "bar");
   ind_mva1000 = core.indicators:create("MVA", source.close, 1000);


How then can I access certain historical data calculations from specific past periods?

This code below fails because size() returns 0.
Code: Select all
     -- Get data here... 
     -- This fails because ind_mva1000.DATA:size() == 0
     core.host:trace("Value from 500 periods ago: " .. ind_mva1000.DATA[ind_mva1000.DATA:size() - 500]);


Is there a way to do this?
imxuf92
 
Posts: 26
Joined: Sat Jan 23, 2016 6:55 pm

Re: ExtSubscribe1() Question

Postby Apprentice » Thu Sep 15, 2016 4:57 am

Can you provide a complete code.

Try this line
ind_mva1000 = core.indicators:create("MVA", Source.close, 1000);
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: ExtSubscribe1() Question

Postby imxuf92 » Tue Sep 20, 2016 11:28 am

I believe I figured it out.

I was trying to obtain the history I needed within the ExtAsyncOperationFinished() method as soon as the data load was complete.

Instead, I needed to set a "needs history" flag and obtain the history when ticks arrive within the Update() method after the data has been loaded.
imxuf92
 
Posts: 26
Joined: Sat Jan 23, 2016 6:55 pm


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 8 guests