Strange effect with asset() function

Posted By: worron

Strange effect with asset() function - 01/19/17 14:54

Hi,
When optimizing my script i faced the following weird issue:
The system shows different testing results depending on the way the currency pair is set. If it is set in concole form - one result, if it is set by calling asset() in script code - another result. As if in this case the price data is taken from some other source..(see screenshots attached). In both cases first i perform training and then testing. Could you explain what i do wrong?
Thanks in advance.

Attached picture Screenshot_1.png
Attached picture Screenshot_2.png
Posted By: trenki2

Re: Strange effect with asset() function - 01/20/17 10:22

It might be usefull if you could post a minimal example code that can reproduce this behaviour so anyone can test and verify. Without code its really hard.
Posted By: worron

Re: Strange effect with asset() function - 01/20/17 12:42

Hi, here is the code, which is simply the copy of workshop 7 with slight changes:

#include <profile.c>

function run()
{

MaxBars = 4320; //half a year
BarPeriod = 60; // H1
Weekend = 1; // don't merge Friday and Sunday bars
LookBack = 3; // only 3 bars needed
NumWFOCycles = 13;
Capital = 1000;
asset("USD/JPY");

set(RULES+FACTORS+TESTNOW);

if(Train) Hedge = 2; // for training, allow long + short

if(ReTrain) {
UpdateDays = -1;
SelectWFO = -1;
reset(FACTORS); // don't re-train factors
}
//
Margin = 0.5 * OptimalF * Capital * sqrt(1 + ProfitClosed/Capital);


if(adviseLong(PATTERN+2,0,
priceHigh(2),priceLow(2),priceClose(2),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(0),priceLow(0),priceClose(0)) > 50)
reverseLong(1);

if(adviseShort() > 40)
reverseShort(1);

}

If you comment the line with asset(...) and set the pair in list box of console you`ll receive different result.
Posted By: jcl

Re: Strange effect with asset() function - 01/20/17 12:57

The results will be most likely the same, but the training files have different names dependent on whether it's a portfolio system with "asset" calls, or not. So make sure that you're using the right files.
Posted By: worron

Re: Strange effect with asset() function - 01/26/17 14:02

Hi,
I encountered another issue with asset(). The following code does not cause error messages in train mode until asset() is called (if it is commented), and a pair is selected in the listbox. When called the message "Error 030 - Check lookback, settings, asset order" appear.

#include <profile.c>

function run()
{
StartDate = 2016;
EndDate = 2017;
BarPeriod = 60; // 1 day
LookBack = 0; //
NumWFOCycles = 10;

asset("AUD/USD");

set(RULES+PARAMETERS+TESTNOW);

if(Train) Hedge = 2;

Stop = 3*ATR(5);
Trail = optimize(13,8,55);
TrailLock = 1;
TrailSlope = 50;



LookBack = 3; // only 3 bars needed
if(adviseLong(PATTERN+2,0,
priceHigh(2),priceLow(2),priceClose(2),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(1),priceLow(1),priceClose(1),
priceHigh(0),priceLow(0),priceClose(0)) > 40)
reverseLong(1);

if(adviseShort() > 40)
reverseShort(1);

PlotWidth = 600;
PlotHeight1 = 300;
}

Here i set LookBack to 0 at the beginning to avoid problrms with calling ATR() and then change to 3 to set the number of candels for advise algorithm as mentioned in Workshop 7. Why that cease to work because of calling asse()?
Thanks in advance
Posted By: jcl

Re: Strange effect with asset() function - 01/27/17 14:28

Just as the error message says: You must set the lookback period before you can load the asset.
Posted By: worron

Re: Strange effect with asset() function - 02/02/17 09:37

Thanks! Got it finally)
Posted By: worron

Re: Strange effect with asset() function - 02/03/17 13:41

Hi, I hurried a bit to admit the issue solved. The problem is i can`t use in the same script ATR and adviseLong/Short because they need different LookBack values. In my case adviseLong/Short needs value 3 which is the number of bars in pattern, and ATR needs much more. First i change the value to suit ATR and after calling it i change the value to 3 for adviseLong/Short. But in this case Zorro returns error 030 (though LookBack-settings-asset sequense seems to be right).
Here is the code fragment (the whole text is similar to above posted):

LookBack = 500 (or 0);
NumWFOCycles = 10;

set(RULES+TESTNOW);
asset("EUR/USD");
Stop = 2*ATR(3);

LookBack = 3;
if(adviseLong(PATTERN+2,0,....

What is wrong here? How can i set a marketaware stop loss in case of using machine learning algo?
Posted By: jcl

Re: Strange effect with asset() function - 02/06/17 18:25

A variable can not be 3 and 500 at the same time, so use the higher value.
Posted By: worron

Re: Strange effect with asset() function - 02/08/17 09:53

And then how AdviseLongShort will know that it should use 3(in this case) bars pattern for analysis? Or is 3 const value?
Posted By: jcl

Re: Strange effect with asset() function - 02/10/17 12:45

It won't. It follows the principle: Better too much than too little.
© 2024 lite-C Forums