Tweaking divergence code

Forums ProRealTime English forum ProOrder support Tweaking divergence code

Viewing 14 posts - 1 through 14 (of 14 total)
  • #180943

    Hello everybody… I wonder if you could help me?

    I have some divergence code that looks back a certain number of bars which seems to work okay when I’m comparing a current low that is lower than a previous low, but doesn’t work so well when a current low is higher than a previous low.

    My graph command tells me that ‘priorlow’ is 13,801.3 which is nearly a hundred bars back from the current low (the lows are labelled on screengrab), and yet the code only permits a lookback of 30 bars.

    I’m wondering if this also has something to do with a market that is constantly rising, but that is just a guess.

    Does anyone know how to solve this?

    Thank you in advance.

     

    #180947

    I did not test it, but it seems you are referencing BACK, while you should reference HALF (if I got what you meant to achieve):

    #180953

    Thanks for your suggestion, Roberto. It changes things slightly, but doesn’t solve the problem. Priorlow now refers to a bar which is 90 back from the current low, which is not the intention of the code.

    I notice that when I reduced the lookback to 28 it found a much more recent low on May14 (where the leftmost blue arrow is on the original screengrab). I hope this helps.

    #180959

    Add this indicator to your chart  (see attached screenshot):

    This is the code for the strategy (I could just test it for syntax errors only):

    2 users thanked author for this post.
    #180985

    Thank you Roberto! 🙂

    On first look, the code looks like it is working properly. I will do a longer check tomorrow.

    #181019

    Hey Roberto,

    The code looks great, but I can’t get the indicator to work. When I add it, it simply creates a blank box under the chart with a scale on the right-hand side…. no arrows appear on the chart. Are there other settings I need to tweak in order to get it to appear on the chart?

    #181028

    Add it ON your chart, not UNDER.

    You have to click the PRICE tag on the top left corner of your chart, then select ADD INDICATOR and choose from the list.

     

    #181061

    Ah okay, thanks – I’ve added it to the right place now.

    Currently I only see the indicator arrows at the most recent bar range. Is it possible to make the indicator return them multiple times going back months or years?

    I’m sorry if these are very basic questions, but I’ve never programmed an indicator before. I’ve had a look in the manual and tried a few things but I can’t get them to work. It’d be great if I could see all the instances of new curlows and new priorlows.

    Thanks.

    #181070

    You can use this version, but the output is not so tidy:

    1 user thanked author for this post.
    #181075

    Oh wow! This is brilliant!!

    I’ve adapted it so it only shows arrows when my price-action entry criteria is met, so now the chart doesn’t look so crowded. This is going to save me a lot of time when I cross-check the validity of my divergence parameters (I think they are entering a bit too often using lows that are not significant enough).

    Thank you so much Roberto 🙂

    #181128

    I hope this is the final thing on this, Roberto 🙂

    I’ve decided to use the PSAR as a way of improving the accuracy of priorlow. I want priorlow to be less than the PSAR in order to allow for an entry but I can’t do it with the code “priorlow < SAR[0.02,0.02,0.2][back]” “priorlow < SAR[0.02,0.02,0.2]”. I assume this is because the priorlow is derived from a lowest bar in a range (which could be bar 26 or whatever) rather than simply the absolute value of the 30th bar back.

    How would I do this?

    Thank you again.

    (I’ve attached a screengrab which graphs “priorlow < SAR[0.02,0.02,0.2][back]” with a black arrow denoting the priorlow bar)

     

    #181143

    The SAR repainted, be careful for an intraday condition

     

    #181204

    What is “and low[i]” for, in line 18?

     

    #181325

    Hey Roberto,

    That’s actually there in error, but it doesn’t make any difference. I’ve deleted it since. I worked out that using [i] was what I needed to do in order to measure the priorlow bar against something else, and I think that I’ve got it working okay…. I hope! 🙂

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

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