Can someone finish the syntax on this non functioning code.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #77992 quote
    Bard
    Participant
    Master

    Hi, Can anyone fix this code?

    It was posted here on PRT  but has a minor syntax error if anyone can fix it that’d be appreciated as I wanted to compare it to the code I modified from another site and posted here:
    https://www.prorealcode.com/topic/kase-dev-stop-dev-stops-4-5-6-0-using-sar-to-flip-devs/

    Cheers
    Bard

     

    //Kase Deviation Stoploss Bands
    
    n = 30
    DTR = 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[9,1](close)
    maSlow = average[21,1](close)
    
    once DevInit = 1
    
    If DevInit = 1 Then 
    If maFast > maSlow Then
    DevLong = 1
    DevLongC = 0
    Else
    DevLong = 0
    DevShortC = 0
    EndIf
    DevInit = 0
    ElsIf DevInit = 0 and DevLong = 1 Then
    HighestDev3 = Dev3
    For y = 1 to DevLongC Do
    If Dev3[y] > HighestDev3 Then
    HighestDev3 = Dev3[y]
    EndIf
    Next
    If close < HighestDev3 Then
    DevLong = 0
    DevShortC = 0
    EndIf
    ElsIf DevInit = 0 and DevLong = 0 Then
    LowestDev3 = Dev3
    For x = 1 to DevShortC Do
    If Dev3[x] < LowestDev3 Then
    DevLong = 1
    DevLongC = 0
    EndIf
    EndIf
    If DevLong = 1 Then
    DevLongC = DevLongC + 1
    //WarningLine = typicalprice-avg
    //Dev1 = typicalprice-avg - st
    Dev2 = typicalprice-avg - 2.2*st
    Dev3 = typicalprice-avg - 3.6*st
    ElsIf DevLong = 0 Then
    DevShortC = DevShortC + 1
    //WarningLine = typicalprice+avg
    //Dev1 = typicalprice+avg + st
    Dev2 = typicalprice+avg + 2.2*st
    Dev3 = typicalprice+avg + 3.6*st
    EndIf
    
    Return Dev2 coloured(2, 118, 253) style(dottedline,2) as "Dev Stop 2.2",
    Dev3 coloured(2, 118, 253) style(dottedline,2) as "Dev Stop 3.6"
    
    #78350 quote
    Nicolas
    Keymaster
    Master

    I fixed the syntax error of your code, don’t know if the indicator is computing correctly though, here it is:

    //Kase Deviation Stoploss Bands
    
    n = 30
    DTR = 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[9,1](close)
    maSlow = average[21,1](close)
    
    once DevInit = 1
    
    If DevInit = 1 Then
    If maFast > maSlow Then
    DevLong = 1
    DevLongC = 0
    Else
    DevLong = 0
    DevShortC = 0
    EndIf
    DevInit = 0
    ElsIf DevInit = 0 and DevLong = 1 Then
    HighestDev3 = Dev3
    For y = 1 to DevLongC Do
    If Dev3[y] > HighestDev3 Then
    HighestDev3 = Dev3[y]
    EndIf
    Next
    If close < HighestDev3 Then
    DevLong = 0
    DevShortC = 0
    EndIf
    ElsIf DevInit = 0 and DevLong = 0 Then
    LowestDev3 = Dev3
    For x = 1 to DevShortC Do
    If Dev3[x] < LowestDev3 Then
    DevLong = 1
    DevLongC = 0
    EndIf
    next
    If DevLong = 1 Then
    DevLongC = DevLongC + 1
    //WarningLine = typicalprice-avg
    //Dev1 = typicalprice-avg - st
    Dev2 = typicalprice-avg - 2.2*st
    Dev3 = typicalprice-avg - 3.6*st
    ElsIf DevLong = 0 Then
    DevShortC = DevShortC + 1
    //WarningLine = typicalprice+avg
    //Dev1 = typicalprice+avg + st
    Dev2 = typicalprice+avg + 2.2*st
    Dev3 = typicalprice+avg + 3.6*st
    EndIf
    endif
    
    Return Dev2 coloured(2, 118, 253) style(dottedline,2) as "Dev Stop 2.2",Dev3 coloured(2, 118, 253) style(dottedline,2) as "Dev Stop 3.6"
    #78383 quote
    Bard
    Participant
    Master

    Thanks @nicolas, but unfortunately not, pls see screen:

    I have the SAR Dev Stop code that I modified and posted on this forum but was wondering how it compared to @juanj’s code and if he has an idea why his code is not performing as intended?

    Cheers

    #78397 quote
    Nicolas
    Keymaster
    Master

    Sorry, I don’t understand, so many topics about the same indis and their applications.., I’m totally lost… 🙁

    #78409 quote
    Bard
    Participant
    Master

    Me too…  The bands were meant to hug the price series but didn’t when applied via the spanner to the Price Chart.

    #78417 quote
    Bard
    Participant
    Master

    Note sure why this image didn’t attach with the post above about juanj’s code not working but his Dev Stop lines are flat horizontal lines on the indicator window and don’t appear at all when applied to the main Price chart window. (The Kase Dev Stops are similar to ATR bands).

    Cheers, hope this makes sense.

    #78455 quote
    Nicolas
    Keymaster
    Master

    Maybe @juanj could help with his code?

    Bard thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Can someone finish the syntax on this non functioning code.


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bard @brad Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by Nicolas
7 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/10/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...