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

[amibroker] Select the trading vehicle



PureBytes Links

Trading Reference Links

/*
SELECT THE VEHICLE TO TRADE A STOCK OR THE WHOLE MARKET 
WITH THE CONVEX-CONCAVE PRINCIPLE
*/

// 1. SMOOTHING PREPARATION
function IIR2( input, f0, f1, f2 )
{
  result[ 0 ] = input[ 0 ];result[ 1 ] = input[ 1 ]; 
  for( i = 2; i < BarCount; i++ )
  {
    result[ i ] = f0 * input[ i ] + f1 * result[ i - 1 ] + f2 * result
[ i - 2 ]; 
  }
  return result;
}

// 2. VEHICLE SELECTION
POPULATION=100;
NUM=Optimize("NUM",30,0,POPULATION,1);
list = GetCategorySymbols( categoryGroup, 254 );
symbol = StrExtract( list, NUM );
SetForeign(symbol);
C1=C;

// 3. SMOOTHING
k=0.45;
RD=IIR2( C1, 0.3, 1.2+K, -0.5-K);
y=RD;

// 4. THE CONVEXITY-CONCAVITY PRINCIPLE, by D. Tsokakis, Sept2003
t=1;
Convex=(y-Ref(y,-t))/t>=(y-Ref(y,-(t+1)))/(t+1);
Concave=NOT(Convex);
Ascending=y>=Ref(y,-1);
Descending=NOT(ascending);
Bullstart=Convex AND Ascending;
Bullend=Concave AND ascending;
Bearstart=Concave AND Descending;
Bearend=Convex AND Descending;

// 5. EXIT D BARS AFTER THE BULLISH INFLECTION POINT
DD=Optimize("DD",6,1,10,1);

// 6. THE TRADING RULES
RestorePriceArrays();
G1=Optimize("G1",1,0,1,1);
SetTradeDelays(1,G1,1,1);
Buy=BULLSTART AND Ref(BEAREND,-1);
BuyPrice=Open;
Sell=Ref(BULLEND AND Ref(BULLSTART,-1),-DD);
SellPrice=IIf(G1==0,Close,Open);
Filter=1;// CURRENT STOCK, N=1 LAST QUOTATIONS
AddTextColumn(SYMBOL,"SYMBOL");

// #30/7/1, 74/3/1, 7/6/1, 7/7/0, 91/8/0

AMZN data, for example, were good to trade QQQ the last year.
^NDX data gives satisfactory results, although there are much better 
candidates.
The optimization is time consuming, because of the GetCategorySymbols
( ) function.
Dimitris Tsokakis


------------------------ 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/