Nicolas

Sweet Spots - round numbers

Category: Indicators By: Nicolas Created: December 4, 2017, 11:15 AM
December 4, 2017, 11:15 AM
Indicators
14 Comments
Sweet Spots - round numbers

The SweetSpots indicator plots automatically lines on round price rates, not only double zeros, it includes any round numbers calculated with 2 different settings in parameters:

  • MainLevels (define major levels, define this setting in points/pips, it will automatically adapt the calculation for the current security/instrument)
  • SubLevels (define sub levels, same setting as MainLevels one)

The ‘NumLinesAboveBelow’ setting will determine how much levels will be plotted on the chart (default is 100 lines above and below the current Close).

//PRC_SweetSpots round number | indicator
//04.12.2017
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge

// --- settings 
// NumLinesAboveBelow = 100
// MainLevels = 100
// SubLevels = 20
// --- end of settings 

defparam drawonlastbaronly=true

DecAr = MainLevels*pointsize
DecArSub = SubLevels*pointsize

myVarUp = close
myVarDn = close
myVarUpSub = close
myVarDnSub = close

if DecAr = 0 then
 InvDec = 1
else
 InvDec = 1/DecAr
endif
if DecArSub = 0 then
 InvDecSub = 1
else
 InvDecSub = 1/DecArSub
endif

for i = 0 to NumLinesAboveBelow do 

 Floor = round(InvDec*myVarDn-0.51)/InvDec
 Ceil = round(InvDec*myVarUp+0.51)/InvDec

 FloorSub = round(InvDecSub*myVarDnSub-0.51)/InvDecSub
 CeilSub = round(InvDecSub*myVarUpSub+0.51)/InvDecSub

 r=255
 g=215
 floorval=floorsub
 ceilval=ceilsub

 drawhline(floorval) coloured(r,g,0)
 drawhline(ceilval) coloured(r,g,0)
 drawrectangle(1,floor,barindex,floor) coloured(r,0,0)
 drawrectangle(1,ceil,barindex,ceil) coloured(r,0,0)

 myVarUp=Ceil
 myVarDn=Floor
 myVarUpSub=CeilSub
 myVarDnSub=FloorSub

next

return

 

Download
Filename: PRC_SweetSpots-round-number.itf
Downloads: 511
Nicolas
Nicolas Legend
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Gianluca
3 years ago
#

Is it possible to have an indicator where those value are as instogram ? and separated? in order to obtain them for a strategy?

s00071609
6 years ago
#

I am using this indicator but it keep crashing as i change the timeframe. For example, changing from 1 Min to 5 minute. Each time I change timeframe, I need to reload this indicator. The error gives "calculation error". I load only 5 lines, yet this keeps crashing. What could be the issue? thanks

Nicolas
6 years ago
#

in the mean time you can try this one: https://www.prorealcode.com/prorealtime-indicators/horisontal-grid-for-00-values/

robbo192
6 years ago
#

Have you any indicators that might help you trade off round numbers. I look for the break and bounce off round numbers.

robbo192
6 years ago
#

It's ok this indicator is perfect. You have saved me lots of time with this indicator. It would be better if the sub lines where a light grey.

robbo192
6 years ago
#

Nicolas, How do you change the colour of the lines? or would you change the code for a fee. I am looking for dark blue rather than the yellow. This is really important to me as I trade off Round numbers. Thanks Rob.

Nicolas
6 years ago
#

change the lines with: r=0 g=0 and lines with coloured like this: coloured(r,g,255)

BobFlynn
7 years ago
#

Hello @Nicolas Thank you very much for this code ! It's very useful to me. I was wondering how I could use in ProOrder. I manage to simply call it, but how can I use the different levels to raise conditions ? Let me know if I shall open a new topic for this. Thanks,

Nicolas
7 years ago
#

Lines are just graphical and are not returned by the indicator. To use it in automated trading, it would be adapted somehow. Please open a new topic for this specific question.

financier
8 years ago
#

Hi, Nicholas I find your sweetspot indicator very handy for identifying key areas in a range of markets, and I would like to incorporate what I think are important levels into my own programmes. Is it possible to reference these lines either in this or a similar programme by attributing variable names to them directly ? Thank you very much for your help and time.

Nicolas
8 years ago
#

Sure,you can. Just add different variables in the loop and test them at each iteration if they have a value or not. Dont forget to reset them to zero before the loop.

Bullan
9 years ago
#

Hi Nicolas, thanks a lot for posting this, very useful. A quick question, I havent much experience with coding but was wondering how I could go about changing the colour of the lines as well as the thickness of the lines? Also, is it possible to put a label on the lines? Thanks Andrew

Nicolas
9 years ago
#

Not possible to change the thickness. You can add text with DRAWTEXT instruction, you'll find many examples in the library.

Bullan
9 years ago
#

One other quick thing, I notice that the lines flicker on and off when price trades close to either side of the level - is there any way of turning this feature off? Cheers

ProRealCode ProRealCode
Loading...