Does anyone know how to use the monte carlo analysis in AB?
runs = Param("# runs", 1000, 0, 10000, 500);
monteCarlo = Param("monteCarlo", 0, 0, 1.00, 0.01);
if(monteCarlo)
Optimize("monteCarlo", 1, 1, runs, 1);
if(monteCarlo)
Buy = Buy AND mtRandom() >= monteCarlo;
else
Buy = Buy;
I use the code shown below for Monte Carlo analysis. I usually set the monte carlo figure to 0.5. ie. there is a 50% chance I may miss this trade or I won't like the buy signal generated for whatever reason. You may set the figure lower if you were more confident about your system and your ability to place all the trades it produces. Regardless, a graph of CAR vs MaxSysDD (for example) should ideally show a tight spread of results, if it doesn't perhaps your system is not as robust as you first thought.
Mark
Hi Sam --
See if this is what you want --
// ExportRange.afl
Filter = 1;
Range = H - L;
AddColumn(Range, "Range", 10.2);
// End of afl program
Here is how to use it -----------------
Select the category of symbols you want to check -- a watchlist, for example.
Select the date range you want to check -- n last days = 1, for example
Click Explore
The results will be displayed in the results window.
Click File > Export, select the output file name and path.
The output file is a csv file with three columns -- Ticker, Date, Range.
Hope this helps,
Howard
To only go long when EMA 4 is above EMA 9 (we'll call this 'x') and 'x' must be above the EMA 18
Buy = ( EMA( Close , 4 ) > EMA( Close , 9 ) ) > EMA( Close , 18 ) > Close
ST,
The EMA crossover conditions that you specified does not make sense.
As an example, the condition that you call 'x', EMA( Close , 4 ) > EMA( Close , 9 ) is OK and will return a boolean result, ie a 1 for true or 0 for false. With only 2 possible results for x, it does not make sense to then have a condition that says x > EMA( Close , 18 ).
Unfortunately the charts that you attached is not sufficiently clear (well for me anyway) on how these crossovers work. Happy to help but you'll need to get it clearer in your mind as to precisely you want
settradedelays( 1, 1, 1, 1 );
gapclosingfromupopen =Open > Ref(H,-1) AND C > Ref(L,-1) AND C < Ref(H,-1);
gapclosingfromdownopen=Open < Ref(L,-1) AND C > Ref(L,-1) AND C < Ref(H,-1);
Buy = EMA( Close , 4 ) > EMA( Close , 9 ) and EMA( Close , 9 ) > EMA( Close , 18 ) and gapclosingfromdownopen;
buyprice = O;
Sell = buy;
sellprice = C;
Short = EMA( Close , 4 ) < EMA( Close , 9 ) and EMA( Close , 9 ) < EMA( Close , 18 ) and gapclosingfromupopen;
Shortprice = O;
Cover = short;
Shortprice = C;
Example:graphxspace defines percentage extra space added at the top and the bottom of the chart
zoom=Param("zoom",5,5,50,5);
GraphXSpace=zoom;
You may wish to make it adjustable via the parameters box.
Insert into your indicator formula, open the parameters box and adjust as required.Code:zoom=Param("zoom",5,5,50,5); GraphXSpace=zoom;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?