VISUAL LEVELs INDICATOR with Donchian channel
Forums › ProRealTime English forum › ProBuilder support › VISUAL LEVELs INDICATOR with Donchian channel
- This topic has 27 replies, 6 voices, and was last updated 1 year ago by gregoire.
-
-
01/18/2021 at 3:41 AM #158218
Hello Nicolas, I congratulate you for the work you have done. This is an indicator that will benefit the entire PRT community.
I have added code to also have the supports (see the itf file).I tried to use the indicator lines in an algorithm but no trade is generated.
Here is the code :1234567891011DEFPARAM CUMULATEORDERS = Falsell, hh = CALL "DONCHIAN LEVELS" [30,800,10,2]c1 = high >= hh and close <hhIF NOT ShortOnMarket AND c1 THENSELLSHORT 1 LOT AT MARKETENDIFSET TARGET $PROFIT 1000SET STOP$LOSS 500I think it’s because the indicator doesn’t create the old lines.
Can we add them in order to be able to create relevant backtests?As you can see in the screenshots, such an indicator will help the robots to bounce on the right levels.
This will bring a real added value to the mean reversion strategy and will allow us to be more efficient on the markets.01/18/2021 at 9:15 AM #158233The levels are found and stored into variables arrays, which are not retrieved when you CALL an indicator.
The only way to find the same levels is to add the entire codes of the indicators into the strategy. Loop through the arrays of support and resistance levels on each candle to find if the price is bouncing on one of them.
1 user thanked author for this post.
01/19/2021 at 10:07 PM #158585Ok @Nicolas, if I understand well I have to create and incorporate in the algo a table that includes all the code, then loops to keep the levels in the table as long as the prices have not bounced on it.
I’m reading the thread (https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/ ) to understand how to use the tables. I’m much more efficient at trading than I am at programming, so I hope I can do it. I can ask you questions for help if I can’t find a solution?01/20/2021 at 1:26 AM #158604@Nicolas, your code works very well once inserted into a strategy, however it doesn’t generate any trade when using volume or tick bars. Do you know how to modify the code to make it work with these bars?
These are the candles most used by algorithm and those whose distribution is closest to a Gaussian distribution.123456789101112131415161718192021222324252627DEFPARAM CUMULATEORDERS = Falsep = 50maxbars = 200 //combien de bars dans l'historique?reversedCandles = 10 //les niveaux ont été les mêmes pendant X barresreversedPoints = 2 //niveau actuel - niveau précédent > points Yif barindex > p thenll= lowest[p](low)hh= highest[p](high)if ll<>ll[1] and ll[1]>0 and ll[1]=ll[1+reversedCandles] and abs(ll-ll[1])>=reversedPoints*pointsize then$llprice[lli]=ll$llbar[lli]=barindex[1+reversedCandles]lli=lli+1endifendifc1 = high >= hh and close <hhIF NOT ShortOnMarket AND c1 THENSELLSHORT 1 LOT AT MARKETENDIFSET TARGET $PROFIT 1000SET STOP$LOSS 50001/20/2021 at 9:47 AM #158630The correct code to test each of the found levels is below:
123456789101112131415161718192021222324252627282930313233DEFPARAM CUMULATEORDERS = Falsep = 50maxbars = 200 //combien de bars dans l'historique?reversedCandles = 10 //les niveaux ont été les mêmes pendant X barresreversedPoints = 2 //niveau actuel - niveau précédent > points Yif barindex > p thenll= lowest[p](low)hh= highest[p](high)if ll<>ll[1] and ll[1]>0 and ll[1]=ll[1+reversedCandles] and abs(ll-ll[1])>=reversedPoints*pointsize then$llprice[lli]=ll//$llbar[lli]=barindex[1+reversedCandles]lli=lli+1endifendiffor i =0 to lli-1 dotestprice = $llprice[i]c1 = high >= testprice and close <testpriceif c1 thenbreakendifnextIF NOT ShortOnMarket AND c1 THENSELLSHORT 1 LOT AT MARKETENDIFSET TARGET pPROFIT 20SET STOP pLOSS 10We have to make a loop through the array populated with the price levels and if the condition is met then we break the loop and an order is launched.
03/12/2023 at 5:57 AM #211402bonjour nicolasserait t il possible de faire en sorte que l indicateur fonctionne sur la version v11 en tick j ai voulu le testé mais il ne fonctionne pas et cela m intéresse fortement mais mon niveau en prog est encore limité et cela m ‘à l air assez avancé.merci pour le temps que tu pourra accordé.cordialement.greghello nicolas would it be possible to make the indicator work on the v11 version in tick I wanted to test it but it does not work and it interests me greatly but my level in prog is still limited and it seems to me quite advanced.
thank you for the time you can give. Cordially.
greg
03/12/2023 at 7:24 AM #211406Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Thank you 🙂
03/12/2023 at 7:28 AM #21140703/12/2023 at 7:31 AM #21140803/16/2023 at 11:38 AM #21163903/23/2023 at 11:51 PM #212030Hello Nicolas nothing sorry I hadn’t slept for 2 days, I tested since then it works, however small question, we have the levels in red and the levels in green, and we have numbers in gray? but no line what do they correspond to? would it be possible to add an option to display them or not? THANKS
03/24/2023 at 9:28 AM #212044I’m not sure about your query, but I think you want the text to be switch off with a setting, which I implement in the below version (setting is “showtext”, default state is OFF).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293defparam drawonlastbaronly=truep = 20maxbars = 800 //how many bars in history?reversedCandles = 5 //levels have been the same during X barsreversedPoints = 2 //current level - previous level > Y pointsshowtext = 0 //show levels textif barindex > p thenhh= highest[p](high)ll= lowest[p](low)if hh<>hh[1] and hh[1]>0 and hh[1]=hh[1+reversedCandles] and abs(hh-hh[1])>=reversedPoints*pointsize then$hhprice[hhi]=hh$hhbar[hhi]=barindex[1+reversedCandles]hhi=hhi+1endifendifif islastbarupdate and hhi>0 then//plot the hh linesfor i = 0 to hhi-1 do //loop through levelselapsed = barindex-$hhbar[i]if elapsed>1 and elapsed<=maxbars thenoffset = max(0,barindex-$hhbar[i])for j = 0 to offset do //testing price break of the current levelprice1 = close[j]priceprev = close[j+1]level = $hhprice[i]broken = 0if (price1>level and priceprev<level) or (price1<level and priceprev>level) thenbroken=1//drawarrow($hhbar[i],price)breakendifnextif broken=0 thendrawsegment($hhbar[i],$hhprice[i],barindex,$hhprice[i])COLOURED(255,0,0)test=$hhprice[i]if showtext thendrawtext("#test#",barindex,$hhprice[i],serif,bold,20)COLOURED(255,0,0)endif//drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)endifendifnextendifif barindex > p thenll= lowest[p](low)hh= highest[p](high)if ll<>ll[1] and ll[1]>0 and ll[1]=ll[1+reversedCandles] and abs(ll-ll[1])>=reversedPoints*pointsize then$llprice[lli]=ll$llbar[lli]=barindex[1+reversedCandles]lli=lli+1endifendif// ___________________________if islastbarupdate and lli>0 then//tracer les lignes llfor i = 0 to lli-1 do //boucle à travers les niveauxelapsed = barindex-$llbar[i]if elapsed>1 and elapsed<=maxbars thenoffset = max(0,barindex-$llbar[i])for j = 0 to offset do //tester la rupture de prix du niveau actuelprice1 = close[j]priceprev = close[j+1]level = $llprice[i]broken = 0if (price1<level and priceprev>level) or (price1>level and priceprev<level) thenbroken=1//drawarrow($hhbar[i],price)breakendifnextif broken=0 thendrawsegment($llbar[i],$llprice[i],barindex,$llprice[i])COLOURED(0,128,0)test=$llprice[i]if showtext thendrawtext("#test#",barindex,$llprice[i],serif,bold,20)COLOURED(0,128,0)endif//drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)endifendifnextendifreturn03/24/2023 at 4:19 PM #21206712345<span class="Y2IQFc" lang="en">Hello Nicolasno it's not quite that, can you already tell me what these data correspond to?looking closely at it is interesting and I wanted to know if it was possible to draw lines in gray with an on/off function.</span>1<span class="Y2IQFc" lang="en">anyway thank you for the reactivity and the modification</span>12<span class="Y2IQFc" lang="en">THANKS</span> -
AuthorPosts