Hello,
I’m trying to create an algorithm based on the divergences.
I tried to call divergence indicators (RSI or MACD) found on the site but it doesn’t work, I think the error comes from my code.
For example I tried to call the indicator “DivergenceRSIWithLookback”, and to indicate as conditions to buy if the indicator is > to 0 and the close is > to the highest of the previous candle, or to short if the indicator is < to 0 and the close is < to the lowest of the previous candle, But this does not give any trade. I removed the conditions close >high [1] and close
I removed the variables from the indicator to integrate them directly into the code but it still didn’t work. It still doesn’t work.
Can someone help me solve this problem? 🙂
DEFPARAM Cumulateorders = False
DEFPARAM FLATAFTER = 214400
DEFPARAM FLATBEFORE = 000100
// Conditions pour ouvrir une position acheteuse
indicator1 = Call "DivergenceRSIWithLookback"
c1 = (indicator1 > 0)
//c2 = close> high[1]
IF c1 AND Not OnMarket THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
// Conditions pour ouvrir une position vendeuse
indicator2 = Call "DivergenceRSIWithLookback"
c3 = (indicator1 < 0)
//c4 = close < low[1]
IF c3 AND Not OnMarket THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF
SET STOP$LOSS 500
SET TARGET$PROFIT 500
PS : Sorry for the readability. I did use the add code function in the initial message, then when I modified it when I noticed the bug but the code continued to be displayed with the text. 🙂
Are you sure the indicator is sending signals? Did you try to GRAPH indicator1, for example?
Hello @Nicolas,
Yes the indicator returns signals as you can see in the screenshot.
I also tried with the indicator “DivergenceRSIopensource” and the result is the same.
I also tried with the other indicators you shared on this page: https://www.prorealcode.com/topic/rsi-divergence/#post-23530 but there are still no trades triggered, whatever the asset or time unit.
Can you help me to program a divergence algorithm? 🙂
You are not GRAPH the indicator in the strategy, I only see the indicators values from ProBuilder on your charts. Please provide the ITF file of your strategy so I can use the same exact indicator as you.
Hello Nicolas,
Here are the 2 indicators and the strategy in itf.
Thank you for your help.
Hello @Nicolas,
Indicators and strategy in itf can be found in the previous message.
Thank you for your help.
You have wrongly called an indicator that don’t exist? The signals were not present? In any case, test your variables with GRAPH, it is the first step to debug a code that is malfunctioning.
PFA the itf file in order to get the complete code working (with indicator embedded).
Below is one error.
Maybe Nicolas fixed this in the .itf above … I’ll try Nicolas file.
// Conditions pour ouvrir une position vendeuse
indicator2 = Call "DivergenceRSIWithLookback"
c3 = (indicator1 < 0)
needs to be
// Conditions pour ouvrir une position vendeuse
indicator2 = Call "DivergenceRSIWithLookback"
c3 = (indicator2 < 0) //Indicator2 not indicator 1
Nicolas code works fine … see attached
ZigoParticipant
Master
Evening,
I am working on a set up for this topic. What I have already is coupling of the signals on a target-price (TP).
In the attachment is every line a TP after a signal. Green lines for long trading, yellow lines for short trading.
ZigoParticipant
Master
Last signal on 144 sec frame
I know my eyes aren’t great, but I feel like I’ve had 10 pints when looking at the attachment 2 posts above … it’s all fuzzy with text superimposed on top of other text … is it just me!? 🙂
is it just me!? 🙂
It looks perfectly focused if you view it through the bottom of your second bottle of wine. Don’t ask me how I know.
ZigoParticipant
Master
Maybe this looks better, if you have to much C2H5OH in your head.
Its the same instrument only 100 times lesser candles. To morrow it clearing out.