1 registered members (AndrewAMD),
1,306
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
MatPed
OP
User
|
OP
User
Joined: Feb 2015
Posts: 652
Milano, Italy
|
Ok, its time to move forward. // 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: royal]
#449381
03/17/15 11:33
03/17/15 11:33
|
Joined: Feb 2015
Posts: 652 Milano, Italy
MatPed
OP
User
|
OP
User
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 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.
|
|
|
|