Using Both Text and Lines
Forums › ProRealTime English forum › ProBuilder support › Using Both Text and Lines
- This topic has 16 replies, 2 voices, and was last updated 2 years ago by robertogozzi.
-
-
06/22/2018 at 4:20 PM #74104
Good Day
I am building an on chart indicator that contains both text as well as lines.
But it seems that the only way to return text is using the Return command with no further elements. (i.e. Return *nothing else*)
For Example:
1234567891011MA = Average[20](close)Rge = averagetruerange[10](close)If low – high[1] > 0.0001 THENDRAWTEXT(“GAP”, barindex, High+Rge/0.2,SansSerif,Italic,10)coloured(0,0,255,255)DRAWARROWUP(barindex, lOW-Rge)coloured(0,0,255,255)EndIfReturn MA as “MA”//doesn’t return the text or the arrow, only the MASo the question is how do I return both the MA as well as the Text/Arrow?
06/22/2018 at 6:25 PM #74113To write code, please use the <> “insert PRT code” button, to make code easier to read. Thank you.
06/22/2018 at 6:30 PM #74116I tried it on DAX daily and it works fine, printint text, arrows and ma.
06/22/2018 at 6:51 PM #74121Interesting, here is the full code set showing no text or arrows;
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179Defparam calculateonlastbars = 800//Variables://Periods = 21//Deviations = 1.618//RSITopThreshold = 95//RSIBottomThreshold = 5//RSIPeriod = 2//ADXPeriod = 14//ADXVal = 20//MAPeriod = 20// ELSASTIC WEIGHTED MOVING AVERAGEPRICE = LOG(customclose)alpha = 2/(PERIODS+1)// EWMA (EMA)if barindex < PERIODS thenEWMA = AVERAGE[3](PRICE)elseEWMA = alpha * PRICE + (1-alpha)*EWMAendif// ELASTIC WEIGHTED STANDARD DEVIATION (ESD)error = PRICE - EWMAdev = SQUARE(error)if barindex < PERIODS+1 thenvar = develsevar = alpha * dev + (1-alpha) * varendifESD = SQRT(var)//ZeroLag Data//lag = ROUND((period-1)/2)//data = (close + (close-close[lag]))//ZLEMA = exponentialaverage[period](data)//BolUp = ZLEMA+STD[period]*dev//BolDn = ZLEMA-STD[period]*dev// BANDSUB = EXP(EWMA + (DEVIATIONS*ESD))BB = EXP(EWMA - (DEVIATIONS*ESD))MID = EXP(EWMA)RSI2 = RSI[RSIPeriod](close)BollR = UB-BBBRSI = BB + (BollR*(RSI2*0.01))BRSIT = BB + (BollR*(RSITopThreshold*0.01))BRSIB = BB + (BollR*(RSIBottomThreshold*0.01))//Dev Scaled MAif barindex < MAPeriod thenDSMA = AVERAGE[3](PRICE)ElsIf barindex > MAPeriod Then//Smooth with a Super Smoothera1 = exp(-1.414*3.14159 / (.5*MAPeriod))b1 = 2*a1*Cos(1.414*180 / (.5*MAPeriod))c2 = b1c3 = -a1*a1c1 = 1 - c2 - c3//Produce Nominal zero mean with zeros in the transfer response//at DC and Nyquist with no spectral distortion//Nominally whitens the spectrum because of 6 dB per octave//rolloffZeros = Close - Close[2]//SuperSmoother FilterFilt = c1*(Zeros + Zeros[1]) / 2 + c2*Filt[1] + c3*Filt[2]//Compute Standard DeviationRMS = 0For count = 0 to MAPeriod - 1 doRMS = RMS + Filt[count]*Filt[count]nextRMS = SqRt(RMS / MAPeriod)//Rescale Filt in terms of Standard DeviationsScaledFilt = Filt / RMSalpha1 = Abs(ScaledFilt)*5 / MAPeriodDSMA = alpha1*Close + (1 - alpha1)*DSMA[1]endif//KASE Deviation Stoploss Bandsn = 30periodFast = 9periodSlow = 21DTR = max(max(High - Low[2], abs(High - Close[2])),max(abs(Low - Close[2]),(abs(Low - Close[2]))))avg = average[n](DTR)st = std[n](DTR)maFast = average[periodFast,1](close)maSlow = average[periodSlow,1](close)if maFast<maSlow thenWarningLine = typicalprice+avgDev1 = typicalprice+avg + stDev2 = typicalprice+avg + 2.2*stDev3 = typicalprice+avg + 3.6*stelseWarningLine = typicalprice-avgDev1 = typicalprice-avg - stDev2 = typicalprice-avg - 2.2*stDev3 = typicalprice-avg - 3.6*stendif//RSI DivergenceMinBarRange = 3Rge = averagetruerange[10](close)MyRSI = rsi[RsiPeriod](Close)ONCE ShiftText = 3RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RSITopThresholdRsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RSIBottomThresholdif RsiMax thenRSIMax1 = MyRSI[1]High1 = High[1]for I = MinBarRange to 80if RsiMax[I] thenRSIMax2 = MyRSI[I + 1]High2 = High[I + 1]If High1 > High2 and RSIMax1 < RSIMax2 thenDRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)DRAWTEXT("Regular", barindex, High + Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)elsif High1 < High2 and RSIMax1 > RSIMax2 thenDRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)DRAWTEXT("Hidden", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)endifbreakendifnextendifif RsiMin thenRSIMin1 = MyRSI[1]Low1 = Low[1]for I = MinBarRange to 80if RSIMin[I] thenRSIMin2 = MyRSI[I + 1]Low2 = Low[I + 1]If Low1 < Low2 and RSIMin1 > RSIMin2 thenDRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)DRAWTEXT("Regular", barindex, lOW - Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)elsif Low1 > Low2 and RSIMin1 < RSIMin2 thenDRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)DRAWTEXT("Hidden", barindex, lOW - Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)endifbreakendifnextendifIf low - high[1] > 0.0001 THENDRAWRECTANGLE(barindex[1],close[1],barindex,low) COLOURED(0,0,0,255)DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)DRAWTEXT("GAP", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,10)coloured(0,0,255,255)ElsIf low[1] - high > 0.0001 THENDRAWRECTANGLE(barindex[1],close[1],barindex,high) COLOURED(0,0,0,255)DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)DRAWTEXT("GAP", barindex, lOW - Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)ENDIF//ADX ActiveTrend Indicator//If hour < 9 or hour > 17 Then//BACKGROUNDCOLOR(0,0,0,0)If ADX[ADXPeriod] > ADXR[ADXPeriod] and ADX > ADXVal ThenBACKGROUNDCOLOR(0,127,255,25)ElsIf ADX[ADXPeriod] < ADXR[ADXPeriod] and ADX <= ADXVal ThenBACKGROUNDCOLOR(255,99,71,25)EndIfRETURN MID as "EWMA(EMA)", UB style(line,2) as "+ESD", BB style(line,2) as "-ESD", BRSI coloured(0,0,255) style(line,2) as "RSI2", BRSIT coloured(0,255,0) style(line,2) as "95", BRSIB coloured(255,0,0) style(line,2) as "5", DSMA coloured(142,123,38) style(line,2) AS "Dev MA", Warningline coloured(255,0,0) style(dottedline,1) as "WarningLine", Dev1 coloured(2, 118, 253) style(dottedline,1) as "DevStop1", Dev2 coloured(20, 100, 244) style(dottedline,1) as "DevStop2", Dev3 coloured(1, 71, 250) style(dottedline,1) as "DevStop3"06/24/2018 at 1:09 PM #7423106/24/2018 at 1:16 PM #7423406/24/2018 at 2:29 PM #74238Yes I know, but I’ve got so many added lines on my Price Chart I wanted to see all what yours showed first as a separate Indicator else I would not see all your intricacies.
I’ve made the text bigger, but is there anyway to make arrows bigger?
06/24/2018 at 3:42 PM #74248For what it’s worth, here is an explanation of how the indicator works.
Idea: Having an all in one indicator that provides all the information I need on the chart itself.
- Exponentially Calculated Bollinger Band
- Background Filter indicating the Trend strength using ADX in relation to ADXR (Dark Blue = Trending, Light Red = Ranging)
- The oscillating blue line is a normalized RSI2 (Above green line = Good long exit, Below red line = Good short exit)
- Dashed lines = KASE Dev stop levels (switching on a 9EMA and 21EMA cross – keeping you with Price Action)
- Golden Line = Deviation based Moving Average
06/26/2018 at 9:11 AM #74361Remove ONCE from line 114 and text will appear…. magically!!!!
06/26/2018 at 1:25 PM #7442906/26/2018 at 1:30 PM #74430Glad to know, but beware.., that trick can be made only ONCE!!!
AhAhAh…. I’m kidding.
06/15/2022 at 9:17 PM #195350Hi Roberto,
I am Italian like you but I write in English so everyone can understand.
I would like to have text displayed and I am struggling to understand how to get it done.
I know drawtext should be used by I visibly miss something. can you please show me a sample of full code to simply display for example a text? Possible on top right corner of the indicator..
Thanks a lot
06/15/2022 at 10:45 PM #19535506/15/2022 at 11:00 PM #195357@Wolf
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Thanks 🙂
06/15/2022 at 11:15 PM #195365 -
AuthorPosts
Find exclusive trading pro-tools on