Help to identify peak and trough in a indicator

Discussion in 'AmiBroker' started by giuditta, Feb 12, 2013.

  1. casoni

    casoni Well-Known Member

    Joined:
    Feb 19, 2006
    Messages:
    397
    Likes Received:
    487
    Trophy Points:
    63
    Hello ,
    if i understood your requirement , is this you want ?

    please check this

    per=Optimize("Period",Param("Period",14,2,20,1),2,20,1);
    percentchange=Optimize("Zig %",Param("Zig %",2,1,20,1),1,20,1);
    az= RSI(per);
    Plot( az,"",colorWhite,4);
    ZZ = Zig(az,LastValue(PercentChange)) ;
    Plot(zz,"",4,1);

    this plots zz on rsi . and same zz can be applied on price chart
    Thank you
     
  2. giuditta

    giuditta Member

    Joined:
    Feb 5, 2013
    Messages:
    31
    Likes Received:
    6
    Trophy Points:
    8
    HI Casoni,
    thanks to your reply. I suppose that you are italian too like me. :)
    My difficulty is to plot a peak of a zig formula. See the picture example in the previous page taken from metastock. I can't create the last formula in amibroker: according to this I need value 1 whenever zig of the zigzag in the middle has a peak and value 0 whenever there is no one.
    Is there anyone able to help me? regards
     
    Last edited: Feb 15, 2013
  3. giuditta

    giuditta Member

    Joined:
    Feb 5, 2013
    Messages:
    31
    Likes Received:
    6
    Trophy Points:
    8
     
  4. KelvinHand

    KelvinHand Well-Known Member

    Joined:
    Jun 4, 2008
    Messages:
    918
    Likes Received:
    1,162
    Trophy Points:
    93
    Location:
    Banned Forever
    pm me your code.
     
  5. sudris

    sudris Well-Known Member

    Joined:
    May 3, 2011
    Messages:
    464
    Likes Received:
    553
    Trophy Points:
    93
    I think you are close enough.

    the highlighted ones are the arrays. make sure you use the same array at RHS of "==".

    for example, if you want to use the Close array to find the peak then your code should look like below

     
  6. giuditta

    giuditta Member

    Joined:
    Feb 5, 2013
    Messages:
    31
    Likes Received:
    6
    Trophy Points:
    8
    here is the code of the zig formula.

    a = C-2*Ref(H,-1) + Ref(L,-2);
    s = V*(C-Ref(H,-1));
    q=a+s;
    zigq=Zig(q,10);
    Plot(Zigq,"zigq",colorWhite);
     

  7. hmsanil

    hmsanil Active Member

    Joined:
    Apr 11, 2010
    Messages:
    322
    Likes Received:
    98
    Trophy Points:
    28

    I tried to overlay this on price, but it not displaying properly.

    How to overlay this indicator on price, can anybody please tell me how to do it

    Thanks
     
  8. casoni

    casoni Well-Known Member

    Joined:
    Feb 19, 2006
    Messages:
    397
    Likes Received:
    487
    Trophy Points:
    63
    hello giuditta ,
    are you looking for something like this ?

    i have plotted peak-bottom on your indicator ,

    please check , if this helps i will post the code.

    * this is 60 min chart

    thank you
     
    Last edited: Jun 1, 2013
  9. KelvinHand

    KelvinHand Well-Known Member

    Joined:
    Jun 4, 2008
    Messages:
    918
    Likes Received:
    1,162
    Trophy Points:
    93
    Location:
    Banned Forever
    First thing, when you plot as indicator (means no price chart), what is the value shown on the Y-Axis ?

    Does it tally with the price chart value ?
    if not why ?
    cause there is a Volume play in the formula.


    To display the price chart and the non-tally indicator together, do the following:

    Plot(Zigq,"zigq",colorWhite, styleOwnScale);
     
    hmsanil likes this.
  10. KelvinHand

    KelvinHand Well-Known Member

    Joined:
    Jun 4, 2008
    Messages:
    918
    Likes Received:
    1,162
    Trophy Points:
    93
    Location:
    Banned Forever
    Now you show out "My Formula", now i understand why you failed.
    Since your are laying out your Ami Code, by extracting from your previous explanation,
    Hope the following is what your are trying to do:

    Code:
    //--1st indicator
    Change1=10;
    function First_Indicator()
    {
      a = C-2*Ref(H,-1) + Ref(L,-2);
      s = V*(C-Ref(H,-1));
      q = a+s; 
    
      zigq=Zig(q,Change1);
    
      return q;
    } 
    
    
    Zig_Fml1=First_Indicator();
    Plot(Zig_Fml1,"zig1",colorWhite, styleOwnScale);
    
    
    //-- 2nd Indicator
    percdiff = 1; 
    pkd = Peak(Zig_Fml1,percdiff) == High; 
    Plot(pkd, "my zig peak",colorYellow,styleOwnScale);
    
    
    If i m not wrong, the problem you had faced:
    1. You try to plot on price chart, nothing shown.
    2. Your formula contain volume.
    3. When you try to plot the following it will never work, it always default to 0.
    * pkd = Peak(Zig_Fml1,percdiff) == High;

    Why ?
    Because your formula contains item 2, no longer able to equal to High.


    IF (your script work on matastock AND don't work on Amibroker) THEN
    post the original mestastock with your actual picture;
    ELSE
    i think i got no way to do it.
     
    Last edited: Feb 17, 2013
Loading...

Share This Page