Remember the value at a crossing

Forums ProRealTime English forum ProBuilder support Remember the value at a crossing

Viewing 5 posts - 1 through 5 (of 5 total)
  • #224530

    Hello,

    i think my question is simple but I can not get a working answer myself. I want to build a simple system on 5 minutes timeframe that buys when Stochastics (lijnK) crosses over the value 60.  So for example at 14.05 lijnK has value 48.77 en at 14.10 lijnK has value 72.33 so a crossing of the value 60 has occured, the system will go long at 14.15

    Now I want my system to “remember” the value 72.33 from time 14.10. As soon as lijnK crosses under this 72.33 the trade must be closed again. Seems simple.

    I have tried:

    c1 = lijnK CROSSES OVER 60

    c2 = lijnK CROSSES UNDER aa

     

    // Condition to buy

    IF c1 THEN

    BUY 1 SHARES AT MARKET
    lijnK = aa

    ENDIF

     

    // Condition to close longposition

    IF c2 THEN

    SELL AT MARKET

    ENDIF

    So I have stated that lijnK = aa. This is not working, it seems aa is considered to be a variable that I must define for optimising the backtest. I do not want optimalisation, and defining aa as varying from 1 to 100 (with 0.1) does also not help.
    I have also tried several words instead of aa, for example lijnK = lijnKatcrospos but now lijnKatcrospos is also considered to be a variable…

     

    Detail: when i use

    // Condition to buy

    IF c1 THEN

    BUY 1 SHARES AT MARKET
    lijnK = aa

    ENDIF

    the system buys at 14.15   In fact, I do not want the system to remember the value of lijnK at 14.15 but at 14.10….  but I think writing lijnK[1] = aa would be wrong, the systems looks at the crossing of “lijnK”.

    Thanks!

    #224531

    Hi, assuming you have a line not shown defining your stochastic, like lijnK= stochastic[14,3](close) for example, but maybe with different settings, you can try with:

     

     

    #224560

    Thanks JC that is a very soon answer..

    Yes i used the standard stochastic as given by ProRealTime, but it is in Dutch:

    // Stochastic 14,3,5

    plusHoog = highest[14](high)

    plusLaag = lowest[14](low)

    oscillator = (close – plusLaag) / (plusHoog – plusLaag) * 100

    lijnK = average[3](oscillator)

    lijnD = average[5](lijnK)

     

    In my case lijnD is not used, we are talking about lijnK. This lijnK oscillates between 0 and 100.

    The standard stochastic does not use the term close. It works with lijnK and lijnK[1] and so on….

    The answer you give contains close and I think that will lead to confusion since close refers to price.

    But your answer made me thinking. Maybe I should write:

    c1 = lijnK CROSSES OVER 60
    // Condition to buy
    IF c1 THEN
      aa = average[3](oscillator)
      BUY 1 SHARES AT MARKET
    ENDIF
    c2 = lijnK CROSSES UNDER aa
    // Condition to close long position
    IF c2 THEN
      SELL AT MARKET
    ENDIF
    #224561

    Hi, you’re absolutly right, big mistake I made in line 8, memorising the value of lijnk at crossing in line 8 should have been aa=lijnk, not aa=close, what it does is memorising into aa the value lijnk has at close of the candle during which lijnk crossed 60.

    And also, yes you could also use the average[3](oscillator) you have, it would work too to memorise its value into aa when c1 true.

     

    #224563

    Thanks JC! I will try this. It is actually very funny! At start I wrote lijnK = aa  and that was wrong…. It is just the other way around… I will try later today…

Viewing 5 posts - 1 through 5 (of 5 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login