How to load historic data of moving averages?

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

How to load historic data of moving averages?

Postby oggy59133 » Tue Jan 26, 2016 3:52 pm

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!!
oggy59133
 
Posts: 5
Joined: Tue Jan 26, 2016 3:42 pm

Re: How to load historic data of moving averages?

Postby Julia CJ » Wed Jan 27, 2016 3:37 am

Hi Oggy59133,

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

Re: How to load historic data of moving averages?

Postby oggy59133 » Wed Jan 27, 2016 2:46 pm

Hi Julia!!
Thanks a lot for your answer!!!
i was lost with this problem!!!
oggy59133
 
Posts: 5
Joined: Tue Jan 26, 2016 3:42 pm

Re: How to load historic data of moving averages?

Postby oggy59133 » Thu Jan 28, 2016 4:40 pm

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!!
oggy59133
 
Posts: 5
Joined: Tue Jan 26, 2016 3:42 pm

Re: How to load historic data of moving averages?

Postby Julia CJ » Fri Jan 29, 2016 7:31 am

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.
Attachments
test.zip
(561 Bytes) Downloaded 1034 times
Julia CJ
 

Re: How to load historic data of moving averages?

Postby oggy59133 » Fri Jan 29, 2016 5:09 pm

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!!
oggy59133
 
Posts: 5
Joined: Tue Jan 26, 2016 3:42 pm

Re: How to load historic data of moving averages?

Postby Julia CJ » Tue Feb 02, 2016 3:59 am

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.
Julia CJ
 

Re: How to load historic data of moving averages?

Postby imxuf92 » Fri Sep 09, 2016 11:49 am

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?
imxuf92
 
Posts: 26
Joined: Sat Jan 23, 2016 6:55 pm

Re: How to load historic data of moving averages?

Postby Julia CJ » Thu Sep 15, 2016 12:21 am

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.
Julia CJ
 


Return to Discussions

Who is online

Users browsing this forum: No registered users and 8 guests