Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: CoinToss ver 1
Author/Uploader: Nilesh - (email hidden)
Date/Time added: 2009-01-27 07:26:26
Origin: probability textbook
Keywords: probability coin taleb thorp poundstone victor
Level: semi-advanced
Flags: system

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

Coin Toss model , it has nothing to do with Technical OR Fundamental Analysis

It has nothing to do with entry or exit rules.
Here One books profits and losses at a predefined percent.

Formula:

_SECTION_BEGIN("ct1");
/*
	Coin Toss model , it has nothing to do with Technical OR Fundamental Analysis
	
	It has nothing to do with entry or exit rules.
	Here One books profits and losses at a predefined percent.
	

	This Model was Inspired by many authors
	---------------------------------------
	a)Victor Sperandeo	:- Methods of Wall Street Master
	b)Nasim Taleb			:-	Fooled by Randomness
	c)Ed Thorp				:-	#Beat the Market		 #Beat the Dealer
	d)William Poundstone	:-	Fortune's Formula

	thanks for AB codes and concepts by
	a)Dimitris Tsokakis
	b)Herman van den Bergen
	c)Anthony Faragasso
	d)Graham Kavanagh	
	and countless good souls.

	Hearty thanks to
	
	"Tomasz Janeczko" for AB Platform.


	Disclaimer : any error in code or concept here belongs to me.
	This Amibroker Script is for educational purposes only. I cannot guarantee 
it's accuracy nor take any responsibility for your use of it.  Use at your own
risk.


*/
SetOption("InitialEquity", 100000);
SetOption("CommissionMode", 1); //% per trade
SetOption("CommissionAmount", 0.05); // commission in BPS per leg
SetOption("MarginRequirement", 10);
SetOption("UsePrevBarEquityForPosSizing", 1);
SetOption("AllowSameBarExit",1);									// Sq off Daily
SetOption("PriceBoundChecking",0);
SetTradeDelays( 0, 0, 0, 0 );
RoundLotSize=50;  													//Change this according to your needs [i did it
for Nifty].

posSizeX = Optimize("posSizeX", 50, 10, 100, 10);

winloss = Optimize("winloss", 50, 10, 90, 2); 					// Assumed probability of
winning, higher the better

winPercent = Optimize("winPercent", 1, 0.25, 2, 0.25);  		// higher the better
lossPercent = winPercent/2; 										//Optimize("lossPercent", 0.5, 0.25, 10,
0.25); 	// lower the better

iterations = Optimize("iterations",1,1,20,1); 					// to test randomness at
different levels, not used in any equation.

HitRatio = mtRandomA() < (winloss/100); 							//hit ratio


PositionSize = -(posSizeX); 										//exposure of capital

Buy = Day() != Ref(Day(), -1 );									// trade daily
Sell = Buy;															// Sq off Daily

Short=Cover=0;

BuyPrice=100;  // to make it generic from EURUSD to Hangseng to Bovespa

//if you win you get winPercent, if you loose you loose lossPercent
SellPrice=IIf(HitRatio,BuyPrice*(1+(winPercent/100)),BuyPrice*(1-(lossPercent/100))
 ); 

Plot(Equity(),"Equity : " , 1,1);
RequestTimedRefresh(1);

SetChartBkGradientFill( ParamColor("BgTop",
colorWhite),ParamColor("BgBottom",colorViolet));
_SECTION_END();

Comments:


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM