How to identify the closest pivot points level to current price

Forums ProRealTime English forum ProOrder support How to identify the closest pivot points level to current price

This topic contains 23 replies, has 5 voices, and was last updated by avatar GraHal 6 months, 2 weeks ago.

View all attachments
Viewing 15 posts - 1 through 15 (of 24 total)
  • #90989

    Good Day PRC Community

    I have a question which I hope some of the other experienced coders (@Nicolas @vonasi @robertogozzi) here can help me with:

    Let’s say I have identified 10 major levels of support and resistance (some above and some below the current price).

    Note: Each major level has its own variable name assigned to it.

    Question:

    How do I determine the level (variable name) directly above the current closing price as well as directly below?

    #90990

    Since arrays are not supported, you’ll have to use IF…ELSIF… ENDIF to test each time all the 10 variables.

    Thers’s no shorter workaround.

    #90991

    Thinking of solutions as I type this:

    First thought is to find all levels (variables) larger than the current close and then use the min of those

    Then find all the levels (variables) lower than the current close and then use the max of those

    Now to find a practical way to code it

    #90992

    Nested if statements won’t cut it as there are actually 21 levels which will have to be measured against close as well as themselves. Meaning we are looking at hundreds of outcomes. Will have to use a combination of If statements and loops in applying my last mentioned logic.

    #90994

    Coding this without arrays is going to tricky but I want to believe there is a way without writing a 21×21=441 condition nested if statement

    #90996

    My brain is breaking over this, every solution keep going back to needing arrays

    #90997

    No workarounds, sorry.

    We must wait till end of March to discover any new feature in version 11, but I guess arrays are not going to be supported, yet.

    #90998

    First thought is to find all levels (variables) larger than the current close and then use the min of those Then find all the levels (variables) lower than the current close and then use the max of those Now to find a practical way to code it

    You answered your own question!

    So you have 10 support/resistance levels recorded as a1 to a10 that could be anywhere compared to price.

    Here is an example using just three levels that can be easily expanded to 10 levels.

    Written after quite a few glasses of red wine and a beer so might be complete cobblers and usually there is a more efficient way to do it than my first idea!

     

     

     

    #91000

    My above code assumes that every time you find a new support or resistance level then one is dropped and the new one is added like this:

     

    #91006

    Thanks Vonasi, you seem to code just fine with your wine. Probably due to the Ballmer Peak 😉 (https://xkcd.com/323/)

    I have added the code, plotting all Monthly, Weekly and Daily Pivot Levels.

    But for some reason the result is wacky, The ‘Pivot Above’ in reality is actually the Pivot Directly Below? And the ‘Pivot Below’ is just the lowest pivot??

     

    #91007

    I’ve only just glanced at the code but can see straight away that line 231 is wrong. They should all be MIN and not MAX as we are looking for the smallest distance  below price and not the biggest.

    #91008

    @nicolas @vonasi I suspect my above-mentioned problem is possibly due to the way MTF updates values? If you graph close in relation to ‘Pivot Above’ and ‘Pivot Below’ you can clearly see there is a problem. Either that or the nested Max statement is failing.

    #91009

    Also I notice that when you store the values of ABOVE and BELOW you store the actual price whereas in my code I stored the difference between price and the level.

    #91010

    Sorry – only one cup of tea so far so not thinking straight! I can see that you have written your code differently to mine. I have to go out now but will try to look at it more closely when I get back.

    #91012

    Since the pivot level was still a value I didn’t think it a problem to just use the straight level instead of the difference between the close and price. But will change it and see

Viewing 15 posts - 1 through 15 (of 24 total)

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