Page 1 of 1

How to load historic data of moving averages?

PostPosted: Tue Jan 26, 2016 3:52 pm
by oggy59133
Hi
I have developed a strategy witch works great on back tests.
On live, i have a problem: i use a EMA1000 moving average, and can't wait 1000 periods before all data needed is loaded...
Has someone the solution to load immediatly the historic of this moving average?
(sorry for my poor english: i am french...)
thanks a lot for your responses!!

Re: How to load historic data of moving averages?

PostPosted: Wed Jan 27, 2016 3:37 am
by Julia CJ
Hi Oggy59133,

The strategy should use function ExtSubscribe1 instead of ExtSubscribe for loading data. The number of loaded bars is specified in ExtSubscribe1.

Re: How to load historic data of moving averages?

PostPosted: Wed Jan 27, 2016 2:46 pm
by oggy59133
Hi Julia!!
Thanks a lot for your answer!!!
i was lost with this problem!!!

Re: How to load historic data of moving averages?

PostPosted: Thu Jan 28, 2016 4:40 pm
by oggy59133
Hi Julia
It seems i enjoyed too fast... It doesn't work :shock:
I am trying to load 5000 bars. (in m5 time frame)
I am obliged to wait 7 days to have data in my MVA1000 moving average!

Here how i did:

function Prepare():
Source = ExtSubscribe1(2, "FRA40", instance.parameters.TF, 5000, true, "bar");

ind_mva1000 = core.indicators:create("MVA", Source.close,1000);
mva1000data = ind_mva1000.DATA;
...
function ExtUpdate(id, source, period)
ind_mva1000:update(core.UpdateLast);
ExtSignal(source, period, "test "..mva1000data[period] , SoundFile, Email, RecurrentSound);
...

after execution, the ExtSignal instruction shows data only after 7 days...

Can you tell me what to do to have data immédiatly, please?

thank you for your help!!

Re: How to load historic data of moving averages?

PostPosted: Fri Jan 29, 2016 7:31 am
by Julia CJ
Hi Oggy59133,

We have not managed to reproduce the issue. I have attached the example (the test.lua file),everything should work correctly. Please let me know whether the issue persists or not.

Re: How to load historic data of moving averages?

PostPosted: Fri Jan 29, 2016 5:09 pm
by oggy59133
Hi Julia
I am sorry: it doesn't work
i have backtested the test.lua strategy you gave, and have seen that the data of my MVA1000 moving average is not loaded immediatly.

The test has began on 10/12/2014, and the data hasn't been loaded before 18/12/2014.
Here what we can see in the evenement tab of the strategy backtester:

Symbole Date/Temps Bid Ask Evenements Capital Solde final
FRA40 18/12/2014 02:25:00 4 177,00 4 178,00 Alerte sur FRA40 au 4 177,00 : Signal: test 0
FRA40 18/12/2014 02:30:00 4 175,00 4 176,00 Alerte sur FRA40 au 4 175,00 : Signal: test 0
FRA40 18/12/2014 02:35:00 4 177,00 4 178,00 Alerte sur FRA40 au 4 177,00 : Signal: test 0
FRA40 18/12/2014 02:40:00 4 189,00 4 191,00 Alerte sur FRA40 au 4 189,00 : Signal: test 0
FRA40 18/12/2014 02:45:00 4 192,00 4 193,00 Alerte sur FRA40 au 4 192,00 : Signal: test 0
FRA40 18/12/2014 02:50:00 4 181,00 4 183,00 Alerte sur FRA40 au 4 181,00 : Signal: test 0
FRA40 18/12/2014 02:55:00 4 185,00 4 187,00 Alerte sur FRA40 au 4 185,00 : Signal: test 4136.028
FRA40 18/12/2014 03:00:00 4 184,00 4 185,00 Alerte sur FRA40 au 4 184,00 : Signal: test 4135.916
FRA40 18/12/2014 03:05:00 4 174,00 4 175,00 Alerte sur FRA40 au 4 174,00 : Signal: test 4135.794
FRA40 18/12/2014 03:10:00 4 179,00 4 180,00 Alerte sur FRA40 au 4 179,00 : Signal: test 4135.678



thank you for your help!!

Re: How to load historic data of moving averages?

PostPosted: Tue Feb 02, 2016 3:59 am
by Julia CJ
Hi Oggy59133,

The strategy should not load data for periods preceding the range you specified in Wizard (in this case it is 10/12/2014). You need to change the date backtesting should start from to an earlier one. Please let me know if you have any questions.

Re: How to load historic data of moving averages?

PostPosted: Fri Sep 09, 2016 11:49 am
by imxuf92
This logic worked perfectly for me.

However, how can I obtain values from one of the historical periods? If I wanted to retrieve the EMA value from 500 periods ago, I can't because the data stream size of the indictor is zero.

Modifying the posted sample slightly, this is basically what I need to do:

Code: Select all
function ExtAsyncOperationFinished(cookie, success, message)

    core.host:trace(tostring(cookie) .. " " .. tostring(success) .. " " .. tostring(message));

   -- Get data here... (THIS FAILS)
   --core.host:trace("Value from 500 periods ago: " .. mva1000data[mva1000data:size() - 500]);
   
        -- HOW CAN THE ABOVE BE DONE?    mva1000data:size() == 0
end


How can this be done?

Re: How to load historic data of moving averages?

PostPosted: Thu Sep 15, 2016 12:21 am
by Julia CJ
Hi Imxuf92,

Please do the following:
ind_mva1000 = core.indicators:create("MVA", Source.close,1000+500);
As a result core.host:trace("Value from 500 periods ago: " .. mva1000data[mva1000data:size() - 500]); will work. Just in case you need to check the size, because these data may be not for all instrumets/periods.