Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, exile, Ayumi), 1,085 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Simple Fat Strategy Build 004 [Re: MatPed] #449231
03/09/15 13:58
03/09/15 13:58
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Ok, its time to move forward.

Quote:

// Build 0004

// #define ASSETLOOP "USD/CHF", "EUR/USD", "GBP/USD", "USD/CAD", "AUD/USD", "USD/JPY", "XAU/USD", "XAG/USD", "NAS100", "SPX500", "GER30", "US30", "UK100" //FOREX SET
#define ASSETLOOP "EUR/USD", "GBP/USD", "USD/CAD", "AUD/USD", "USD/JPY", "XAU/USD", "XAG/USD" // No Stock
//#define ASSETLOOP "USD/CHF", "EUR/USD","USD/JPY","XAU/USD","SPX500"//MIN FOREX SET
//#define ASSETLOOP "EUR/USD" //test asset

//---- Global VAR ----
int myCapital = 0;
var myMargin = 0;
var comp = 0;
//--------------------

function setSlider()
{
myCapital = slider(1,2500,0,25000,"Capital"," Initial Capital"); //used for compounding calculation
myMargin = slider(2,50,0,500,"Margin"," Initial Margin"); // fixed or initial Margin
comp= slider(3,0,0,1,"Comp.", "0=Fixed Margin 1=Compound Margin");
}

function checkEquity()
{
// equity curve trading: switch to phantom mode when the equity
// curve goes down and is below its own lowpass filtered value

if(Train) { Lots = 1; return; } // no phantom trades in training mode
vars EquityCurve = series(ProfitClosed+ProfitOpen);
vars EquityLP = series(LowPass(EquityCurve,10));
if(EquityLP[0] < LowPass(EquityLP,100) && falling(EquityLP))
Lots = -1; // drawdown -> phantom trading
else
Lots = 1; // profitable -> normal trading
}

function enterFSLong()
{
if(comp == 1 && !is(TRAINMODE)) {
Margin = OptimalFLong * myMargin * sqrt(1 + max(0,(WinLong-LossLong)/myCapital));
enterLong();
} else {
Margin=myMargin;
enterLong();
}
}

function enterFSShort()
{
if(comp == 1 && !is(TRAINMODE)) {
Margin = OptimalFShort * myMargin * sqrt(1 + max(0,(WinShort-LossShort)/myCapital));
enterLong();
} else {
Margin=myMargin;
enterLong();
}
}

function CLSTR()
{
TimeFrame=24;

Stop = 2*ATR(14);
Trail = Stop;
TrailLock = 10;

checkEquity();

var dayL = optimize(40,10,80);
var dayS = optimize(40,10,80);

if (priceHigh() >= HH(dayL)) enterFSLong();
if (priceLow() <= LL(dayS)) enterFSShort();
}

function CNTR()
{
TimeFrame = 4;
Stop = optimize(4,2,8) * ATR(100);
Trail = 4*ATR(100);

vars Price = series(price());
vars Filtered = series(BandPass(Price,optimize(30,20,40),0.5));
vars Signal = series(Fisher(Filtered,500));
var Threshold = optimize(1,0.5,1.5,0.1);

checkEquity();

if(crossUnder(Signal,-Threshold)) enterFSLong();
else if(crossOver(Signal,Threshold)) enterFSShort();
}

function TRND()
{
TimeFrame = 1;
Stop = optimize(4,2,8) * ATR(100);
Trail = 0;

vars Price = series(price());
vars Trend = series(LowPass(Price,optimize(500,300,800)));

checkEquity();

if(valley(Trend)) enterFSLong();
else if(peak(Trend)) enterFSShort();
}

function run()
{
set(PARAMETERS+FACTORS); // generate and use optimized parameters and factors

BarPeriod = 60; // 1 hour bars
LookBack = 2500; // needed for Fisher()
NumWFOCycles = 6; // activate WFO

StartDate = 2009;
EndDate = 2014;
Hedge=5;

if(ReTrain) {
UpdateDays = -1; // update price data from the server
SelectWFO = -1; // select the last cycle for re-optimization
reset(FACTORS); // don't generate factors when re-training
}
NumWFOCycles = 6; // activate WFO

setSlider();

// portfolio loop
while(asset(loop(ASSETLOOP)))
while(algo(loop("TRND","CNTR","CLSTR")))
{
if(Algo == "TRND")
TRND();

if(Algo == "CNTR")
CNTR();

if(Algo == "CLSTR")
CLSTR();
}

PlotWidth = 700;
PlotHeight1 = 400;
//ColorUp = ColorDn = ColorWin = ColorLoss = 0; // don't plot candles and trades
//set(TESTNOW+PLOTNOW);
}


mainly no change in the trading strategy, re-arranged the run function, some service functions amd prepared the slider in order to be execute in demo with the possibility to change some money Management parameters. I have added anothe assets set because my broker does not have the same feed as the Zorro's.

Strategies, Broker (Assets/minimal lot size/commission structure) are the nexy open question. I have to study...

Last edited by MatPed; 03/09/15 14:00.
Re: Simple Fat Strategy Build 004 [Re: MatPed] #449261
03/10/15 21:46
03/10/15 21:46
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline
Newbie
forexcoder  Offline
Newbie

Joined: Feb 2015
Posts: 45
Italy
Great idea MatPed! I'll try to help you as I can!!!

Re: Simple Fat Strategy Build 004 [Re: forexcoder] #449347
03/16/15 11:05
03/16/15 11:05
Joined: Jul 2013
Posts: 75
R
royal Offline
Junior Member
royal  Offline
Junior Member
R

Joined: Jul 2013
Posts: 75
Hi MatPed, could you upload your PAR and FAC files please? Something seems to go wrong in my WFO frown

Re: Simple Fat Strategy Build 004 [Re: royal] #449381
03/17/15 11:33
03/17/15 11:33
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline OP
User
MatPed  Offline OP
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Hi, I have re-started the project. As you read I am focusing on money management first i.e. develop a skeleton run function on witch insert the different strategies.

Unfortunately the approach fixed money risk has revealed to be not the best choice on portfolio trading. So I had to re-start from scratch.

What I discovered reading for the 10th times laugh the Z system manual is that you can compound the z systems gains too. You have to do it by hand but with a simple excel it's easy. Just few minutes a day/week. So I guess I will use the same z's developer approach for money management.
At this time it seems that the only edge of FS will be the opportunity to add assets to the TS and, on top of this, I have seen basically no contribution from the community. So why continue the project?

Anyway as soon I will come up with a trusted version i will post it for your reference.

Ciao

Last edited by MatPed; 03/17/15 11:33.
Re: Simple Fat Strategy Build 004 [Re: MatPed] #449476
03/21/15 13:18
03/21/15 13:18
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline
Newbie
forexcoder  Offline
Newbie

Joined: Feb 2015
Posts: 45
Italy
I tested FAT Build 0004 and the resul are this:
alk-Forward Test Fat Strategy_004 portfolio - performance report

Bar period 1 hour
Simulation period 02.06.2009-31.12.2014
Test period 16.05.2012-31.12.2014
Lookback time 2500 bars (21 weeks)
WFO test cycles 5 x 3174 bars (27 weeks)
Training cycles 6 x 17986 bars (155 weeks)
Monte Carlo cycles 200
Assumed slippage 10.0 sec

Gross win/loss 190404$ / -252101$ (-279826p)
Virtual win/loss 112057$ / -173973$
Average profit -23487$/year, -1957$/month, -90$/day
Max drawdown -118305$ -192% (MAE -166879$ -270%)
Total down time 90% (TAE 99%)
Max down time 99 weeks from Dec 2012
Largest margin 10927$
Trade volume 13958090$ (5313615$/year)
Transaction costs -7825$ spr, 637$ slp, -7595$ rol, -583$ com
Capital required 137355$

Number of trades 2433 (927/year, 18/week, 4/day)
Percent winning 40%
Max win/loss 2756$ / -6248$
Avg trade profit -25$ -115.0p (+879.4p / -788.0p)
Avg trade slippage 0.26$ 1.2p (+4.6p / -1.1p)
Avg trade bars 774 (+1199 / -477)
Max trade bars 11281 (97 weeks)
Time in market 11867%
Max open trades 199
Max loss streak 91 (uncorrelated 16)

Annual return -17%
Profit factor 0.76 (PRR 0.71)
Sharpe ratio -0.39
Kelly criterion -0.87
R2 coefficient 0.508
Ulcer index 255.2%
Prediction error 15%

Confidence level AR DDMax Capital

10% -31% 61760$ 76928$
20% -26% 75553$ 91668$
30% -23% 84277$ 100991$
40% -21% 96670$ 114235$
50% -18% 109829$ 128298$
60% -16% 126905$ 146546$
70% -14% 151835$ 173188$
80% -12% 171483$ 194186$
90% -11% 192618$ 216771$
95% -10% 209747$ 235077$
100% -6% 383807$ 421089$

Portfolio analysis OptF ProF Win/Loss Wgt% Cycles

AUD/USD avg .000 0.27 144/509 26.2 X\\\\
EUR/USD avg .001 0.45 120/458 16.6 XXXX\
GBP/USD avg .008 0.66 147/387 9.1 \\\XX
USD/CAD avg .113 4.99 225/300 -58.3 \XXX/
USD/JPY avg .118 5.72 169/356 -62.6 \XX\/
XAG/USD avg .000 0.27 119/392 188.0 X\\\\
XAU/USD avg .000 0.29 66/387 31.7 X\\\\

CLSTR avg .015 0.66 463/568 46.5 XXXXX
CNTR avg .044 0.81 342/297 14.6 XXXXX
TRND avg .060 0.58 185/1924 89.6 \\\\X

AUD/USD:CLSTR .000 0.33 69/146 12.0 \\\\\
AUD/USD:CLSTR:L .000 0.33 69/146 12.0 \\\\\
AUD/USD:CLSTR:S .000 ---- 0/0 -0.0 .....
AUD/USD:CNTR .000 0.63 60/56 2.1 /\\\\
AUD/USD:CNTR:L .000 0.63 60/56 2.1 /\\\\
AUD/USD:CNTR:S .000 ---- 0/0 -0.0 .....
AUD/USD:TRND .000 0.02 15/307 12.0 \\\\\
AUD/USD:TRND:L .000 0.02 15/307 12.0 \\\\\
AUD/USD:TRND:S .000 ---- 0/0 -0.0 .....
EUR/USD:CLSTR .000 0.75 83/109 3.3 ///\\
EUR/USD:CLSTR:L .000 0.75 83/109 3.3 ///\\
EUR/USD:CLSTR:S .000 ---- 0/0 -0.0 .....
EUR/USD:CNTR .010 1.04 37/59 -0.1 /\//\
EUR/USD:CNTR:L .010 1.04 37/59 -0.1 /\//\
EUR/USD:CNTR:S .000 ---- 0/0 -0.0 .....
EUR/USD:TRND .000 0.00 0/290 13.4 \\\\\
EUR/USD:TRND:L .000 0.00 0/290 13.4 \\\\\
EUR/USD:TRND:S .000 ---- 0/0 -0.0 .....
GBP/USD:CLSTR .000 0.97 70/87 0.3 \\\\/
GBP/USD:CLSTR:L .000 0.97 70/87 0.3 \\\\/
GBP/USD:CLSTR:S .000 ---- 0/0 -0.0 .....
GBP/USD:CNTR .060 1.44 62/42 -2.2 \\\//
GBP/USD:CNTR:L .060 1.44 62/42 -2.2 \\\//
GBP/USD:CNTR:S .000 ---- 0/0 -0.0 .....
GBP/USD:TRND .000 0.11 15/258 11.1 \\\\\
GBP/USD:TRND:L .000 0.11 15/258 11.1 \\\\\
GBP/USD:TRND:S .000 ---- 0/0 -0.0 .....
USD/CAD:CLSTR .000 0.87 64/60 0.6 \\\//
USD/CAD:CLSTR:L .000 0.87 64/60 0.6 \\\//
USD/CAD:CLSTR:S .000 ---- 0/0 -0.0 .....
USD/CAD:CNTR .261 1.63 49/33 -1.0 \//\/
USD/CAD:CNTR:L .261 1.63 49/33 -1.0 \//\/
USD/CAD:CNTR:S .000 ---- 0/0 -0.0 .....
USD/CAD:TRND .529 7.74 112/207 -57.9 \\\\/
USD/CAD:TRND:L .529 7.74 112/207 -57.9 \\\\/
USD/CAD:TRND:S .000 ---- 0/0 -0.0 .....
USD/JPY:CLSTR .221 3.01 70/38 -8.3 \//\/
USD/JPY:CLSTR:L .221 3.01 70/38 -8.3 \//\/
USD/JPY:CLSTR:S .000 ---- 0/0 -0.0 .....
USD/JPY:CNTR .285 4.31 56/30 -6.4 \/\\/
USD/JPY:CNTR:L .285 4.31 56/30 -6.4 \/\\/
USD/JPY:CNTR:S .000 ---- 0/0 -0.0 .....
USD/JPY:TRND .323 7.66 43/288 -48.0 \\\\/
USD/JPY:TRND:L .323 7.66 43/288 -48.0 \\\\/
USD/JPY:TRND:S .000 ---- 0/0 -0.0 .....
XAG/USD:CLSTR .000 0.54 66/87 34.7 /\\\\
XAG/USD:CLSTR:L .000 0.54 66/87 34.7 /\\\\
XAG/USD:CLSTR:S .000 ---- 0/0 -0.0 .....
XAG/USD:CNTR .000 0.63 53/43 17.6 /\\\\
XAG/USD:CNTR:L .000 0.63 53/43 17.6 /\\\\
XAG/USD:CNTR:S .000 ---- 0/0 -0.0 .....
XAG/USD:TRND .000 0.00 0/262 135.6 \\\\\
XAG/USD:TRND:L .000 0.00 0/262 135.6 \\\\\
XAG/USD:TRND:S .000 ---- 0/0 -0.0 .....
XAU/USD:CLSTR .000 0.66 41/41 3.9 /\\\\
XAU/USD:CLSTR:L .000 0.66 41/41 3.9 /\\\\
XAU/USD:CLSTR:S .000 ---- 0/0 -0.0 .....
XAU/USD:CNTR .000 0.54 25/34 4.5 /\\\\
XAU/USD:CNTR:L .000 0.54 25/34 4.5 /\\\\
XAU/USD:CNTR:S .000 ---- 0/0 -0.0 .....
XAU/USD:TRND .000 0.00 0/312 23.3 \\\\\
XAU/USD:TRND:L .000 0.00 0/312 23.3 \\\\\
XAU/USD:TRND:S .000 ---- 0/0 -0.0 .....

Re: Simple Fat Strategy Build 004 [Re: forexcoder] #449477
03/21/15 13:19
03/21/15 13:19
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline
Newbie
forexcoder  Offline
Newbie

Joined: Feb 2015
Posts: 45
Italy
Is there something wrong in my test?

Re: Simple Fat Strategy [Re: MatPed] #449478
03/21/15 13:24
03/21/15 13:24
Joined: Feb 2015
Posts: 45
Italy
forexcoder Offline
Newbie
forexcoder  Offline
Newbie

Joined: Feb 2015
Posts: 45
Italy
This is the chart.

Attached Files Zorro_FAT.JPG
Re: Simple Fat Strategy [Re: forexcoder] #449631
03/26/15 14:43
03/26/15 14:43
Joined: Feb 2014
Posts: 181
R
RTG Offline
Member
RTG  Offline
Member
R

Joined: Feb 2014
Posts: 181
Ive attempted to replicate the triangle breakout system outline in the book but could not get it to work in the same way.

Page 2 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1