The “Stock Simple Code”

The “Stock Simple Code”

Hello everyone,

I just had the idea to write a little code, which makes you enjoy the rising shares.

We take only long positions, on stocks in bullish phase (defined relative to the moving average 200 periods).

The formula includes reinvestment of earnings.

Without reinvestment, it is necessary to use :

We must optimize the variables « mm » and « cc », but generally we have good results with mm = 3 and cc = 4.

Screenshot : code tested for example on « Pernod Ricard », over the last 20 years.

The code is profitable on the vast majority of the shares, because it only takes positions in the uptrend.

This code is a light version of my personal code, the « CODE BOURSE PEA ».

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. Nicolas • 04/21/2016 #

    Thanks again for sharing Doc.
    Beware of optimization, it introduces survivor bias that is incompatible with automated trading. Over fitting past behaviour of  a strategy, is like rewrite history by yourself 🙂
    I wrote a short blog article on this: http://www.prorealcode.com/blog/avoid-equity-curve-fitting-with-probacktest-trading-strategy-optimisation/
    Delete equity over-fit introduced by parameters in strategies is the major and hard part of automatic trading research. Code long only strategies that buy instruments that perform since thirty years, is the easy one 🙂

  2. Doctrading • 04/21/2016 #

    Ok  😉

  3. zilliq • 04/21/2016 #

    I think the “best”  method to backtest is  to do a simplier Walk forward backtest (and we hope we will have a full Walk forward backtest in the next version 10.4.) :
    Optimize the parameters in the 2/3 of the duration of the backtest and test them on the Last 1/3
    For example test on the 2 first months and test them on the Last month for a duration of 3 month 
    It’s not ideal but better than Optimize on all duration because the past is the past 
    Have a nice day (From bali,  in holidays 🙂 ) 

  4. volpiemanuele • 04/21/2016 #

    Hi,
    I have modified and optimized the strategy on FTSE 100 CASH Eur 1 on IG demo account. Below the code modified and optimized. I have a result of 50% positive trade with a gain, starting from january 2016, of 670 euro with Time Frame of 5 minute. Can you aid me to develop the strategy in order to improve the result on the same market or EURUSD mini (I use IG). Thanks
    /-------------------------------------------------------------------------
    // Codice principale : STOCK SIMPLE CODE_fts100
    //-------------------------------------------------------------------------
    // STOCK SIMPLE CODE
    // www.doctrading.fr

    DEFPARAM CUMULATEORDERS = FALSE
    DEFPARAM FlatBefore = 090000
    DEFPARAM FlatAfter = 170000

    //capital = 10000 + strategyprofit
    //n = capital / close

    // DEFINITION DE LA TENDANCE
    MMlongue = average[246](close)
    MMmoyenne = average[64](close)
    MMcourte = average[19](close)

    // Optimiser les variables mm et cc de 1 à 10

    // ACHAT
    c1a = close > MMlongue and MMlongue > MMlongue[1]
    c2a = MMcourte crosses over MMmoyenne

    IF c1a and c2a THEN
    BUY 1 shares AT MARKET
    ENDIF

    // SORTIE ACHAT
    c1v = MMcourte crosses under MMmoyenne

    IF c1v THEN
    SELL AT MARKET
    ENDIF

    // ACHAT
    c1a = close < MMlongue and MMlongue < MMlongue[1]
    c2a = MMcourte crosses under MMmoyenne

    IF c1a and c2a THEN
    SellShort 1 shares AT MARKET
    ENDIF

    // SORTIE ACHAT
    c1v = MMcourte crosses over MMmoyenne

    IF c1v THEN
    ExitShort AT MARKET
    ENDIF

     
     
     
    The new code 
     
     

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
emism12 Looks great, personally I don't use automated trading for single stocks, but is definitely o...
adconsulting Ciao, I look that the strategy (backtest 50 k), works very good wiht US 500 CASH 1 EURO in...
Kev Monaghan The equity curve looks to follow the stock price almost perfectly, Have you tested on stock ...
smarttrader1 hi, can you improve on this ? can you make this flag screeener for day trading, I want to be...
Nicolas Please open a new topic in the proscreener forum for this specific query. Please provide exp...
NHGambler Nice screener. Only thing is I wonder if this is aimed more at small/medium/large caps? I ...
mickey992 salut merci pour ton partage et ton travaille
patapouf Hi Vivien René I just discovered your “Ordered trend-following stocks Screener”. Great work...
RobertFX Works fine
Kees Pols great tool! Thank you
tush1822 appreciate your post mate!! it helped me.
fredfilm Hi Nicolas, how could we add a price screen to this? eg stock prices between $1 to $3 etc
Vonasi Forum discussion on these indicators can be found here: https://www.prorealcode.com/topic/av...
jennr29 Hi. Is it possible to convert this code to an mq4 file?
Nicolas Sorry but our website is dedicated to prorealtime programming. However, you can ask for priv...
avatar
Anonymous Hi Odin, Thanks for this screener based on the popular criteria to trade trends from Marc...
Gianluca thank you very nice screener
bertrandpinoy BONJOUR PAUL impossible de tenter le trading automatique, PRT me dis que l instruction "GRAP...
Paul Bonjour, supprimez les lignes avec un "graph"
bertrandpinoy merci. vous l utiliser actuellment sur quel instrument vous? et quel timeframe? Merci
GraHal Yes sorry, I set up a link to a screen shot on my google drive and then I got locked into th...
gabri Here's the thread https://www.prorealcode.com/topic/multiframe-rsi-of-rsi/
Bernard13 Bonjour Nicolas, Pourriez-vous m'indiquer si cet indicateur fonctionne avec la V11 ? Le di...
Nicolas Thanks for contributing to the "ichimoku section" of the prorealtime code library Don't he...
sourberry Thank you , this is a great indicator works beautifully. Could you kindly modify to scr...
pp_playaflamenca Excuse me,... reading your code about spanB: [ SenkouSpanBFutureW = (Highest[SenkouSpanPerio...
Julio Hi Doctrading, Is it possible to flip this to a "going bearish" by simply switching the cod...
Doctrading Hello, Yes, you can do it very simply...
Tarek Laaroussi Hi doctrading i am the one who sent you the email first thanks for the code . It really wo...

Top