Sweet Spots - round numbers

Category: Indicators By: Nicolas Created: December 4, 2017, 11:15 AM
December 4, 2017, 11:15 AM
Indicators
14 Comments

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: 492
Nicolas Master
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

Logo Logo
Loading...