Remember the value at a crossing
Forums › ProRealTime English forum › ProBuilder support › Remember the value at a crossing
- This topic has 4 replies, 2 voices, and was last updated 12 months ago by Vogeltje.
-
-
11/28/2023 at 7:15 PM #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 = aaENDIF
// 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 = aaENDIF
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!
11/28/2023 at 7:32 PM #224531Hi, 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:
12345678910111213141516171819202122232425lijnK= stochastic[14,3](close) // to maybe change with your stochastic own parametersc1 = lijnK CROSSES OVER 60// Condition to buyIF c1 THENaa = closeBUY 1 SHARES AT MARKETENDIFc2 = lijnK CROSSES UNDER aa// Condition to close long positionIF c2 THENSELL AT MARKETENDIF11/29/2023 at 12:21 PM #224560Thanks 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 buyIF c1 THENaa = average[3](oscillator)BUY 1 SHARES AT MARKETENDIFc2 = lijnK CROSSES UNDER aa// Condition to close long positionIF c2 THENSELL AT MARKETENDIF11/29/2023 at 12:49 PM #224561Hi, 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.
11/29/2023 at 1:01 PM #224563 -
AuthorPosts
Find exclusive trading pro-tools on