VISUAL LEVELs INDICATOR with Donchian channel

Viewing 13 posts - 16 through 28 (of 28 total)
  • Author
    Posts
  • #158218 quote
    Soyouzzz1
    Participant
    Junior

    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 :

    DEFPARAM CUMULATEORDERS = False
    ll, hh = CALL "DONCHIAN LEVELS" [30,800,10,2]
    
    c1 = high >= hh and close <hh
    
    IF NOT ShortOnMarket AND c1 THEN
    SELLSHORT 1 LOT AT MARKET
    ENDIF
    
    SET TARGET $PROFIT 1000
    SET STOP$LOSS 500

    I 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.

    #158233 quote
    Nicolas
    Keymaster
    Master

    The 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.

    Soyouzzz1 thanked this post
    #158585 quote
    Soyouzzz1
    Participant
    Junior

    Ok @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?

    #158604 quote
    Soyouzzz1
    Participant
    Junior

    @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.

    DEFPARAM CUMULATEORDERS = False
    
    p = 50
    maxbars = 200 //combien de bars dans l'historique?
    reversedCandles = 10 //les niveaux ont été les mêmes pendant X barres
    reversedPoints = 2 //niveau actuel - niveau précédent > points Y
     
    if barindex > p then
     
    ll= 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+1
    endif
    endif
    
    c1 = high >= hh and close <hh
     
    IF NOT ShortOnMarket AND c1 THEN
    SELLSHORT 1 LOT AT MARKET
    ENDIF
     
    SET TARGET $PROFIT 1000
    SET STOP$LOSS 500
    #158630 quote
    Nicolas
    Keymaster
    Master

    The correct code to test each of the found levels is below:

    DEFPARAM CUMULATEORDERS = False
    
    p = 50
    maxbars = 200 //combien de bars dans l'historique?
    reversedCandles = 10 //les niveaux ont été les mêmes pendant X barres
    reversedPoints = 2 //niveau actuel - niveau précédent > points Y
     
    if barindex > p then
     
    ll= 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+1
    endif
    endif
    
    for i =0 to lli-1 do 
    testprice = $llprice[i]
    c1 = high >= testprice and close <testprice
    if c1 then 
    break
    endif
    next
     
    IF NOT ShortOnMarket AND c1 THEN
    SELLSHORT 1 LOT AT MARKET
    ENDIF
     
    SET TARGET pPROFIT 20
    SET STOP pLOSS 10

    We 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.

    #211402 quote
    gregoire
    Participant
    Senior

    bonjour nicolas

    serait 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.

    greg

    hello 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

    #211406 quote
    robertogozzi
    Moderator
    Master

    @gregoire

    Only 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 🙂

    #211407 quote
    gregoire
    Participant
    Senior

    sorry roberto I haven’t slept for 2 days I didn’t pay attention, thank you

    #211408 quote
    gregoire
    Participant
    Senior

    ok i go to my bed lol

    #211639 quote
    Nicolas
    Keymaster
    Master

    The indicator should work on ticks chart, there is no limitation. Why do you think it is not?

    #212030 quote
    gregoire
    Participant
    Senior

    Hello 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

    #212044 quote
    Nicolas
    Keymaster
    Master

    I’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).

    defparam drawonlastbaronly=true
     
    p = 20
    maxbars = 800 //how many bars in history?
    reversedCandles = 5 //levels have been the same during X bars
    reversedPoints = 2 //current level - previous level > Y points
    showtext = 0 //show levels text
     
    if barindex > p then
     
    hh= 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+1
    endif
    endif
     
    if islastbarupdate and hhi>0 then
    //plot the hh lines
    for i = 0 to hhi-1 do //loop through levels
    elapsed = barindex-$hhbar[i]
    if elapsed>1 and elapsed<=maxbars then
     
    offset = max(0,barindex-$hhbar[i])
    for j = 0 to offset do //testing price break of the current level
    price1 = close[j]
    priceprev = close[j+1]
    level = $hhprice[i]
    broken = 0
    if (price1>level and priceprev<level) or (price1<level and priceprev>level) then
    broken=1
    //drawarrow($hhbar[i],price)
    break
    endif
    next 
    if broken=0 then
    drawsegment($hhbar[i],$hhprice[i],barindex,$hhprice[i])COLOURED(255,0,0)
    test=$hhprice[i]
    if showtext then 
    drawtext("#test#",barindex,$hhprice[i],serif,bold,20)COLOURED(255,0,0)
    endif 
    //drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)
    endif 
    endif
    next
    endif
    
    if barindex > p then
     
    ll= 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+1
    endif
    endif
    // ___________________________
    
    if islastbarupdate and lli>0 then
    //tracer les lignes ll
    for i = 0 to lli-1 do //boucle à travers les niveaux
    elapsed = barindex-$llbar[i]
    if elapsed>1 and elapsed<=maxbars then
     
    offset = max(0,barindex-$llbar[i])
    for j = 0 to offset do //tester la rupture de prix du niveau actuel
    price1 = close[j]
    priceprev = close[j+1]
    level = $llprice[i]
    broken = 0
    if (price1<level and priceprev>level) or (price1>level and priceprev<level) then
    broken=1
    //drawarrow($hhbar[i],price)
    break
    endif
    next 
    if broken=0 then
    drawsegment($llbar[i],$llprice[i],barindex,$llprice[i])COLOURED(0,128,0)
    test=$llprice[i]
    if showtext then 
    drawtext("#test#",barindex,$llprice[i],serif,bold,20)COLOURED(0,128,0)
    endif
    //drawtext("#offset#",barindex,$hhprice[i],serif,bold,20)
    endif 
    endif
    next
    endif
     
    return
    #212067 quote
    gregoire
    Participant
    Senior
    Hello Nicolas
    no 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.
    
    
    anyway thank you for the reactivity and the modification
    
    THANKS
Viewing 13 posts - 16 through 28 (of 28 total)
  • You must be logged in to reply to this topic.

VISUAL LEVELs INDICATOR with Donchian channel


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Soyouzzz1 @soyouzzz1 Participant
Summary

This topic contains 27 replies,
has 6 voices, and was last updated by gregoire
2 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/15/2020
Status: Active
Attachments: 21 files
Logo Logo
Loading...