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).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
//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 |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
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
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
Not possible to change the thickness. You can add text with DRAWTEXT instruction, you’ll find many examples in the library.
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.
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.
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,
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.
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.
change the lines with:
r=0
g=0
and lines with coloured like this: coloured(r,g,255)
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.
Have you any indicators that might help you trade off round numbers. I look for the break and bounce off round numbers.
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
in the mean time you can try this one: https://www.prorealcode.com/prorealtime-indicators/horisontal-grid-for-00-values/
Is it possible to have an indicator where those value are as instogram ? and separated? in order to obtain them for a strategy?