round number
Forums › ProRealTime English forum › ProOrder support › round number
- This topic has 10 replies, 4 voices, and was last updated 3 years ago by Paul.
-
-
05/23/2020 at 4:42 PM #132962
I there any code available to find the round number example for dax 11100 11200 etc
similarly for dow 24400 , 24500
code should give nearest round number the idea is to place 2 pips above round number 24400 buy and place stop loss 23990 etc
05/23/2020 at 5:57 PM #13296805/23/2020 at 5:59 PM #132969It took all of three seconds using the search box and typing in ’round numbers’ to find this:
https://www.prorealcode.com/prorealtime-indicators/sweet-spots-numbers/
You should try the search box some time as it is quite useful! 🙂
05/25/2020 at 9:23 AM #13313105/25/2020 at 10:14 AM #133136I’m not sure exactly what you are asking for. With MainLevels = 100 and SubLevels = 100 it draws lines at 100 intervals. I did spot a couple of little errors in the code. The FOR NEXT loop should start from 1 and not from zero and the addition or subtraction of 0.51 should be 0.5.
Here is a version of that code that simply returns the nearest round number above price and below price.
1234567891011121314151617MainLevels = 100DecAr = MainLevels*pointsizemyVarUp = closemyVarDn = closeif DecAr = 0 thenInvDec = 1elseInvDec = 1/DecArendifFloor = round(InvDec*myVarDn-0.5)/InvDecCeil = round(InvDec*myVarUp+0.5)/InvDecreturn floor, ceil05/25/2020 at 10:27 AM #133143To always round a number (using ROUND) to the lowest positive integer -0.5 needs to be subtracted, while always rounding to the highest positive integer +0.4 needs to be added.
05/25/2020 at 10:48 AM #133147I’m not sure that is correct Roberto. I tested it with this little code:
12345678910111213141516MainLevels = 100DecAr = MainLevels*pointsizemyVarUp = closeif DecAr = 0 thenInvDec = 1elseInvDec = 1/DecArendifCeil = round(InvDec*myVarUp+0.4)/InvDecmyround = round(InvDec*myVarUp+0.5)/InvDecreturn ceil as "+0.4 ceil", myround as "+0.5 ceil", close as "close"When using +0.4 sometimes it rounds it down rather than up.
05/25/2020 at 11:18 AM #133159because it rounds the first decimal position, to round the second one it should be 0.04 (or 0.05), 0.004 (or 0.005) for the third decimal position, etc…
05/25/2020 at 4:27 PM #133195Yes but in this indicator we always want to be a number above so if the current price is 1.0 then rounding with +0.4 will return 1.0 whereas we need it to be 2.0 To get 2.0 we have to add on 0.5
In a normal rounding situation you are correct as 1.0 should return 1 when rounded but not if we want to always find the next whole number above the current value.
05/25/2020 at 4:29 PM #13319805/25/2020 at 4:57 PM #133204Maybe it has some parts of interest
https://www.prorealcode.com/prorealtime-trading-strategies/big-line-strategy/
-
AuthorPosts
Find exclusive trading pro-tools on