Add text on Divergence indicator
Forums › ProRealTime English forum › ProBuilder support › Add text on Divergence indicator
- This topic has 13 replies, 2 voices, and was last updated 3 years ago by robertogozzi.
Tagged: divergences
-
-
03/14/2019 at 2:25 PM #93635
Good day,
I found this indicator in the library. Will it be possible to add a text e.g “Buy” or “Sell” just above or below the divergence lines?
Regards,
Segie
Divergence on price12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455///////////////////////////////////////////////////////////// MACD divergences on price//by Jose Callao// twitter @jose7674// attach this indicator to the chartN=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators//using any other indicator is as easy as changing the valuesmiMACD = exponentialAverage[12](close) - exponentialAverage[26](close)IF (BarIndex > 10+1+N) THEN//we look for bearish divergencesIF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THENextremum2=miMACD[1]extremum1=highest[N](miMACD)preciomax2=close[1]preciomax=Highest[N](close)IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THENfor i=1 to Nif close[i]=preciomax[1] thenzz=idrawsegment (barindex[1], close[1], barindex[zz], close[zz]) coloured(200,0,0)endifnextendifendif//we look for bullish divergencesIF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THENextremum22=miMACD[1]extremum11=lowest[N](miMACD)preciomin2=close[1]preciomin=lowest[N](close)IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THENfor i2=1 to Nif close[i2]=preciomin[1] thenzz2=i2drawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)endifnextendifendifendifreturn//////////////////////////////////////////////03/14/2019 at 3:03 PM #93639Hi segie
see code with text and arrows
Macd Divergence123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960///////////////////////////////////////////////////////////// MACD divergences on price//by Jose Callao// twitter @jose7674// attach this indicator to the chartN=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators//using any other indicator is as easy as changing the valuesmiMACD = exponentialAverage[12](close) - exponentialAverage[26](close)ATR = Averagetruerange[100](close)//AddedIF (BarIndex > 10+1+N) THEN//we look for bearish divergencesIF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THENextremum2=miMACD[1]extremum1=highest[N](miMACD)preciomax2=close[1]preciomax=Highest[N](close)IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THENfor i=1 to Nif close[i]=preciomax[1] thenzz=idrawtext("SELL",barindex[1],high[1]+ATR,Dialog,Bold,10)coloured(255,0,0)//Addeddrawarrowdown(barindex[1], high[1])coloured(255,0,0)//Addeddrawsegment (barindex[1], close[1], barindex[zz], close[zz]) coloured(255,0,0)endifnextendifendif//we look for bullish divergencesIF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THENextremum22=miMACD[1]extremum11=lowest[N](miMACD)preciomin2=close[1]preciomin=lowest[N](close)IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THENfor i2=1 to Nif close[i2]=preciomin[1] thenzz2=i2drawtext("BUY",barindex[1],low[1]-ATR,Dialog,Bold,10)coloured(0,200,0)//Addeddrawarrowup(barindex[1], low[1])coloured(0,200,0)//Addeddrawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)endifnextendifendifendifreturn//////////////////////////////////////////////1 user thanked author for this post.
03/14/2019 at 3:11 PM #93640There you go:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556///////////////////////////////////////////////////////////// MACD divergences on price//by Jose Callao// twitter @jose7674// attach this indicator to the chartN=40///N is the number of bars to look back for a divergence. Normal values are 20-40. Must be the same in both indicators//using any other indicator is as easy as changing the valuesmiMACD = exponentialAverage[12](close) - exponentialAverage[26](close)IF (BarIndex > 10+1+N) THEN//we look for bearish divergencesIF (miMACD[1]>miMACD AND miMACD[1]>miMACD[2]) THENextremum2=miMACD[1]extremum1=highest[N](miMACD)preciomax2=close[1]preciomax=Highest[N](close)IF(extremum2<extremum1 AND preciomax2>preciomax[1]) THENfor i=1 to Nif close[i]=preciomax[1] thenzz=idrawsegment (barindex[1], close[1], barindex[zz], close[zz]) coloured(200,0,0)offset = high[1] + (high[1] / 100)drawtext("Sell",barindex[1],Offset) coloured(255,0,0,255)endifnextendifendif//we look for bullish divergencesIF (miMACD[1]<miMACD AND miMACD[1]<miMACD[2]) THENextremum22=miMACD[1]extremum11=lowest[N](miMACD)preciomin2=close[1]preciomin=lowest[N](close)IF(extremum22>extremum11 AND preciomin2<preciomin[1]) THENfor i2=1 to Nif close[i2]=preciomin[1] thenzz2=i2drawsegment(barindex[1], close[1], barindex[zz2], close[zz2]) coloured(0,200,0)offset = low[1] - (low[1] / 100)drawtext("buy",barindex[1],Offset) coloured(0,128,0,255)endifnextendifendifendifreturn1 user thanked author for this post.
03/15/2019 at 8:29 AM #9373806/29/2021 at 5:38 AM #172693Hello Nicolas, Jose, Segie & Roberto,
When the above indicator triggers, it lags by a few points. This is normal and correct with all MACD type indicators.
Now assume I have it displayed on Chart and instead of having Drawsegment, I have Drawarrowup and Drawarrowdown instead. My question is:
If I want to (on purpose) make it false trigger i.e. trigger the up and down arrows on Barindex[1] prematurely by say 10 index points before actual bullish and bearish conditions are triggered, how would I do that please?
Many tnx in advance
06/29/2021 at 8:35 AM #172699There’s no way to foretell if a signal will be returned next bar.
You can only wait for the signal and when it shows you can plot something on the prior bar. It’s a ZigZag-like behavior called REPAINTING.
06/29/2021 at 8:46 AM #172701Tnx Roberto. I am not sure if I explained myself properly.
I want the signal to appear prematurely (i.e. prior prior and in advance of what it was going to appear).
Let’s say the signal will appear when a condition is met (let’s say when current bar price is or reaches 7000). What I want is the signal to appear as the price approaches or near 7000 (say 7000 – x points, for example 6990)
with the MACD indicator that JOSE has written, once the conditions that trigger the signals are understood, then we can alter those conditions to trigger on approach not on attainment. I am fully aware that this would defeat the purpose of the divergence/convergence but still that’s what I want to achieve and test. It would be like a prewarning of trouble ahead 🙂
Hope this has clarified what I am trying to achieve.
06/29/2021 at 8:56 AM #172702Yes, you had explained yourself clearly.
If 7000 is lagging, you can replace it with 6990. Then 6990 will be lagging.
Anyway, were it a fixed price, say 7000, you could easily wait when it is 6990, though not exactly, but with CLOSE how can you tell it’s now 10 points less than it will be next bar?
06/29/2021 at 9:02 AM #172703Mate I used Close as just a plain example. The actual conditions for the signal trigger are those in the MACD on MACD indicator that is coded by JOSE and posted here in the forum. Have a look at this indicator and see if you can grasp the conditions that trigger the signal. if you can then see if there is a way to trigger the signal on approach of condition (i.e. pre-mature trigger) rather than on attainment of condition.
06/29/2021 at 10:19 AM #172705Indicators are even worse than price, if the current price is 6990, on the rise, you may guess the next bar is approx. 7000, but how can you foretell next bar MACD will be 0 if now it’s -3?
If you mean something like this:1IF (miMACD[1]>(miMACD-2) AND miMACD[1]>miMACD[2]) THENassuming next miMACD will be the current value + 2, it won’t work most of the times.
07/01/2021 at 3:59 AM #172855tnx Roberto.
The below attached file returns value of an indicator I have written on top or bottom of candle (green if positive and red if negative). The value is live and dynamic i.e. it changes up and down for the duration of the timeframe. At the end of time frame, the value freezes and becomes historic, green if positive by end of time frame and red if negative by end of time frame). So far so easy and straightforward.
My question is:
How can I display the rate the value is changing per minute? is that possible with an array or some other simpler code?
07/01/2021 at 7:06 AM #172856The file is missing.
07/01/2021 at 7:34 AM #172858It was a picture. I here attach it again
07/01/2021 at 8:58 AM #172864It’s the same answer I posted here https://www.prorealcode.com/topic/creating-timer-to-capture-indicator-values-at-intervals/.
You can display values every 15 minutes on a 1-minute TF, not the other way round.
-
AuthorPosts
Find exclusive trading pro-tools on