Creating a Kagi Bear condition

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #108201 quote
    soulintact
    Participant
    Senior

    Dear all,

    I am trying to create a Bear condition out of Nicola’s excellent Kagi on price chart. I get a syntax error, and I cannot understand why. Anyone spotting the error, thanks!

     

    //PRC_Kagi on price chart | indicator
    //05.09.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    // select one of the two possible setting (0=don't use)
    ReversalAmountPercent = 1.5 //amount of price percent to inverse Kagi trend
    //ReversalAmountPoints = 0 //amount of points to inverse Kagi trend
    // --- end of settings
    
    once kagi=close
    
    
    if ReversalAmountPercent>0 then
    //percent retracement
    pup = (close-kagi)/kagi
    pdn = (kagi-close)/kagi
    InvDec = 1/0.1
    //bullish reversal
    if pup>=ReversalAmountPercent/100 then
    coeff = abs(pup/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(kagi*(ReversalAmountPercent/100)*coeff)
    endif
    //bearish reversal
    if pdn>=ReversalAmountPercent/100 then
    coeff = abs(pdn/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(kagi*(ReversalAmountPercent/100)*coeff)
    
    endif
    
    if ReversalAmountPoints>0 then
    //points retracement
    pup = close-kagi
    pdn = kagi-close
    InvDec = 1
    //bullish reversal
    if pup>=ReversalAmountPoints*pointsize then
    coeff = (pup/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(ReversalAmountPoints*pointsize)*coeff
    
    endif
    //bearish reversal
    if pdn>=ReversalAmountPoints*pointsize then
    coeff = (pdn/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(ReversalAmountPoints*pointsize)*coeff
    endif
    
    BearKagi=(pdn>=ReversalAmountPercent/100) or (pdn>=ReversalAmountPoints*pointsize)
    #108215 quote
    Nicolas
    Keymaster
    Master

    The “ReversalAmountPoints” is still commented in your code at line 9.

    soulintact thanked this post
    #108245 quote
    soulintact
    Participant
    Senior

    Thanks Nicolas. It was careless of me. Unfortunately, I still get the syntax error message. Any more observations or possible ideas, thanks!

     

    //PRC_Kagi on price chart | indicator
    //05.09.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    // select one of the two possible setting (0=don't use)
    ReversalAmountPercent = 1.5 //amount of price percent to inverse Kagi trend
    ReversalAmountPoints = 0 //amount of points to inverse Kagi trend
    // --- end of settings
    
    once kagi=close
    
    
    if ReversalAmountPercent>0 then
    //percent retracement
    pup = (close-kagi)/kagi
    pdn = (kagi-close)/kagi
    InvDec = 1/0.1
    //bullish reversal
    if pup>=ReversalAmountPercent/100 then
    coeff = abs(pup/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(kagi*(ReversalAmountPercent/100)*coeff)
    endif
    //bearish reversal
    if pdn>=ReversalAmountPercent/100 then
    coeff = abs(pdn/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(kagi*(ReversalAmountPercent/100)*coeff)
    
    endif
    
    if ReversalAmountPoints>0 then
    //points retracement
    pup = close-kagi
    pdn = kagi-close
    InvDec = 1
    //bullish reversal
    if pup>=ReversalAmountPoints*pointsize then
    coeff = (pup/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(ReversalAmountPoints*pointsize)*coeff
    
    endif
    //bearish reversal
    if pdn>=ReversalAmountPoints*pointsize then
    coeff = (pdn/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(ReversalAmountPoints*pointsize)*coeff
    endif
    
    BearKagi=(pdn>=ReversalAmountPercent/100) or (pdn>=ReversalAmountPoints*pointsize)
    #108248 quote
    Nicolas
    Keymaster
    Master

    If you are just looking for when the new Kagi is up or down, just check the color in the original code.

    If R>0 , then its red, otherwise it’s green.

    To spot a new reversal, check if the previous R was >0 or = to 0.

    bearish = r>0 and r[1]=0

    and vice versa for a new bullish reversal condition:

    bullish = r[1]>0 and r=0
    soulintact thanked this post
    #108254 quote
    soulintact
    Participant
    Senior

    Thanks Nicolas, you solved it.

     

    //PRC_Kagi on price chart | indicator
    //05.09.2019
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge
    
    // --- settings
    // select one of the two possible setting (0=don't use)
    ReversalAmountPercent = 1.5 //amount of price percent to inverse Kagi trend
    ReversalAmountPoints = 0 //amount of points to inverse Kagi trend
    // --- end of settings
    
    once kagi=close
    
    
    if ReversalAmountPercent>0 then
    //percent retracement
    pup = (close-kagi)/kagi
    pdn = (kagi-close)/kagi
    InvDec = 1/0.1
    //bullish reversal
    if pup>=ReversalAmountPercent/100 then
    coeff = abs(pup/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(kagi*(ReversalAmountPercent/100)*coeff)
    r=0
    //g=255
    endif
    //bearish reversal
    if pdn>=ReversalAmountPercent/100 then
    coeff = abs(pdn/ReversalAmountPercent)*100
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(kagi*(ReversalAmountPercent/100)*coeff)
    r=255
    //g=0
    endif
    endif
    
    if ReversalAmountPoints>0 then
    //points retracement
    pup = close-kagi
    pdn = kagi-close
    InvDec = 1
    //bullish reversal
    if pup>=ReversalAmountPoints*pointsize then
    coeff = (pup/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi+(ReversalAmountPoints*pointsize)*coeff
    r=0
    //g=255
    endif
    //bearish reversal
    if pdn>=ReversalAmountPoints*pointsize then
    coeff = (pdn/pointsize)/ReversalAmountPoints
    coeff = round(InvDec*coeff-0.5)/InvDec
    kagi=kagi-(ReversalAmountPoints*pointsize)*coeff
    r=255
    //g=0
    endif
    endif
    
    BearKagi=r>0 and r[1]=0
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Creating a Kagi Bear condition


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
soulintact @soulintact Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/23/2019
Status: Active
Attachments: No files
Logo Logo
Loading...