1 registered members (AbrahamR),
717
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
My Take on A Mega Script
#408047
09/24/12 10:06
09/24/12 10:06
|
liftoff
Unregistered
|
liftoff
Unregistered
|
I had plans on trading the Z1 on a microlot but due to complications from FXCM it seems it is not such a good idea at this time. So I have decided to combine a couple of scripts I know inside out. The script will include the trend and cycle trading scripts from the tutorials and hucks trend catcher.
// Workshop 6: Portfolio trading ///////////////////
function tradeTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *Trend = series(LowPass(Price,optimize(250,100,1000)));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and valley(Trend))
enterLong();
else if(strstr(Algo,":S") and peak(Trend))
enterShort();
}
function tradeCounterTrend()
{
var *Price = series(price());
var Threshold = optimize(1.0,0.5,2,0.1);
var *DomPeriod = series(DominantPeriod(Price,30));
var LowPeriod = LowPass(DomPeriod,500);
var *HP = series(HighPass(Price,LowPeriod*optimize(1,0.5,2)));
var *Signal = series(Fisher(HP,500));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and crossUnder(Signal,-Threshold))
enterLong();
else if(strstr(Algo,":S") and crossOver(Signal,Threshold))
enterShort();
}
function HuckTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *LP5 = series(LowPass(Price,5));
var *LP10 = series(LowPass(Price,optimize(10,6,20)));
var *RSI10 = series(RSI(Price,10));
Stop = optimize(5,1,10)*ATR(30);
static int crossed = 0;
if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;
if(strstr(Algo,":L") and (crossed > 0 && crossOver(RSI10,50)) {
enterLong();
crossed = 0;
} else if(strstr(Algo,":S") and (crossed < 0 && crossUnder(RSI10,50)) {
enterShort();
crossed = 0;
} else
crossed -= sign(crossed);
}
function run()
{
set(PARAMETERS+FACTORS+LOGFILE); // use optimized parameters and reinvestment factors
BarPeriod = 240; // 4 hour bars
LookBack = 500; // needed for Fisher()
NumWFOCycles = 8; // activate WFO
NumBarCycles = 4; // 4 times oversampling
if(ReTrain) {
UpdateDays = 30; // reload new price data from the server every 30 days
SelectWFO = -1; // select the last cycle for re-optimization
}
// portfolio loop
while(asset(loop("EUR/USD","USD/CHF","GBP/USD","AUD/USD","USD/CAD","USD/JPY","USD/NZD",)))
while(algo(loop("TRND:L","TRND:S","CNTR:L","CNTR:S","HuckTrend:L","HuckTrend:S")))
{
// set up the optimal margin
if(Train)
Lots = 1;
else if(strstr(Algo,":L") and OptimalFLong > 0) {
Lots = 1;
Margin = clamp((WinLong-LossLong) * OptimalFLong/2, 50, 10000);
} else if(strstr(Algo,":S") and OptimalFShort > 0) {
Lots = 1;
Margin = clamp((WinShort-LossShort) * OptimalFShort/2, 50, 10000);
} else
Lots = 0; // switch off trading
if(strstr(Algo,"TRND"))
tradeTrend();
else if(strstr(Algo,"CNTR"))
tradeCounterTrend();
}
PlotWidth = 1000;
PlotHeight1 = 320;
}
Script wont comply, can someone help me find the error?
Last edited by liftoff; 09/24/12 10:18.
|
|
|
Re: My Take on A Mega Script
[Re: jcl]
#408091
09/25/12 06:37
09/25/12 06:37
|
liftoff
Unregistered
|
liftoff
Unregistered
|
Will go over everything and try implementing it
|
|
|
Re: My Take on A Mega Script
[Re: ]
#408151
09/26/12 15:13
09/26/12 15:13
|
liftoff
Unregistered
|
liftoff
Unregistered
|
Tried implementing the concepts and error again.
// Workshop 6: Portfolio trading ///////////////////
function tradeTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *Trend = series(LowPass(Price,optimize(250,100,1000)));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and valley(Trend))
enterLong();
else if(strstr(Algo,":S") and peak(Trend))
enterShort();
}
function tradeCounterTrend()
{
var *Price = series(price());
var Threshold = optimize(1.0,0.5,2,0.1);
var *DomPeriod = series(DominantPeriod(Price,30));
var LowPeriod = LowPass(DomPeriod,500);
var *HP = series(HighPass(Price,LowPeriod*optimize(1,0.5,2)));
var *Signal = series(Fisher(HP,500));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and crossUnder(Signal,-Threshold))
enterLong();
else if(strstr(Algo,":S") and crossOver(Signal,Threshold))
enterShort();
}
function HuckTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *LP5 = series(LowPass(Price,5));
var *LP10 = series(LowPass(Price,optimize(10,6,20)));
var *RSI10 = series(RSI(Price,10));
Stop = optimize(5,1,10)*ATR(30);
int crossed = SkillLong[0]
if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;
if(strstr(Algo,":L") and (crossed > 0 && crossOver(RSI10,50)) {
enterLong();
crossed = 0;
} else if(strstr(Algo,":S") and (crossed < 0 && crossUnder(RSI10,50)) {
enterShort();
crossed = 0;
} else
SkillLong[0] = crossed;
}
function run()
{
set(PARAMETERS+FACTORS+LOGFILE); // use optimized parameters and reinvestment factors
BarPeriod = 240; // 4 hour bars
LookBack = 500; // needed for Fisher()
NumWFOCycles = 8; // activate WFO
NumBarCycles = 4; // 4 times oversampling
if(ReTrain) {
UpdateDays = 30; // reload new price data from the server every 30 days
SelectWFO = -1; // select the last cycle for re-optimization
}
// portfolio loop
while(asset(loop("EUR/USD","USD/CHF","GBP/USD","AUD/USD","USD/CAD","USD/JPY","USD/NZD",)))
while(algo(loop("TRND:L","TRND:S","CNTR:L","CNTR:S","HuckTrend:L","HuckTrend:S")))
{
// set up the optimal margin
if(Train)
Lots = 1;
else if(strstr(Algo,":L") and OptimalFLong > 0) {
Lots = 1;
Margin = clamp((WinLong-LossLong) * OptimalFLong/2, 50, 10000);
} else if(strstr(Algo,":S") and OptimalFShort > 0) {
Lots = 1;
Margin = clamp((WinShort-LossShort) * OptimalFShort/2, 50, 10000);
} else
Lots = 0; // switch off trading
if(strstr(Algo,"TRND"))
tradeTrend();
else if(strstr(Algo,"CNTR"))
tradeCounterTrend();
else if(strstr(Algo,"HuckTrend"))
HuckTrend();
}
PlotWidth = 1000;
PlotHeight1 = 320;
}
Last edited by liftoff; 09/26/12 15:22.
|
|
|
Re: My Take on A Mega Script
[Re: ]
#408535
10/03/12 13:27
10/03/12 13:27
|
liftoff
Unregistered
|
liftoff
Unregistered
|
JCL I am having a hard time getting this to work. Can you please help me out?
|
|
|
Re: My Take on A Mega Script
[Re: ]
#408824
10/08/12 09:18
10/08/12 09:18
|
Joined: Oct 2012
Posts: 22
Guiom
Newbie
|
Newbie
Joined: Oct 2012
Posts: 22
|
Tried implementing the concepts and error again. I think that's the code for what you wanted to do, you had a missing ";" after int crossed = SkillLong[0], missing declaration of Delay and an extra "," at the end of while(asset(loop...)) I only tested/optimized with EURUSD and USDCHF and it took almost an hour and the result isn't interesting: Profit 5934 MI 211 DD 6104 Capital 6861 Trades 218 Win 33% Avg +27.22 Bars 81 AR 37% PF 1.32 SR 0.47 UI 47.9% Error 35%
// Portfolio trading: Trend, Counter Trend and Huck Trend ///////////////////
function tradeTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *Trend = series(LowPass(Price,optimize(250,100,1000)));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and valley(Trend))
enterLong();
else if(strstr(Algo,":S") and peak(Trend))
enterShort();
}
function tradeCounterTrend()
{
var *Price = series(price());
var Threshold = optimize(1.0,0.5,2,0.1);
var *DomPeriod = series(DominantPeriod(Price,30));
var LowPeriod = LowPass(DomPeriod,500);
var *HP = series(HighPass(Price,LowPeriod*optimize(1,0.5,2)));
var *Signal = series(Fisher(HP,500));
Stop = optimize(2,1,10) * ATR(100);
if(strstr(Algo,":L") and crossUnder(Signal,-Threshold))
enterLong();
else if(strstr(Algo,":S") and crossOver(Signal,Threshold))
enterShort();
}
function HuckTrend()
{
TimeFrame = 1;
var *Price = series(price());
var *LP5 = series(LowPass(Price,5));
var *LP10 = series(LowPass(Price,optimize(10,6,20)));
var *RSI10 = series(RSI(Price,10));
Stop = optimize(5,1,10)*ATR(30);
int crossed = SkillLong[0];
int Delay = 3;
if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;
if(strstr(Algo,":L") and (crossed > 0 && crossOver(RSI10,50))) {
enterLong();
crossed = 0;
} else if(strstr(Algo,":S") and (crossed < 0 && crossUnder(RSI10,50))) {
enterShort();
crossed = 0;
} else
SkillLong[0] -= sign(crossed);
}
function run()
{
set(PARAMETERS+FACTORS+LOGFILE); // use optimized parameters and reinvestment factors
BarPeriod = 240; // 4 hour bars
LookBack = 500; // needed for Fisher()
NumWFOCycles = 8; // activate WFO
NumBarCycles = 4; // 4 times oversampling
if(ReTrain) {
UpdateDays = 30; // reload new price data from the server every 30 days
SelectWFO = -1; // select the last cycle for re-optimization
}
// portfolio loop
while(asset(loop("EUR/USD","USD/CHF")))
while(algo(loop("TRND:L","TRND:S","CNTR:L","CNTR:S","HuckTrend:L","HuckTrend:S")))
{
// set up the optimal margin
if(Train)
Lots = 1;
else if(strstr(Algo,":L") and OptimalFLong > 0) {
Lots = 1;
Margin = clamp((WinLong-LossLong) * OptimalFLong/2, 50, 10000);
} else if(strstr(Algo,":S") and OptimalFShort > 0) {
Lots = 1;
Margin = clamp((WinShort-LossShort) * OptimalFShort/2, 50, 10000);
} else
Lots = 0; // switch off trading
if(strstr(Algo,"TRND"))
tradeTrend();
else if(strstr(Algo,"CNTR"))
tradeCounterTrend();
else if(strstr(Algo,"HuckTrend"))
HuckTrend();
}
PlotWidth = 1000;
PlotHeight1 = 320;
}
|
|
|
Re: My Take on A Mega Script
[Re: Guiom]
#408835
10/08/12 13:46
10/08/12 13:46
|
liftoff
Unregistered
|
liftoff
Unregistered
|
Thank you mate. I did the corrections myself over the weekend and tested it... It didn't turn out too great. it was profitable but required too high a capital, I think something like 10,000.
|
|
|
|