[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Re: Adding buy & sell to point and figure chart



PureBytes Links

Trading Reference Links

How can you backtest a compressed chart that does not relate to time?
Even the possible price values may never have existed because the PF
chart fills in the blank spaces during a column
You need to translate the PF values into real time (to match the date
X axis) to get any meaningful results. This means get rid of any
compression.

-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com


2008/6/19  <apforex@xxxxxxxxx>:
> Hello Larry,
>
> pfsig (box) will return the trading signals calculated inside the function.
>
> box = yourvalue;
> pfsig(box);
> Filter = Status("lastbarinrange")
> AddColumn(Buy, "buysignal");
>
> If you are uncomfortable with the function you can use only the code inside,
> initializing  BOX on top of the code as in the code below:
>
> /*----------------------------------------------------------------------
>    Simple Break-Out Strategy :
>    Generates trading signals, entry prices as well as PnF Plot on bar chart
>    (you need to set TickSize per symbol).
> -----------------------------------------------------------------------*/
>    SetBarsRequired(100000,100000);
>    box = Param("box", 10,10,30,1)*TickSize;
>    Buy = Sell = Short = Cover = 0;
>    BuyPrice = ShortPrice = CoverPrice = SellPrice = C;
>
>    j = 0;
>    Lo[0] = Box * ceil(L[0]/Box) ;
>    Hi[0] = Lo[0] + box;
>    direction = 0;
>    reverse = 3;
>    pfline[0] = Lo[0];
>    for( i = 1 ; i < BarCount ; i++ )
>    {
>       if(direction[j] == 0)
>       {
>          if(L[i] <= Lo[j] - Box)
>          {
>             diff = Lo[j] - L[i];
>             n= floor(diff/box);
>             Lo[j] = Lo[j] - n* box;
>          }
>
> else
>          {
>             if(H[i] >= Lo[j] + Reverse*Box)
>             {
>                diff = H[i] - Lo[j];
>                n = floor(diff/box);
>                j++;
>                direction[j] = 1;
>                Hi[j] = Lo[j-1] + n* Box;
>                Lo[j] = Lo[j-1] + Box;
>
>
>             }
>          }
>       }
>       else
>       {
>          if(H[i] >= Hi[j] + Box)
>          {
>             diff = H[i] - Hi[j];
>             n= floor(diff/box);
>             Hi[j] = Hi[j] + n*box;
>
>          }
>
> else
>          {
>             if(L[i] <= Hi[j] - Reverse * Box )
>             {
>                diff = Hi[j] - L[i];
>                n= floor(diff/box);
>                j++;
>                direction[j] = 0;
>                Lo[j] = Hi[j-1] - n*box;
>                Hi[j] = Hi[j-1] - Box;
>
>             }
>          }
>       }
>       if(direction[j])    pfline[i] = Hi[j]; else pfline[i] = Lo[j];
>
>       /* Calculate Signals
>       -------------------------------*/
>       if( j>1) // num Columns > 1
>       {
>          if(direction[j])
>          {
>
>             prevTop =  Hi[j-2];
>             bol = prevTop + box; // breakout Level
>             if (H[i] >=  bol && H[i-1] < bol) // cross High previous top
>             {
>
>                Buy[i] = 1;
>                BuyPrice[i] = bol;
>             }
>          }
>          else
>          {
>
>             prevBot = Lo[j-2];
>             bol = prevBot - box; // breakout Level
>             if (L[i] <=  bol && L[i-1] > bol) // cross Low previous bottom
>
>             {
>                Short[i] = 1;
>                ShortPrice[i] = bol;
>             }
>          }
>       }
>
>    }
>    // remove excess signals for the same condition
>    nochange = pfline == Ref(pfline,-1);
>    Buy = IIf( nochange, 0, Buy);
>    Short = IIf(nochange, 0, Short);
>
>
>
> Plot(C,"", IIf(Buy, colorBrightGreen,IIf(Short,colorRed, 39)),styleBar);
> Plot(pfline,"", colorYellow, styleDots|styleNoLine);
> PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,L);
> PlotShapes(Short*shapeDownArrow,colorRed,0,H);
>
> if( Status("action") == actionExplore)
> {
> Filter = Status("lastbarinrange");
> AddColumn(Buy, "Buy");
> AddColumn(Short, "Short");
> }
>
> //-----------------------------------End of Code
> --------------------------------------------------------
>
>
> onelkm wrote:
>
> Ok, Ive had a chance to look at your code and it does nice plots
> showing the buy and sell arrows. However, and I don't know why, I can't
> get it to produce buy sell results in a backtest. Possibly I am
> not "calling" the function pfsig(box) correctly. Can you help me
> understand how to produce actual buy and sells in automatic analysis?
>
> using the following code ( or several other variations ) converts your
> impulse buy and sell signal to a state function, buy it will not
> produce actual buy & sells!??
>
> Onbuy = Buy; 					
> Onsell = Sell;
> Onbuy = Flip(Buy,Sell);					
> Onsell = Flip(Sell,Buy);
>
> buy = onbuy;
> sell = onsell;		
>
> Thanks again
> Larry
>
>
> ------------------------------------
>
> Please note that this group is for discussion between users only.
>
> To get support from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
> Yahoo! Groups Links
>
>
>
>
>
>
> 

------------------------------------

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/