Coding a Moving Average crossover
Forums › ProRealTime English forum › ProScreener support › Coding a Moving Average crossover
- This topic has 6 replies, 3 voices, and was last updated 7 years ago by GraHal.
-
-
11/19/2016 at 9:38 AM #16796
Hi all,
I usually have no problems with this type of code as you can basically select the criteria with ProScreener.
However, this one is not bringing up anything at all! (even if I select it to look at all markets). I’m basically looking to find markets where the 21 day EMA has crossed over the 400SMA within the last 100 days/periods on a daily chart.
123456indicator1 = ExponentialAverage[21](close)indicator2 = Average[400](close)c1 = summation [100] (indicator1 CROSSES OVER indicator2)SCREENER[c1] ((close/DClose(1)-1)*100 AS "%Chg yest.")Any help would be great.
Also a random question – ProScreener shows the top 50 results. Is there a way to view the next 50?
Many thanks, David.
11/19/2016 at 1:02 PM #1680211/19/2016 at 4:34 PM #16806Mmm my message above screwed again … what am I doing wrong!
I got your code working, but not above MA [250] … must be to do with the ‘preload bars’ … but I cant see a preload bars command to increaser to 400.
There were 7 hits using
Average[250](close)and Cross Over on a Daily TF.
11/19/2016 at 4:38 PM #1680911/20/2016 at 1:43 AM #16817Hi,
Thanks for your help again. Yes it’s strange that it will allow the code to work with a 250SMA but not a 400SMA!
Using a 250SMA however would help me spot markets that are heading towards the 400SMA anyway so that may be more ideal. :o)
Can I ask what you mean by preload bars?
Thanks, David.
11/20/2016 at 11:22 AM #16827You can’t get results which are oldest than 256 periods. So if you want to test a crossover of a SMA200 that occured 60 periods ago, it is not possible because a 200 periods SMA needs of course 200 periods to compute correctly and it’s getting worse with EMA for instance. This is a limitation of the Proscreener module ..
11/20/2016 at 2:47 PM #16844Preload bars are the numbers of bars that are pre loaded at the beginning of a backtest or for a screener.
A 250 MA needs 250 bars in order to compute the Moving Average so as Nicolas says (this is his site btw :)) the limit is 256 bars … hence why the MA not give any hits above MA 256? (I didnt try 256, only 250).
On Backtest you can select the Command ‘Preload Bars’ and enter what you wish (up to a limit). The default PreLoad on Backtest is 200 Bars.
-
AuthorPosts
Find exclusive trading pro-tools on