Popular Rule Based Model

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #68202 quote
    odin
    Participant
    Veteran

    Dear Forum Members,
    Dear Nicolas,

    a lot of institutional banking firms work with “rule bases investments”. the most popular in our bank is
    the 200sma/38sma rule based strategy with a 3 % filter for noise.

    i wanna have this code for my own to use ist in pro realtime.
    i wanna code this in weekly form, because i check the markets on weekends.

    description:

    if the 8 week sma is over the upper band it is a long signal until the
    the 8 week sma is under the lower band
    a new long signal is formed when the 8 week sma is over the upper band again.

    my problem:
    i cannot code the description until ….
    please can you do this for me – in my indicator not i have no very time a histogramm
    and the value is 0. that´s false – the logic is green or red and not 0.
    do you understand what i mean.
    please recode my code – that its correct 🙂

    thank you so much 🙂

    here is my code:

     

    // orginial 200 day sma
    c1 = average[40](close)
    // the 3 % up band
    c2 = c1*1.03
    // the 3 % low band
    c3 = c1*0.97
    // the original 38 day sma
    c4 = average[8](close)
    
    //histogramm building
    // result1 is green
    // result2 is red
    
    if c4 > c2 then
    result1 = 1
    else
    result1 = 0
    endif
    
    if c4 < c3 then
    result2 = 1
    else
    result = 0
    endif
    
    return result1, result2, 0
    #68204 quote
    odin
    Participant
    Veteran

    i hope you can help me, because i have no secrets.

    afterwards i have the code, i wanna tell yoau

     

    1.  strategy for long term investments

    2. use ist for position trades…

    #68215 quote
    TempusFugit
    Participant
    Veteran

    Is this it?

    // orginial 200 day sma
    c1 = average[40](close)
    // the 3 % up band
    c2 = c1*1.03
    // the 3 % low band
    c3 = c1*0.97
    // the original 38 day sma
    c4 = average[8](close)
    
    
    if c4 > c2 then
    result = 1
    elsif c4 < c3 then
    result = -1
    endif
    
    return result, 0
    Nicolas thanked this post
    #68222 quote
    Nicolas
    Keymaster
    Master

    Thanks Tempusfugit. I think you have solved Odin’s problem. I noticed that the moving average is a simple one while it’s an exponential one plotted on the chart.

    So the strategy is as easy than looking for upper/ lower bands crossing with the 8 period MA?

    #68233 quote
    odin
    Participant
    Veteran

    Good morning! Ist ist really so easy ?? Wow i wanna Test ist is Home . So little Code and it Work.

    I thougt i have to use the function once or until.

    At Nicolas sorry you are tight i have plotted an ema on chart

    #68234 quote
    odin
    Participant
    Veteran

    So an easy Long Term system is

    Buy 100 % when indicator value is one

    And sell If the value is minus 1

    No short Trades its only for long only Stock bias.

    Ist should Work Well on sp500, nasdaq100 , stoxx600 and other really Big etfs Indexes to crate lazy wealth.

    How should the Code Designed

    A) Invest 100 %

    B) invest 10.000 USD fix Dollar amount

    Thx for Help

    #68235 quote
    odin
    Participant
    Veteran

    This model ist popular used in insurances to Work long Term with costumer Money and should avoid massive bear time losses.

    #68236 quote
    odin
    Participant
    Veteran

    Next step you can use it as Trend Filter for your own Swing Trading ideas

    Later i Post my Idea 🙂

    #68249 quote
    Nicolas
    Keymaster
    Master

    Sweet Bull Market, where are you now? 😆

    So is that 200/38 or 40/8 SMA periods?

    #68258 quote
    odin
    Participant
    Veteran

    Its 200 and 38 Sma on daily and 40 and 8 on week

    I prefer week for lower noise

    #68291 quote
    odin
    Participant
    Veteran

    here you see, the rule bases modul is really powerful, for example for german tec dax etf.

    now optimization and stop loss is required.

    The Indicator of TempusFugit works well….

     

    // Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    indicator1, ignored = CALL "rule based modul"
    c1 = (indicator1 = 1)
    
    IF c1 THEN
    BUY 10000 CASH AT MARKET
    ENDIF
    
    // Bedingungen zum Ausstieg von Long-Positionen
    indicator2, ignored = CALL "rule based modul"
    c2 = (indicator2 = -1)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF

    can you code this, that the trading system

    everytime buys 100 % of all avaiable cash .. and reinvest 100 % .

    thank you for help

    #68295 quote
    odin
    Participant
    Veteran

    and it is only long only.. because in short periods it brings no more performance.

    is should only avoid big bear markets.

    #68298 quote
    GraHal
    Participant
    Master

    and it is only long only

    How come you show short trades in the Chart above?
    I take it your Chart is not the result of your code  … which does not show anY sellshorts?

    Seems a shame to not take advantage of the downs as well as the up periods??

    #68299 quote
    odin
    Participant
    Veteran

    you can use short trades… in bear phase i switch into high yield bonds etfs…

    you can use it also as trend filter:

    here it is a 2rsi trend model, every time buy when rsi2 is under 10

    and sell on 10 % profit stop or wen rule based model would go short.

     

    // Festlegen der Code-Parameter// Festlegen der Code-Parameter
    DEFPARAM CumulateOrders = False // Kumulieren von Positionen deaktiviert
    
    // Bedingungen zum Einstieg in Long-Positionen
    indicator1, ignored = CALL "rule based modul"
    c1 = (indicator1 = 1)
    indicator2 = RSI[2](close)
    c2 = (indicator2 < 10)
    
    IF c1 AND c2 THEN
    BUY 10000 CASH AT MARKET
    ENDIF
    
    // Bedingungen zum Ausstieg von Long-Positionen
    indicator3, ignored = CALL "rule based modul"
    c3 = (indicator3 = -1)
    
    IF c3 THEN
    SELL AT MARKET
    ENDIF
    
    // Stops und Targets
    SET TARGET %PROFIT 10
    
    #68302 quote
    odin
    Participant
    Veteran
    IF c1 THEN
    BUY 10000 CASH AT MARKET
    ENDIF

    how sould the code like be, if i wanna

    buy 100 % of my capital on every trade.

    please help me.

    thanks

Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.

Popular Rule Based Model


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
odin @odin Participant
Summary

This topic contains 19 replies,
has 6 voices, and was last updated by ANDY
7 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/12/2018
Status: Active
Attachments: 4 files
Logo Logo
Loading...