MTF on stochastic

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #232768 quote
    Bogren
    Participant
    New

    Hi,

     

    Need some help.

     

    Let´s say i want to create a Multi timeframe strategy on two different timeframes with stochastic indicator or some other one like RSI, doesn´t matter which one.

     

    Is the best way to create the indicator and include it in the strategy code or is it better/easier to use

    the CALL instruction instead to “call” for the indicator?

     

    If want a strategy like the one explained above on stochastic as an example on 1h and 15min so i better understand how things like this is coded in it´s simplest way.

     

    And then use easy rules like this.

     

    Long trades

    1.Higher timeframe (1h) is bullish, stochastic (fast line is above slow) and not overbought (above80).

    2. 15min timeframe, stochastic fast line crosses over slow line and is below oversold (below20) is when to buy.

    Reverse for short ones.

    If someone could code this I should be more then happy.

    Thanks in advance!

    #232824 quote
    Iván González
    Moderator
    Master

    Hi!

    Here you have an example of long trades.

     

    overbougth=80
    oversold=20
    timeframe(1h,updateonclose)
    stok1h=Stochastic[14,3](close)
    stod1h=Stochasticd[14,3,5](close)
    setupLong1h=stok1h>stod1h and stok1h<overbougth
    setupShort1h=stok1h<stod1h and stok1h>oversold
    
    timeframe(15mn)
    stok15mn=Stochastic[14,3](close)
    stod15mn=Stochasticd[14,3,5](close)
    setupLong15mn=stok15mn crosses over stod15mn and stok15mn<oversold
    setupShort15mn=stok15mn crosses under stod15mn and stok15mn>overbougth
    
    if not onmarket and setupLong1h and setupLong15mn then
    buy 1 contract at market
    set stop %loss 5
    set target %profit 5
    endif
    Bogren thanked this post
    #233834 quote
    Bogren
    Participant
    New

    Thank you @Iván !

    This make sens to me and works nice.

    When i try the same approach but with an not predifined indicator like the DTOSC for example, coded by @doctrading in the indicator library. It will not read the overbought/oversold conditions correctly for me.

    Here is a good example of what i was wondering before if it is easiest to code it as a separate indicator and then use the “call” command or to put the code for the indicator directly in the strategy code?

    https://www.prorealcode.com/prorealtime-indicators/dtosc-dynamic-trader-oscillator/

    #234810 quote
    Bogren
    Participant
    New

    Anyone?

    I attached the code for the indicator.

    type = 2
    
    if type = 1 then
     a = 8
     b = 5
     c = 3
     d = 3
    endif
    
    if type = 2 then
     a = 13
     b = 8
     c = 5
     d = 5
    endif
    
    if type = 3 then
     a = 21
     b = 13
     c = 8
     d = 8
    endif
    
    if type = 4 then
     a = 34
     b = 21
     c = 13
     d = 13
    endif
    
    storsi = 100 * ((rsi[a] - lowest[b](rsi[a])) / ((highest[b](rsi[a])) - lowest[b](rsi[a])))
    
    dtosck = average[c](storsi)
    dtoscd = average[d](dtosck)
    
    Seuilhaut = 75
    Seuilbas = 25
    
    RETURN dtosck AS "DTOSCK" , dtoscd AS "DTOSCD" , Seuilhaut , Seuilbas
    #234812 quote
    Iván González
    Moderator
    Master

    Here you have an example:

    overbougth=75
    oversold=25
    type = 2
    
    if type = 1 then
    a = 8
    b = 5
    c = 3
    d = 3
    elsif type = 2 then
    a = 13
    b = 8
    c = 5
    d = 5
    elsif type = 3 then
    a = 21
    b = 13
    c = 8
    d = 8
    elsif type = 4 then
    a = 34
    b = 21
    c = 13
    d = 13
    endif
    
    timeframe(1h,updateonclose)
    storsi1h = 100 * ((rsi[a] - lowest[b](rsi[a])) / ((highest[b](rsi[a])) - lowest[b](rsi[a])))
    stok1h = average[c](storsi1h)
    stod1h = average[d](stok1h)
    setupLong1h=stok1h>stod1h and stok1h<overbougth
    setupShort1h=stok1h<stod1h and stok1h>oversold
    
    timeframe(15mn)
    storsi15mn = 100 * ((rsi[a] - lowest[b](rsi[a])) / ((highest[b](rsi[a])) - lowest[b](rsi[a])))
    stok15mn=average[c](storsi15mn)
    stod15mn=average[d](stok15mn)
    setupLong15mn=stok15mn crosses over stod15mn and stok15mn<oversold
    setupShort15mn=stok15mn crosses under stod15mn and stok15mn>overbougth
    
    if not onmarket and setupLong1h and setupLong15mn then
    buy 1 contract at market
    set stop %loss 5
    set target %profit 5
    endif
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

MTF on stochastic


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Bogren @bogren Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Iván González
1 year, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/17/2024
Status: Active
Attachments: No files
Logo Logo
Loading...