Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 946 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 6 of 7 1 2 3 4 5 6 7
Re: Z5 [Re: jcl] #437790
02/26/14 08:33
02/26/14 08:33
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Allright. So I include the line
set(LOGFILE);
in the script. I run it and look into the log folder of Zorro and what I get is:

[79: Fri 24.04. 00:00] 1.30081
[80: Mon 27.04. 00:00] 1.31242
[81: Tue 28.04. 00:00] 1.32141
[EUR/USD::L8101] Long 1@1.3025 Risk 10 at 00:00
[EUR/USD::L8101] Sell 1@1.3025: -0.17 at 00:00


and all trades similar to this one, like:

[EUR/USD::S8502] Short 1@1.3291 Risk 10 at 00:00
[EUR/USD::S8502] Cover 1@1.3291: -0.21 at 00:00

And this bothers me because I can't figure out what is doing:

1. It opens position at 00:00 in all of them, which shouldn't be according to the conditions requested. Though this may be understood if we consider that it refers to the bar 00:00

2. It gives risk US$ 10 or US$ 11 by default when there is no risk limit since there is no stop loss.

3. It closes position at 00:00 same day when it should close at 00:00 of next day, since ExitTime is set to 1.

Re: Z5 [Re: Mangal] #437792
02/26/14 08:56
02/26/14 08:56
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You enter your trades at midnight and immediately close them at the Open of the next bar. So of course you're always losing due to trading costs. If you wanted to close them at the Open of the day after tomorrow, you must wait 2 bars for exiting, so set ExitTime to 2. This may be a little confusing, but it's because a trade closes at the Open. If you don't set a stop, the risk is estimated and has no further meaning.

A script just does what you tell it to do, the task is to tell it the right thing.

Re: Z5 [Re: jcl] #437793
02/26/14 09:06
02/26/14 09:06
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
I get it. So it should be ExitTime = 2

Last edited by Mangal; 02/26/14 09:08.
Re: Z5 [Re: Mangal] #437978
03/04/14 04:14
03/04/14 04:14
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
I am trying a multitimeframe strategy and it doesn't work. Anyone can tell me where is the mistake in the following script?

function trenta()
{
TimeFrame = 1;

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;



if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var VlrL;

VlrL = B1[0] * percentage;



if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrL) enterShort();


Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;


}

function doscents()
{
TimeFrame = 8;

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;



if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var VlrL;

VlrL = B1[0] * percentage;



if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrL) enterShort();


Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 10;

}

function run()
{

set (PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
function trenta();
function doscents();
NumWFOCycles = 3;

}

The two functions used, individually they run fine but when trying to run them together, don't work.

Re: Z5 [Re: Mangal] #437982
03/04/14 07:55
03/04/14 07:55
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
User quiz: Who can see where the two functions interfere with each other? Solution tomorrow.

Re: Z5 [Re: jcl] #438028
03/05/14 08:28
03/05/14 08:28
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
No takers, so here the solution: You're setting trade parameters in function A for trades in function B, and vice versa - that is probably not what you intended.

Just as in real life, you must set stop, exit etc. _before_ entering a trade. When the trade is already entered, it's a little too late.

Re: Z5 [Re: jcl] #438072
03/06/14 10:58
03/06/14 10:58
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Sorry, jcl, I don't pick it up. Even if I cancel all B functions keeps without compiling. I put now the stop loss and target in front and paréntesis to separate. Is it now that the A functions for one Time Frame interfer with the A functions of the other TimeFrame?



function trenta()
{
Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;
TimeFrame = 1;
{
vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;

if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();
}
{
//vars B1 = series(priceLow(2));
//vars B2 = series(priceLow(1));
//vars B3 = series(price(0));
//var percentage = 0.001;
//var VlrL;

//VlrL = B1[0] * percentage;


//if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
//if (B1[0] > B2[0] and B3[0] > B1[0]+VlrL) enterShort();

}

}

function doscents()
{

Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 10;
TimeFrame = 8;
{

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var VlrH;

VlrH = A1[0] * percentage;

if (A1[0] < A2[0] and A3[0] < A1[0]-VlrH) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+VlrH) enterShort();
}

{
//vars B1 = series(priceLow(2));
//vars B2 = series(priceLow(1));
//vars B3 = series(price(0));
//var percentage = 0.001;
//var VlrL;

//VlrL = B1[0] * percentage;

//if (B1[0] < B2[0] and B3[0] < B1[0]-VlrL) enterLong();
//if (B1[0] > B2[0] and B3[0] > B1[0]+VlrL) enterShort();
}

}

function run()
{
set(PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
function trenta();
function doscents();
NumWFOCycles = 3;
}


When training it gives:


A1,A2,A3 Multitime trialF compiling................
WFO: A1,A2,A3 Multitime trialF 2011..2013

Re: Z5 [Re: Mangal] #438073
03/06/14 11:09
03/06/14 11:09
Joined: Jul 2013
Posts: 522
D
dusktrader Offline
User
dusktrader  Offline
User
D

Joined: Jul 2013
Posts: 522
Inside your run() function, I believe it's a syntax error to use the word "function" ... just get rid of that and then it will complete the Test.

Like this:
Code:
function run()
{
set(PARAMETERS);
BarPeriod = 30;
StartDate = 2011;
EndDate = 2013;
trenta();
doscents();
NumWFOCycles = 3;
}


Re: Z5 [Re: dusktrader] #438430
03/14/14 07:36
03/14/14 07:36
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
Thank you, dusktrader. Together with the changes in parenthesis and other indications from jcl, now it runs.

Re: Z5 [Re: Mangal] #442618
06/26/14 21:24
06/26/14 21:24
Joined: Sep 2013
Posts: 73
M
Mangal Offline OP
Junior Member
Mangal  Offline OP
Junior Member
M

Joined: Sep 2013
Posts: 73
I wouldn't put money on the following script because it gives negative results in different periods of time than 2011-2013. However for the sake to know if there is some mistake since it gives CAGR 3174%, can anyone have a look and see if there is mistake?

#include <profile.c>
function run()

{

BarPeriod = 60;
Stop = optimize(30,20,200)*PIP;
TakeProfit = optimize(500,150,700)*PIP;
ExitTime = 25;
NumWFOCycles = 4;
set(PARAMETERS+FACTORS);
Capital = 500;
StartDate = 2011;
EndDate = 2013;
set(LOGFILE);
plotTradeProfile(-100);

vars A1 = series(priceHigh(2));
vars A2 = series(priceHigh(1));
vars A3 = series(price(0));
var percentage = 0.001;
var Vlr;
Vlr = A1[0] * percentage;


Margin = OptimalF * Capital * sqrt(1 + ProfitClosed/Capital);
if (A1[0] < A2[0] and A3[0] < A1[0]-Vlr) enterLong();
if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();

vars B1 = series(priceLow(2));
vars B2 = series(priceLow(1));
vars B3 = series(price(0));
var percentage = 0.001;
var Vlr;
Vlr = B1[0] * percentage;



//if (B1[0] < B2[0] and B3[0] < B1[0]-Vlr) enterLong();
//if (A1[0] > A2[0] and A3[0] > A1[0]+Vlr) enterShort();


}

------------------------------------------------------
It gives the following result with two degres of freedom:

Read A1,2,3 60'_EURUSD_1.par A1,2,3 60'_EURUSD_2.par A1,2,3 60'_EURUSD_3.par
Factors stored in A1,2,3 60'_EURUSD.fac

A1,2,3 60' run..
Walk-Forward Test: A1,2,3 60' EUR/USD 2011..2013
Read A1,2,3 60'_EURUSD.fac A1,2,3 60'_EURUSD_1.par A1,2,3 60'_EURUSD_2.par A1,2,3 60'_EURUSD_3.par
Monte Carlo Analysis... Median AR 168%
Profit 18772$ MI 1494$ DD 5127$ Capital 2719$
Trades 326 Win 60% Avg +801.8p Bars 21
CAGR 3174% PF 1.53 SR 2.10 UI 11% R2 0.69 ok
Generate Chart - please wait... ok

Page 6 of 7 1 2 3 4 5 6 7

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1