Divergence Strategy works intermittent

Questions about MultiCharts and user contributed studies.
moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

Divergence Strategy works intermittent

Postby moreno » 07 Oct 2020

Hi friends
I have written A divergence strategy long entries
but somehow it doesn't catch all the setups.
using Renko/regular/kase bars.

my thoughts (with no answer right now) for the problem:
does Renko/kase bar charts work for strategies different from regular charts?
Is coding the problem?
what is the frequency the code runs again and again on each chart/time frame? maybe that's the problem?

the code is below you may try it yourself. the trigger function here is RSI Divergence with index
change each iteration to check if the divergence profile consolidated.

Code: Select all

inputs: Price( Close ), Length( 14 ), OverSold( 30 ) ; variables: varRSI( 0 ),idx(0) ; varRSI = RSI( Price, Length ) ; idx = idx+1; if varRSI[1] < varRSI and varRSI[1] < varRSI[2] and //current low varRSI[idx+2] < varRSI[idx+1] and varRSI[idx+2] < varRSI[idx+3] and //first low varRSI[idx+2] < varRSI[1] and varRSI[idx+2] < overSold and //first low < current low - indicator up Close[idx+2] > Close[1] and Close > Close[1] then //price decending buy ("Divergence LE") this bar at Close; if idx=20 then idx=1; //check up to 20 iterations erlier
What are your thoughts? where is the problem?

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Divergence Strategy works intermittent

Postby TJ » 07 Oct 2020

From experience, Renko strategies never worked in a consistent behavior. It is just the nature of the non-time based beast.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Divergence Strategy works intermittent

Postby JoshM » 08 Oct 2020

my thoughts (with no answer right now) for the problem:
does Renko/kase bar charts work for strategies different from regular charts?
The wiki has a page with the backtesting differences between the different resolution types.
somehow it doesn't catch all the setups.
(...)
Is coding the problem?
It looks like your code uses a lookback period that varies per bar (with the `idx` variable). Doesn't the code need to lookback the same number of bars on each bar? That way you get a static 'lookback window' in which to look for divergences.

Your code to me seems to look back 1 bar back on bar number #100, then on bar #101 it looks back 2 bars, on #103 3 bars, and so on. But this way not every bar is scanned, the way I understand your code.

moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

Re: Divergence Strategy works intermittent

Postby moreno » 08 Oct 2020

somehow it doesn't catch all the setups.
(...)
Is coding the problem?
It looks like your code uses a lookback period that varies per bar (with the `idx` variable). Doesn't the code need to lookback the same number of bars on each bar? That way you get a static 'lookback window' in which to look for divergences.

Your code to me seems to look back 1 bar back on bar number #100, then on bar #101 it looks back 2 bars, on #103 3 bars, and so on. But this way not every bar is scanned, the way I understand your code.

JoshM thank you for clarifying the code anomaly!
I'm going to fix that...will be glad if friends will share their ideas.


Return to “MultiCharts”