Adding Stop loss Levels to existing code
Forums › ProRealTime English forum › ProBuilder support › Adding Stop loss Levels to existing code
- This topic has 3 replies, 2 voices, and was last updated 3 years ago by Geoffrey Toplis.
-
-
03/25/2021 at 5:13 PM #165317
Hi there,
I am trying to add stop levels to an indicator I am using – I’ve looked everywhere and nothing seems to work well enough with the indicator I am using. The closest I got was with Someones Darvas Boxes code:
https://www.prorealcode.com/prorealtime-indicators/darvas-boxes-2/
Id like to add these lines as stop loss level (It is for hidden Divergence) so when the indicator picks up a lower high / higher low it will draw these lines on the previous high / low
See code below:
Hidden Divergence123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960//RSI Divergences By Frank (Francesco)//Description: the indicator draws arrows on chart as entry points when a direct or an hidden RSI divergence is found.//When a DIRECT divergence is found, "dd" (direct divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow//When an HIDDEN or INVERSE divergence is found, "hd" (hidden divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow//Variables://RsiPeriod: number of bars to calculare RSI value//RsiOverSold: Oversold Level//RsiOverBought: OverBought Level//MinBarRange: minimum distance from two consecutive Price Highs or Price LowsRge = averagetruerange[7](close)MyRSI = rsi[RsiPeriod](Close)ONCE ShiftText = 3RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBoughtRsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSoldif 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 thenelsif High1 < High2 and RSIMax1 > RSIMax2 thenDRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)DRAWTEXT("Sell", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,15)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 thenelsif Low1 > Low2 and RSIMin1 < RSIMin2 thenDRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)DRAWTEXT("Buy", barindex, lOW - Rge / ShiftText / 0.2,SansSerif,Italic,15)coloured(0,0,255,255)REM Set Stop LevelMyStop =Low[1]endifbreakendifnextendifreturnThanks in advance and let me know if you need anymore information
Geoff
03/25/2021 at 5:26 PM #165322Just to clarify, these levels would be on the price chart not the RSI
Regards,
Geoff
03/25/2021 at 6:02 PM #165325There you go:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990//////////////////////////////////////////////////////////////////////////////////////////// DARVAS Boxes//// https://www.prorealcode.com/prorealtime-indicators/darvas-boxes-2///============================== Indicateurif box=1 and (high>DownBoxe or low<UpBoxe) thenbox=0flag=0endifif box=0 and flag=0 and low>low[3] and low[1]>low[3] and low[2]>low[3] thenth=low[3]flag=1endifif flag=1 and box=0 and low<th thenflag=0endifif flag=1 and box=0 and high<high[3] and high[1]<high[3] and high[2]<high[3] thenDownBoxe=high[3]UpBoxe=thbox=1endifonce DownBoxe=undefinedonce UpBoxe=undefined//============================== Fin//return UpBoxe style (point,3) as "UpBoxe",DownBoxe style (point,3) as "DownBoxe"////////////////////////////////////////////////////////////////////////////////////////////RSI Divergences By Frank (Francesco)//Description: the indicator draws arrows on chart as entry points when a direct or an hidden RSI divergence is found.//When a DIRECT divergence is found, "dd" (direct divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow//When an HIDDEN or INVERSE divergence is found, "hd" (hidden divergence) text is added to chart over (Sell signal) or under (Buy signal) the arrow//Variables:RsiPeriod = 14 //: number of bars to calculare RSI valueRsiOverSold = 30 //: Oversold LevelRsiOverBought = 70 //: OverBought LevelMinBarRange = 2 //: minimum distance from two consecutive Price Highs or Price LowsRge = averagetruerange[7](close)MyRSI = rsi[RsiPeriod](Close)ONCE ShiftText = 3RsiMax = MyRSI < MyRSI[1] and MyRSI[1] > MyRSI[2] and MyRSI[1] > RsiOverBoughtRsiMin = MyRSI > MyRSI[1] and MyRSI[1] < MyRSI[2] and MyRSI[1] < RsiOverSoldif 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 thenelsif High1 < High2 and RSIMax1 > RSIMax2 thenDRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)DRAWTEXT("Sell", barindex, High + Rge / ShiftText / 0.2,SansSerif,Italic,15)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 thenelsif Low1 > Low2 and RSIMin1 < RSIMin2 thenDRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)DRAWTEXT("Buy", barindex, lOW - Rge / ShiftText / 0.2,SansSerif,Italic,15)coloured(0,0,255,255)REM Set Stop LevelMyStop =Low[1]endifbreakendifnextendifreturn UpBoxe style (point,1) as "UpBoxe",DownBoxe style (point,1) as "DownBoxe"03/25/2021 at 6:30 PM #165328Thank you so much – I really appreciate the help
I am sorry if I am starting to ask too much but is there a way that the lines can be drawn drawn according to the high / low that corresponds to the previous high or low defined in the divergence indicator instead of just highs and lows on the chart
Ive tried to show an example in the attached image
-
AuthorPosts
Find exclusive trading pro-tools on