screening a strategy on each stock of us 500

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #66438 quote
    Francesco78
    Participant
    Master

    Hi, I was wondering if there is any way to screen a strategy on every single shares of the SP 500.

    Just to be clear. I want to see if a mean reverting strategy that works well on the SP 500 could be applied to a basket of stocks instead than to the whole index. It would be interesting to see if there is a particular basket that contribute to the “mean revertingness” of SP 500 and isolate it.

    Many thanks

    Francesco

    #66439 quote
    Nicolas
    Keymaster
    Master

    We could simulate profit generated by a strategy of each individual stock of a shares list.. but it would be tricky, depends of the strategy itself! and it would only be possible on the last 254 bars (history limitation of ProScreener).

    If you could expose the strategy (or the probacktest code), I could lend an hand 🙂

    #66444 quote
    Francesco78
    Participant
    Master

    Thank you Nicolas,

    the strategies I had in mind are the one that we published on the SP 500

    S&P 500 daily RSI(2) long short strategy

    and

    S&P 500 mean reverting strategy

    Let me know if you think you can work something out of them and if I can do anything to help

    Thank you!

    #66462 quote
    Nicolas
    Keymaster
    Master

    Quick example of the first one converted into a screener:

    a = 5
    b = 20
    
    cl = RSI[2]<a
    cs = RSI[2]>100-a
    
    if cl then
    long=1
    short=0
    entrylong=close
    endif
    
    if cs then
    long=0
    short=1
    entryshort=close
    endif
    
    if long and RSI[2]>100-(a+b) and close < open then
    long=0
    gain=(close-entrylong)+gain
    //sell at market
    endif
    
    if short and RSI[2]<(a+b) then
    short=0
    gain=(entryshort-close)+gain
    //exitshort at market
    endif
    
    screener[gain](gain)

    Your a and b variables are optimized in ProBacktest, so I took dummy values for them. The gain is in points, not in money, depends of shares quantity you bought for each stock of course ..

    Francesco78 thanked this post
    #66463 quote
    Nicolas
    Keymaster
    Master

    Wait a minute, I think I made something wrong..

    Francesco78 thanked this post
    #66464 quote
    Nicolas
    Keymaster
    Master

    Hmmm, please review my code, I think it should be good now 🙂

    a = 5
    b = 20
    
    cl = RSI[2]<a
    cs = RSI[2]>100-a
    
    if cl and long=0 then
    long=1
    short=0
    entrylong=close
    endif
    
    if cs and short=0 then
    long=0
    short=1
    entryshort=close
    endif
    
    if long and RSI[2]>100-(a+b) and close < open then
    long=0
    gain=(close-entrylong)+gain
    //sell at market
    endif
    
    if short and RSI[2]<(a+b) then
    short=0
    gain=(entryshort-close)+gain
    //exitshort at market
    endif
    
    screener[gain](gain)
    #66465 quote
    Francesco78
    Participant
    Master

    Thank you Nicolas, the code is fine but I am not very confident with screeners. Let me understand, if I select “daily” screening the resultsa  are computed on the last 2 years right?

    #66471 quote
    Nicolas
    Keymaster
    Master

    Yes, beginning 254 bars ago from now.

    Francesco78 thanked this post
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

screening a strategy on each stock of us 500


ProScreener: Market Scanners & Detection

New Reply
Author
Summary

This topic contains 7 replies,
has 2 voices, and was last updated by Nicolas
7 years, 11 months ago.

Topic Details
Forum: ProScreener: Market Scanners & Detection
Language: English
Started: 03/26/2018
Status: Active
Attachments: No files
Logo Logo
Loading...