hi Mav,

this code I posted uses nbar "future" points to establish that a top or bottom 
is formed. So no matter what you do in real time you will find that a new top 
of bottom will appear inside the chart nbars after the fact. So I do not see a 
two bar wait will do you any good,

regards, Ed




From: Mubashar Virk 
Sent: Monday, September 06, 2010 7:22 PM
To: [email protected] 
Subject: Re: [amibroker] Plotting Arrows on "Prices of Pivot Chart"


  
Ed,
How do you feel about a "two-bar "wait"" for PH or PL confirmation.

// E.M.Pottasch 09/06/10
SetBarsRequired(sbrAll,sbrAll);
nbar = Param("nbar",4,2,50,1);
cbar = Param("cbar",2,2,50,1); // wait

PHigh = H > Ref(HHV(H,nbar),-1) AND Ref(HHV(H,nbar),nbar) < H;
PHighPrice0 = ValueWhen(PHigh,H);
PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > cbar,PHighPrice0,Null);
PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= cbar,PHighPrice0,Null);
PLow = L < Ref(LLV(L,nbar),-1) AND Ref(LLV(L,nbar),nbar) > L;
PLowPrice0 = ValueWhen(PLow,L);
PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > cbar,PLowPrice0,Null);
PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= cbar,PLowPrice0,Null);

GraphXSpace = 5;
SetChartOptions(0, chartShowDates);
Plot(C,"\nLast",colorBlack,styleCandle);
PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10);
PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10);
PlotShapes(shapeUpArrow*PLow,colorGreen,0,L,-25);
PlotShapes(shapeDownArrow*PHigh,colorRed,0,H,-25);

Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleThick);
Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine);
Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleThick);
Plot(PLowPrice2,"",colorBrightGreen,styleDots | styleNoLine); 

On 9/6/2010 1:42 PM, Edward Pottasch wrote: 

    

  1 line was missing:

  // E.M.Pottasch 09/06/10 
  SetBarsRequired(sbrAll,sbrAll); 
  nbar = Param("nbar",4,2,50,1); 

  PHigh = H > Ref(HHV(H,nbar),-1) AND Ref(HHV(H,nbar),nbar) < H; 
  PHighPrice0 = ValueWhen(PHigh,H); 
  PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > nbar,PHighPrice0,Null); 
  PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= nbar,PHighPrice0,Null); 
  PLow = L < Ref(LLV(L,nbar),-1) AND Ref(LLV(L,nbar),nbar) > L; 
  PLowPrice0 = ValueWhen(PLow,L); 
  PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > nbar,PLowPrice0,Null); 
  PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= nbar,PLowPrice0,Null); 

  GraphXSpace = 5; 
  SetChartOptions(0, chartShowDates); 
  Plot(C,"\nLast",colorWhite,styleCandle); 
  PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10); 
  PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10); 
  PlotShapes(shapeUpArrow*PLow,colorGreen,0,L,-25); 
  PlotShapes(shapeDownArrow*PHigh,colorRed,0,H,-25); 

  Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleThick); 
  Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine); 
  Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleThick); 
  Plot(PLowPrice2,"",colorBrightGreen,styleDots | styleNoLine); 


  From: Edward Pottasch 
  Sent: Monday, September 06, 2010 10:40 AM
  To: [email protected] 
  Subject: Re: [amibroker] Plotting Arrows on "Prices of Pivot Chart"


    

  Mav,

  I admit I did not plough through the code you posted in detail but it seems 
to me it is unavoidable that future quotes are needed to be able to determine 
that a bottom or top has been found. 

  below I added a little extension. Only where the horizontal lines are solid 
it does not use future quotes, regards, Ed

  // E.M.Pottasch 09/06/10 
  SetBarsRequired(sbrAll,sbrAll); 
  nbar = Param("nbar",4,2,50,1); 

  PHigh = H > Ref(HHV(H,nbar),-1) AND Ref(HHV(H,nbar),nbar) < H; 
  PHighPrice0 = ValueWhen(PHigh,H); 
  PHighPrice1 = IIf(PHighPrice0 AND BarsSince(PHigh) > nbar,PHighPrice0,Null); 
  PHighPrice2 = IIf(PHighPrice0 AND BarsSince(PHigh) <= nbar,PHighPrice0,Null); 
  PLow = L < Ref(LLV(L,nbar),-1) AND Ref(LLV(L,nbar),nbar) > L; 
  PLowPrice0 = ValueWhen(PLow,L); 
  PLowPrice1 = IIf(PLowPrice0 AND BarsSince(Plow) > nbar,PLowPrice0,Null); 
  PLowPrice2 = IIf(PLowPrice0 AND BarsSince(Plow) <= nbar,PLowPrice0,Null); 

  GraphXSpace = 5; 
  SetChartOptions(0, chartShowDates); 
  Plot(C,"\nLast",colorWhite,styleCandle); 
  PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10); 
  PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10); 
  PlotShapes(shapeUpArrow*PLow,colorGreen,0,L,-25); 
  PlotShapes(shapeDownArrow*PHigh,colorRed,0,H,-25); 

  Plot(PHighPrice1,"\nPHighPrice",colorOrange,styleThick); 
  Plot(PHighPrice2,"",colorOrange,styleDots | styleNoLine); 
  Plot(PLowPrice1,"\nPLowPrice",colorBrightGreen,styleThick); 






  From: Mubashar Virk 
  Sent: Monday, September 06, 2010 10:22 AM
  To: [email protected] 
  Subject: Re: [amibroker] Plotting Arrows on "Prices of Pivot Chart"


    
  Edward,

  WOW!
  Beautiful!

  Edward, the only differece  between your and Reinsley Codes is that future is 
referenced in your code. 
  But the concept of PH & PL is such that future referencing does not make any 
difference.

  Thank you very much for this easy to understand beauty.

  Best regards,
  Mav


  On 9/6/2010 12:18 PM, Edward Pottasch wrote: 

      
    hi,

    I don't see why you need this complicated code. Code below gives same 
result (arrows included), rgds, Ed

    // E.M.Pottasch 09/06/10 
    SetBarsRequired(sbrAll,sbrAll); 
    nbar = Param("nbar",4,2,50,1); 

    PHigh = H > Ref(HHV(H,nbar),-1) AND Ref(HHV(H,nbar),nbar) < H; 
    PHighPrice = ValueWhen(PHigh,H); 
    PLow = L < Ref(LLV(L,nbar),-1) AND Ref(LLV(L,nbar),nbar) > L; 
    PLowPrice = ValueWhen(PLow,L); 

    GraphXSpace = 5; 
    SetChartOptions(0, chartShowDates); 
    Plot(C,"\nLast",colorWhite,styleCandle); 
    PlotShapes(shapeSmallCircle*PLow,colorGreen,0,L,-10); 
    PlotShapes(shapeSmallCircle*PHigh,colorRed,0,H,10); 
    PlotShapes(shapeUpArrow*PLow,colorGreen,0,L,-25); 
    PlotShapes(shapeDownArrow*PHigh,colorRed,0,H,-25); 




    From: Mubashar Virk 
    Sent: Monday, September 06, 2010 8:44 AM
    To: [email protected] 
    Subject: [amibroker] Plotting Arrows on "Prices of Pivot Chart"


      
    HI Reinsley,

    I have tried to mark PH& PL with arrows instead of "stars" in the below
    AFL of yours. I tried various combination of plotshape but failed in
    every instance. Can you please help?

    Thanks,
    Mav

    ----------------------------------------------------------
    // pivots and prices
    // based on Pramod's comments 
http://www.amibroker.com/library/detail.php?id=617
    // adapted by Reinsley : Prices on Pivot and ajustable digits #
    // mod by Sanjiv Bansal : take care of Highs or Lows when two adjacent bars 
are equal
    // does not reference to future

    SetChartOptions( 0, chartShowDates );

    _SECTION_BEGIN( "Price" );
    _N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} \nOp %g, \nHi
    %g, \nLo
    %g, \nCl %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )
    ) ) );
    Plot( C, "Close", ParamColor( "Color", colorBlack ), styleNoTitle |
    styleCandle
    | styleThick );
    _SECTION_END();

    _SECTION_BEGIN( "pivot" );
    price = ParamToggle( "Plot Price", "Off|On", 1 );
    num = Param( "trend", 4, 1, 10, 1 );
    dist = 0.5 * ATR( 10 );
    rightfig = Param( "rightfig ", 7, 1, 10, 1 );
    xspace = Param( "GraphXSpace ", 10, 1, 20, 1 );

    mHHV = HHV( H, num );
    mLLV = LLV( L, num );

    FirstVisibleBar = Status( "FirstVisibleBar" );
    Lastvisiblebar = Status( "LastVisibleBar" );

    for ( b = Firstvisiblebar + num; b<= Lastvisiblebar AND b< BarCount -
    num; b++ )
    {
    i = num;
    ml = 0;
    mu = 0;

    while ( i> 0 )
    {

    if ( L[b]< L[b+i] )
    {
    ml++;
    }

    if ( H[b]> H[b+i] )
    {
    mu++;
    }

    i--;
    }

    if ( ml == num AND L[B] == mLLV[B] )
    {
    PlotText( "\n *\n", b, L[b], colorGreen );

    if ( price == 1 )
    {
    p = StrRight( NumToStr( L[b], 4.1 ), rightfig );
    PlotText( "\n\n" + p, b - 2 , L[b] , colorGreen );
    }
    }

    if ( mu == num AND H[B] == mHHV[B] )
    {
    PlotText( " *\n", b, H[b], colorRed );

    if ( price == 1 )
    {
    p = StrRight( NumToStr( H[b], 4.1 ), rightfig );
    PlotText( p , b - 2 , H[b] + dist[b] + 1, colorRed );
    }
    }
    }
    _SECTION_END();








Reply via email to