Page 1 of 1

Download security history for strategy

PostPosted: Thu Sep 09, 2021 3:13 am
by Questing
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

Re: Download security history for strategy

PostPosted: Fri Sep 10, 2021 3:39 am
by Apprentice
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.

Re: Download security history for strategy

PostPosted: Fri Sep 10, 2021 6:36 am
by Questing
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.

Re: Download security history for strategy

PostPosted: Mon Sep 13, 2021 11:22 am
by Apprentice
You can use ExtSubscribe1 instead of ExtSubscribe

Re: Download security history for strategy

PostPosted: Sun Sep 19, 2021 7:26 am
by Questing
Thanks heaps Apprentice!

Re: Download security history for strategy

PostPosted: Tue Sep 21, 2021 4:51 am
by Questing
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?

Re: Download security history for strategy

PostPosted: Wed Sep 22, 2021 4:23 am
by Apprentice
Your request is added to the development list.
Development reference 859.

Re: Download security history for strategy

PostPosted: Wed Sep 22, 2021 2:19 pm
by Apprentice
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)

Re: Download security history for strategy

PostPosted: Sun Oct 03, 2021 5:57 am
by Questing
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.