Download security history for strategy

Moderator: admin

Download security history for strategy

Postby Questing » Thu Sep 09, 2021 3:13 am

Hi Support,

I have noticed that when I run a strategy in TS say with sma period 20, the strategy waits until 20 live candels have been collected before it starts to process the strategy. this is usuall doen throught the use of the "first" counter in the code.

I need to know how to call history candles, in this case the last 20 candles into the strategy so that the strategy does not need to wait for the first twenty live candles to elapse before the strategy can starts analysing the market for me.

Kind Regards,

Tendai
Questing
 
Posts: 5
Joined: Thu Aug 29, 2019 9:26 am

Re: Download security history for strategy

Postby Apprentice » Fri Sep 10, 2021 3:39 am

While this is possible.
Can you define an example of how and why you need this?

The first check ensures that enough candles are loaded for the example indicator calculation.
For example, to calculate 10-period moving average we need 10 candles.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Download security history for strategy

Postby Questing » Fri Sep 10, 2021 6:36 am

What is the maximum number of history candles say M, that are loaded into memory when any new strategy is started in TS?

When I am using period N moving average in the strategy, where N > M. I have noticed that on running the strategy, it will not load the last N canles of data into memeory and start processing the strategy going forward with the sliding window of candles in the analysis. It only loads the last M candles and since N > M the strategy starts supplimenting with new candles that get completed going forwards untill it has N candles in memory. Thus it cannot complete an analysis of the market until it has supplimented the M candles it got from loading history data with X new candels that were completed since the start of the strategy to make the N candles it needs to make the assessment.

That is N = M + X, so the strategy will not complete any assessment for the next X candles as it collects newly completed X candles to suppliment the M candles it loaded from history.

I would like to be able to specify in the strategy how many history candles to load into memory, so that the strategy has a full complement of the sliding window candles it needs to make the market assesmement from the momemt I start the strategy.
Questing
 
Posts: 5
Joined: Thu Aug 29, 2019 9:26 am

Re: Download security history for strategy

Postby Apprentice » Mon Sep 13, 2021 11:22 am

You can use ExtSubscribe1 instead of ExtSubscribe
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Download security history for strategy

Postby Questing » Sun Sep 19, 2021 7:26 am

Thanks heaps Apprentice!
Questing
 
Posts: 5
Joined: Thu Aug 29, 2019 9:26 am

Re: Download security history for strategy

Postby Questing » Tue Sep 21, 2021 4:51 am

Hi Apprentice,

I may have spoken too soon. It appears like I am getting the same result with ExtSubscriber1.

I changed to ExtSubscriber1 with a count of 400 while using a 377 moving average period in the strategy. After starting the strategy it did not trigger on the first three signals that took place after the following period times from start of strategy;

1: At 80 periods
2: At 120 periods
3: At 152 periods

All signals at or after 168 periods from start of strategy were correctly triggered and no misssed signals were recorded after that point in the strategy.

It appears that the strategy may have kept between 194 to 209 periods in memory and then started collecting new candles until it had built up the 377 required to process the strategy logic. This requirement would have been met somewhere from the 152 to 168 periods after start of the strategy.

Is there a way of finding out the actual number of periods of data kept for the strategy at any given time?
Questing
 
Posts: 5
Joined: Thu Aug 29, 2019 9:26 am

Re: Download security history for strategy

Postby Apprentice » Wed Sep 22, 2021 4:23 am

Your request is added to the development list.
Development reference 859.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Download security history for strategy

Postby Apprentice » Wed Sep 22, 2021 2:19 pm

Some ma's could require more data. EMA, for example, requires +50% of bars compared to period. (EMA300 requires 450 bars). If you have MA over MA then their periods adds up. (EMA300 over EMA300 requires 900 bars)
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Download security history for strategy

Postby Questing » Sun Oct 03, 2021 5:57 am

Hi Apprentice,

Thanks heaps! Doubling and tripling the number of history bars solved the missed signals problem. The strategies are not missing any signals now.

Kind Regards,

Questing.
Questing
 
Posts: 5
Joined: Thu Aug 29, 2019 9:26 am


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 13 guests