PureBytes Links
Trading Reference Links
|
I'm able to copy the code using Edit -> Select All. I was just
wondering if anybody has any additional
code/Interpretation/modifications/improvements to this expectation
analysis code...
TIA
rgds, Pal
--- In amibroker@xxxxxxxxxxxxxxx, "palsanand" <palsanand@xxxx> wrote:
> Hi All,
>
> I'm tryin to do an Expectation Analysis describe by
>
> http://www.amibroker.net/3rdparty/IntroToAtc.pdf pages 29-32
>
> I'm not able to copy and paste the code from this pdf file. I was
> wondering if anybody has this code. I'm trying to add to the
> following code:
>
> /* your trading system functions here */
> ...
> /*Buy and Sell rules here */
>
> /*Buy = Cover = ...;
>
> Sell = Short = ...; */
>
> Buy = ExRem(Buy,Sell);
>
> Sell = ExRem(Sell,Buy);
>
> Short = ExRem(Short,Cover);
>
> Cover = ExRem(Cover,Short);
>
> AddToComposite( Equity(), "~CompositeEquity", "X" ); //Filter for
> scan set to a list, e.g., list0
>
> shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
> PlotShapes(IIf
> (Buy,shapeUpArrow,shapeNone) ,colorBrightGreen,0,Graph0,-15);
> PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,Graph0,-
15);
> PlotGrid(1);
> PlotGrid(-1);
> GraphXSpace=10;
>
> ApplyStop(stopTypeTrailing, stopModePoint, 3*ATR(14), True,
> True ); /* Chandelier Exit - Actually I use 3BSMA stop but cant use
> this function for that */
>
> Equity(1); // THIS EVALUATES STOPS
> Title = Name() + ": " + Date() + " Open " + WriteVal
> (O,1.4) + " Hi " +WriteVal(H,1.4) + " Lo "
> +WriteVal(L,1.4) + " Close " + WriteVal(C,1.4);
>
> /* the following line uses Flip function to get "1" after the buy
> signal and reset it back to "0" after sell appears. */
>
> in_trade = Flip( Buy, Sell );
>
> AddToComposite( in_trade, "~OpenPosCount", "V" );
>
> /* We use "~OpenPosCount" artificial ticker to store the results.
> Again we should run just Scan of the formula AND
the "~OpenPosCount"
> ticker would become available.
>
> Use */
>
> Graph0 = Foreign( "~OpenPosCount", "V");
>
> /* in Indicator Builder after running the back-test to see the
chart
> of the number of Open positions of your system. */
>
> e = Equity(1); // THIS EVALUATES STOPS
>
> tradeend1 = Sell;
> tradeend2 = Cover;
>
> profit1 = e - ValueWhen( Buy, e );
> profit2 = e - ValueWhen( Short, e);
>
> endprofit1 = IIf( tradeend1 , profit1, 0 );
> endprofit2 = IIf( tradeend2 , profit2, 0 );
>
> LosingLongTrades = LastValue( Cum( endprofit1 < 0 ) );
> LosingShortTrades = LastValue( Cum( endprofit2 < 0 ) );
> WiningLongTrades = LastValue( Cum( endprofit1 > 0 ) );
> WiningShortTrades = LastValue( Cum( endprofit2 > 0 ) );
> TotalLongTrades = LastValue( Cum( tradeend1 ) );
> TotalShortTrades = LastValue( Cum( tradeend2 ) );
>
>
> AddColumn( LosingLongTrades, "Losing Long trades", 1 );
> AddColumn( WiningLongTrades, "Wining Long trades", 1 );
> AddColumn( TotalLongTrades, "Total Long trades", 1 );
> AddColumn( LosingShortTrades, "Losing Short trades", 1 );
> AddColumn( WiningShortTrades, "Wining Short trades", 1 );
> AddColumn( TotalShortTrades, "Total Short trades", 1 );
>
>
> Filter = Status("lastbarinrange");
>
> // now we will count the number of
> // count trades winning in given $ ranges
> NumRanges = 25; // number of ranges to generate
> RangeSize = 100; // controls $ size of the range
>
> for( i = 0; i < NumRanges; i++ )
> {
> rangestart = i * RangeSize;
> rangeend = (i+1)*RangeSize;
> if( i == NumRanges - 1 ) rangeend = 999999;
> AddColumn(
> LastValue( 100* Cum( endprofit1 > rangestart AND endprofit1 <
> rangeend ) /TotalLongTrades ),
> "% with profit " + rangestart + ".." + rangeend );
> AddColumn(
> LastValue( 100* Cum( endprofit2 > rangestart AND endprofit2 <
> rangeend ) /TotalShortTrades ),
> "% with profit " + rangestart + ".." + rangeend );
>
> }
>
> for( i = 0; i < NumRanges; i++ )
> {
> rangestart = (-i - 1 ) * RangeSize;
> rangeend = -i*RangeSize;
> if( i == NumRanges - 1 ) rangestart = -999999;
> AddColumn(
> LastValue( 100* Cum( endprofit1 > rangestart AND endprofit1 <
> rangeend ) /TotalLongTrades ),
> " % with loss " + rangeend + ".." + rangestart );
> AddColumn(
> LastValue( 100* Cum( endprofit2 > rangestart AND endprofit2 <
> rangeend ) /TotalShortTrades ),
> " % with loss " + rangeend + ".." + rangestart );
>
> }
>
> TIA
> rgds, pal
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|