Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 177 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 5 1 2 3 4 5
Re: My Take on A Mega Script [Re: ] #411267
11/15/12 03:27
11/15/12 03:27
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
I have another question in regards to the SkillLong variables, I just cant seem to work this out. This following code was posted to store the crossing for Hucks strategy.

Quote:

while(asset(loop("EUR/USD","GBP/USD",USD/CHF"))) {

int crossed = SkillLong[0];
int Delay = 3;


if(crossOver(LP5,LP10))
crossed = Delay;
else if(crossUnder(LP5,LP10))
crossed = -Delay;

if(crossed > 0 && crossOver(RSI10,50))) {
enterLong();
crossed = 0;
} else if(crossed < 0 && crossUnder(RSI10,50))) {
enterShort();
crossed = 0;
} else
SkillLong[0] -= sign(crossed);
}


Is this code correct for storing the cross on multiple assets? Because it doesnt seem so. The reason I dont think it is because when I run my strategy with just one asset Im getting no problems, however when I run multiple assets Im getting errors. So running through it we create a variable called crossed which is stored with the SkillLong[0] variable? Then we store the delay into the crossed variable? So does then mean that Delay has been stored in crossed or SkillLong[0]? And then should we be checking if SkillLong[0] > 0 or crossed > 0? Im super confused about how this works if jcl or someone could go the theory to thisagain Id really appreciate it.

Re: My Take on A Mega Script [Re: TankWolf] #411271
11/15/12 05:20
11/15/12 05:20
Joined: Sep 2012
Posts: 99
T
TankWolf Offline
Junior Member
TankWolf  Offline
Junior Member
T

Joined: Sep 2012
Posts: 99
Ok so I think I have answered my own question, been playing around for hours today and I finally just got the SkillLong version to match the static int one.

Quote:

while(asset(loop("EUR/USD","GBP/USD",USD/CHF"))) {

int crossed = SkillLong[0];
int Delay = 3;


if(crossOver(LP5,LP10))
SkillLong[0] = Delay;
else if(crossUnder(LP5,LP10))
SkillLong[0] = -Delay;

if(SkillLong[0] > 0 && crossOver(RSI10,50))) {
enterLong();
crossed = 0;
SkillLong[0] = crossed;
} else if(SkillLong[0] < 0 && crossUnder(RSI10,50))) {
enterShort();
crossed = 0;
SkillLong[0] = crossed;
} else
SkillLong[0] -= sign(crossed);
}


Ok so this is how I understand the theory. We create a variable called crossed and store SkillLong[0] into it. Then we store the Delay into SkillLong[0]. Next we check if SkillLong[0] > or < than 0. If it is trade is entered long or short. Then we store 0 back into crosssed and then store crossed back into SkillLong[0]. I got the same results running this code vs the static int crossed = 0 method on one asset so I assume its right. Any feedback or advice still would very much be appreciated.

Re: My Take on A Mega Script [Re: TankWolf] #411285
11/15/12 09:50
11/15/12 09:50
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
This code seems to work, but it's not perfect - it looks too complicated. In programming, simpler and shorter is always better. I see no reason in your code for a "crossed" variable.

Code:
int Delay = 3;
if(crossOver(LP5,LP10))
  SkillLong[0] = Delay;
else if(crossUnder(LP5,LP10))
  SkillLong[0] = -Delay;

if(SkillLong[0] > 0 && crossOver(RSI10,50))) {
  enterLong();
  SkillLong[0] = 0;
} else if(SkillLong[0] < 0 && crossUnder(RSI10,50))) {
  enterShort();
  SkillLong[0] = 0;
} else
  SkillLong[0] -= sign(SkillLong[0]);



Here's an easier method without any SkillLong:

Code:
var *Signals = series(0);
if(crossOver(LP5,LP10))
  *Signals = 1;
else if(crossUnder(LP5,LP10))
  *Signals = -1;

if(Sum(Signals,3) > 0 && crossOver(RSI10,50)))
  enterLong();
else if(Sum(Signals,3) < 0 && crossUnder(RSI10,50)))
  enterShort();



This method to check if some signal happened within the last 3 bars is explained in Workshop 4:

http://zorro-trader.com/manual/en/tutorial_trade.htm

Re: My Take on A Mega Script [Re: jcl] #434517
12/20/13 07:09
12/20/13 07:09

L
liftoff
Unregistered
liftoff
Unregistered
L



Well, its been over a year and I keep asking myself what I could have achieved if I had stuck with this. Well there is nothing to asking questions with what could have been.
Good thing is I have had sometime to learn the basics of programming and I am ready to give this one more serious try.
I can see some folks here have really stuck with this and they are better at scripting with the C lite variant... I hope they ll hold my hand and help me along as I try and get this working.

I was thinking of a way I could learn and get people involved and interested in helping me. What I came up with is translating the work of Art of Automation from babypips. ( http://www.babypips.com/blogs/art-of-automation )
I will be working my way backwards from his latest post. Pick the latest system he has reviewed and try and automate it using zorro and I will do a test to see how it fairs. I believe that will give me a set of useful systems worth working on for the next couple of months to keep me busy and learning.
So what do you guys think, a good idea?

Re: My Take on A Mega Script [Re: ] #434523
12/20/13 10:30
12/20/13 10:30
Joined: Aug 2013
Posts: 124
D
DMB Offline
Member
DMB  Offline
Member
D

Joined: Aug 2013
Posts: 124
I like this babypips blog. Lots of complete system descriptions to tinker with. Maybe using signal processing theory and WFO will give us an edge. We'll I will work through some after I am finished my current projects and share what I come up with.

Re: My Take on A Mega Script [Re: DMB] #434549
12/20/13 17:58
12/20/13 17:58

L
liftoff
Unregistered
liftoff
Unregistered
L



Great to see you are on board. Based on the obstacles I faced the last time, I will definitely need all the help I can get.

Re: My Take on A Mega Script [Re: ] #434650
12/23/13 08:16
12/23/13 08:16

L
liftoff
Unregistered
liftoff
Unregistered
L



So after doing some reading over the weekend, I believe I need to spend sometime going over the tutorials and merging them with dusktraders Design Process Approach.
I will therefore be detailing what I do and how I do it in this thread. Any one who comes along later can read through it and learn from my progression.
I will be starting out with the Trend Following Edge.

Last edited by liftoff; 12/23/13 08:17.
Re: My Take on A Mega Script [Re: ] #434651
12/23/13 08:56
12/23/13 08:56
Joined: Aug 2013
Posts: 124
D
DMB Offline
Member
DMB  Offline
Member
D

Joined: Aug 2013
Posts: 124
I am going to have a go at the Three Little Pigs system. It appears to have enough complication with multiple time frames to teach me something, and it could be adapted to signal processing theory pretty easily in a version 2. Maybe I will be done in the next two weeks. If not, it will be delayed as per my time restrictions. But we'll see what happens.

Re: My Take on A Mega Script [Re: ] #434666
12/23/13 12:21
12/23/13 12:21

L
liftoff
Unregistered
liftoff
Unregistered
L



Step 1a: Goal: identify marginally-profitable edge
No WFO; No oversample; Simple Stop; Std entry

So in step one we test the trading logic naked to see if it has an edge. A straight backtest, no Oversampling, a simple stop with no defined appropriate logic. Std entry also follows the generic nature of the stop.

Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60;
	
//edge trading logic
  var  BarsPassed = optimize(1000,500,1500,10); // refers to the barspassed to the LowPass function.
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = 4*ATR(100); //simple stop level
    
  if(valley(Trend))
    enterLong(); //standard entry
  else if(peak(Trend))
    enterShort(); //standard entry
}



Code:
TF-e1 EUR/USD 2008..2013
Read TF-e1_EURUSD.par
Profit 438$  MI 6$  DD 138$  Capital 104$
Trades 464  Win 22%  Avg +12.4p  Bars 76
AR 73%  PF 1.41  SR 0.63  UI 20.0%  Error 38%



Running this simple code produces a return of over 73% meaning it has an edge or exploits some inefficiency in the market. I therefore proceed to 1b.

Step 1b: optimize the BarPeriod
I prefer longer time frames because it is my belief that they reduce errors in backtesting *belief based on no research*. I will let Zorro however test and tell me which barperiods produce the best results based on the current nature of the strategy.
I want to manually review the optimization chart for this step, so I hardcode the number of bars argument passed into the LowPass function, which I can do by getting the found-best values out of the Data/script.par file. The .par file tells me 810 is the best figure to use.

Training then with only 1 optimized parameter (the BarPeriod) will cause Zorro to produce the optimallity chart that I can use. I can see clearly from this chart that BarPeriod 60 is indeed the best of the bunch.
Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = optimize(60,60,1440,60);
	
	//edge trading logic
  var  BarsPassed = 810; //optimize(810,500,1500, 10) ... refers to the barspassed to the LowPass function.
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = 4*ATR(100); //simple stop level
    
  if(valley(Trend))
    enterLong(); //standard entry
  else if(peak(Trend))
    enterShort(); //standard entry
}


The graph does show that the system is profitable over a lot of time frames but the highest profit and number of trades is achieved when I use the one hour. So I will stick to that.


Step 1c: Goal: identify optimizable parameters
No WFO; No oversample; Simple Stop; Std entry
In this step, I want to focus on all the parameters that might play a role in the edge logic specifically. I need to try to keep a global view of my ultimate intent, which is to produce a multi-asset tradebot. The parameters that work for my current asset (I have started with EURUSD) may not be appropriate for other assets, so I want to give them the flexibility to move around for other asset personalities, and for market changes over time.

Therefore, ideally, I want to try to identify parameters that do affect core logic and give them flexibility to adjust (via Zorro's optimizer), but at the same time I want to constrain them based on a reasonable range that will be identified from the parameter optimization charts. Zorro will only produce an opt chart if I am optimizing 1 parameter, so I need to first hardcode the other parameters and then individually check each one to review its opt chart. With this strategy, the parameter that affects core logic is called BarPassed. The parameter should already be hardcoded from our last Step 1b, because we needed to do that in order to check that BarPeriod opt chart. So now I will hardcode BarPeriod back to 60 minutes, and select the first parameter to be optimized. (TIP: so that I don't forget what the original optimal parameter was, I set this value as the "start" value in the optimizer call.)

Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60; // optimize(60,60,1440,60);
	
	//edge trading logic
  var  BarsPassed = 820; // optimize(820,500,1500, 10);
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = 4*ATR(100); //simple stop level
    
  if(valley(Trend))
    enterLong(); //standard entry
  else if(peak(Trend))
    enterShort(); //standard entry
}





I initially set the "reasonable range" of the parameter BarsPassed to 750-1200, with the optimal value of 820 in the "start" position. Since this is the only logic parameter we are optimizing, I was not too comfortable putting such a narrow constraint on the parameter. I therefore left the range as it was initially.
I am done optimizing core-logic parameters, I now re-Train and re-Test. In multi-parameter Trains, Zorro only looks at one parameter at a time, and relies on the "start" value for all other parameters. Since we are optimizing only one parameter in this section mainly because of the nature of this code, we end up with basically the same returns.
Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60; // optimize(60,60,1440,60);
	
	//edge trading logic
  var  BarsPassed = 820; // optimize(820,500,1500, 10);
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = 4*ATR(100); //simple stop level
    
  if(valley(Trend))
    enterLong(); //standard entry
  else if(peak(Trend))
    enterShort(); //standard entry
}



Step 1d
No WFO; No oversample; Rev entry
In this step, I add the enhancements of reverseLong() and reverseShort() to replace the simple entries. These helper functions have special features that are desirable and explained in Workshop 5.

Also in this step, I perform the same optimization as in Step 1c, focusing specifically on the Stop. To find a good-working ATR value for this tradebot, I tested the following varieties before settling on ATR(200): 300, 200, 150, 100, 50, 25, 10. At this point I was thinking of just creating a new variable and setting it to pass optimized values to the
ATR function, but I was a bit hestitant as this might qualify as curve fitting. I will
look into the possibility when I improve at this.I settled on 200.
Here is the resultant code after all these adjustments:
Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60; // optimize(60,60,1440,60);
	
	//edge trading logic
  var  BarsPassed = 820; // optimize(820,500,1500, 10);
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = optimize(5,1,15,1,-5)*ATR(100);
    
  if(valley(Trend))
    //enterLong(); //standard entry
	   reverseLong(1);
  else if(peak(Trend))
    //enterShort(); //standard entry
		reverseShort(1);
}



Step 1e
Yes WFO; Yes oversample, Rev entry
In this step, I've added a variable to control maxtrades (a feature of the reverseLong() and reverseShort() helper functions). I can get an idea of how many trades the system might take from looking at the Performance Report on Step 1c. I will manually adjust the value up and down to determine how many trades are most appropriate.

Also in this step, I've added oversampling. This is described in the manual. I will use an oversampling value of 3.

Going by dusktraders findings, I will be using his if code to set oversampling on only during Test. To accommodate this, I add some code to make sure NumSampleCycles is never set during a Train, but always set during a Test.

Additionally, this step adds Rolling Walk-Forward-Optimization. I have added dusktradesrs code that warns me (and stops the Train) if it falls below a threshold of 30 trades per cycle.
Code:
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60; // optimize(60,60,1440,60);
	
	if(is(TESTMODE)) NumSampleCycles = 3; //oversampling on Test only, not Train
	if (Train) { RollLong = 0; RollShort = 0; } //help prevent asymmetry in parameters & profit factors
	DataSplit = 70; //70% training, 30% OOS test
	NumWFOCycles = 5;
	int maxtrades = 1;

	//require minimum 30 trades per WFO cycle or stop training
	static int LastWFOCycle = 0, LastNumTrades = 0;
	if(Train && (WFOCycle != LastWFOCycle) )
	{
		if(LastNumTrades > 0 and LastNumTrades < 30)
		{
			char tradecount[100];
			sprintf(tradecount,"Not enough trades per cycle: %d",LastNumTrades);
			quit(tradecount);
		}
		LastWFOCycle = WFOCycle;
	}
	LastNumTrades = NumWinTotal+NumLossTotal;
	
	//edge trading logic
  var  BarsPassed = 820; // optimize(820,500,1500, 10);
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = optimize(5,1,15,1,-5)*ATR(100);
    
  if(valley(Trend))
   	   reverseLong(1);
  else if(peak(Trend))
   		reverseShort(1);
}


In this step, I am looking for only a "reasonable positive return", because future adjustments will have a major impact on profitability. As you can see, I'm incrementally changing the composition of the strategy. With each change, I check the Test result to make sure nothing has gone haywire (and backtrack if it does).
Code:
Walk-Forward Test: TF-e1 EUR/USD 2008..2013
Read TF-e1_EURUSD_1.par TF-e1_EURUSD_2.par TF-e1_EURUSD_3.par TF-e1_EURUSD_4.par
Profit 238$  MI 5$  DD 113$  Capital 106$
Trades 271  Win 24%  Avg +11.5p  Bars 82
AR 60%  PF 1.43  SR 0.63  UI 21.7%  Error 43%


Off to go grab a meal. I will be back to go through the next processes in a couple of hours. The reason I am doing this on here is to get the more advanced coders and traders to point out shortfalls in my reasoning in how I am adapting dusktraders approach. So all inputs are welcome.

Re: My Take on A Mega Script [Re: ] #434680
12/23/13 20:22
12/23/13 20:22

L
liftoff
Unregistered
liftoff
Unregistered
L



Step 1f: Goal: identify modifiers that work well
Yes WFO; Yes oversample; Yes maxtrades; Yes all param optimizing; No emode

I believe the modifiers dusktrader have a potential of leading me to curve fit. I will therefore try to find economic or financial outlook reasons of why I think they should be applied before I include any of them. I will therefore pick them one after another and see if it should be included.

fridayClose()
Since this is a trend following strategy we hope to follow the trend as long as possible. So I will overlook this modifier,

hourOpen()
I dont think I will be needing this too.

todayOpenCombo()
I am a big believer in the markets being influenced by the big players to an extent. I therefore believe if trends are going to develop over the long term then the big boys are going to have to plan on how best to jump on it. A conspiracy nut over here, I know. I therefore see this tool as essential in reducing noise. I will therefore be including it.

todayCloseCombo()

marketOpenCombo()
As a conspiracy nut, I believe when the big boys are on a trade, they are ready to let it ride and more often than not this will be when they are in the market and when volume is there to ride. I will therefore be using this modifier.

Following dusktraders procedure:


1. DISABLE WFO temporarily (comment out the NumWFOCycles and DataSplit lines)

2. Hardcode all currently optimizable parameters. I do it this way, for example:
Code:
var TimeCycle = 64; //optimize(64,55,75,1,0);


3. Set an optimize on the first modifier to check, such as this:
Code:
int marketopencombo = optimize(1,1,15,1);


After viewing the optimality graph. I pick 3 as the default.
Code:
int dayopencombo = optimize(1,1,63,1);


After viewing the optimality graph, I pick 37 as the default.


I don't have any idea what the "estimated best start value" is yet, so I've used just 1. IMPORTANT: no other parameters should be set to optimize except the modifier at this stage.

4. Now tell Zorro to Train. It will recurse through each value of the modifier, as compared with the known-reasonable values that we hardcoded in all the other parameters. This produces a figure in the Zorro window after Train that can then become your "estimated best start value". I will now store this value in my script like this:
Code:
int marketopencombo = 15; //optimize(3,1,15,1);


Code:
int dayopencombo = 63; //optimize(37,1,63,1);



Shown here: 3 was the best value in that Train, so I'm recording that as part of my optimize statement. It is commented-out because my next step was to check the dayopecombo modifier. The value 63 in this case is the default "days" value for this particular modifier.

5. Go back and repeat for each optimizable modifier, starting from step #3. This will allow you to realize the "estimated best start value" for each optimizable modifier.

6. Don't forget to re-ENABLE the WFO that we disabled in step #1. Also re-ENABLE all core parameter and Stop/Trail optimization statements before proceeding.

So putting all this together... the strategy now looks like the one below, after identifying all the "estimated best start values" for each modifier. Rather than go by dusktraders route of having picking modifiers based on AR effect, I decided to use my understanding of the markets so I stick with these two modifiers.
Code:
function fridayClose(int fridayclose)
{
	//allows Friday trading up until NYSE 3pm; close trades and don't allow after this
	if(fridayclose && dow() == FRIDAY && lhour(ET) >= 15) 
		{
			exitLong("*");
			exitShort("*");
			return 1; //condition met; indicate no further trades
		}
	return 0; //condition not met; safe to take new trades
}
function hourOpen(int hourblockstart, int hourblockend)
{
	//blocks new open trades between selected hours
	//uses NYSE time, including DST
	if ( (lhour(ET) >= hourblockstart) && (lhour(ET) < hourblockend) )
		return 0; //between blocked hours, do not allow trade opens
	else
		return 1; //no conditions met, allow trades by default
}
function todayOpenCombo(var dayopencombo)
{
	//allows optimizer to specify the best combo of days for opens
	//bit position 0 = Monday
	//bit position 1 = Tuesday
	//bit position 2 = Wednesday
	//bit position 3 = Thursday
	//bit position 4 = Friday
	//bit position 5 = Sunday
	//given a combination #, the function will return whether
	//current dow() is in the combination

	int dayopencombobits = dayopencombo+.5; //truncate to rounded int
	int today = dow() - 1; //Mon is 0
	if (today == 6) today = 5; //bump Sun to 5 (no Sat, keep binary range 0-63)

	if (dayopencombobits & (1 << today)) return 1; //current dow() is in the combo
		else return 0; //current dow() not in combo, do not allow trade opens
}
function todayCloseCombo(var dayclosecombo)
{
	//allows optimizer to specify the best combo of days to close by NYSE 4pm
	//bit position 0 = Monday
	//bit position 1 = Tuesday
	//bit position 2 = Wednesday
	//bit position 3 = Thursday
	//bit position 4 = Friday
	//bit position 5 = Sunday
	//given a combination #, the function will determine if we are beyond
	//a combo close time, close all trades if necessary, and return 1
	//if no further trades allowed today

	int dayclosecombobits = dayclosecombo+.5; //truncate to rounded int
	int today = dow() - 1; //Mon is 0
	if (today == 6) today = 5; //bump Sun to 5 (no Sat, keep binary range 0-63)

	if ((dayclosecombobits & (1 << today)) && lhour(ET) >= 16) 
	{
		exitLong("*");
		exitShort("*");
		return 1; //current dow() is in the combo; indicate no further trades
	}
	else return 0; //current dow() not in combo, safe to take new trades
}
function marketOpenCombo(var marketopencombo)
{
	//allows optimizer to specify best markets to initiate trades
	//bit position 0 = New York 8am-5pm Eastern
	//bit position 1 = Sydney 5pm-2am Eastern
	//bit position 2 = Tokyo 7pm-4am Eastern
	//bit position 3 = London 3am-12pm Eastern
	//given a combination #, the function will determine if current time is within
	//a market part of the combination (returns 1 to allow trading if true)
	
	int marketcombobits = marketopencombo+.5; //truncate to rounded int
	if ( (lhour(ET) >=8) && (lhour(ET) <17) && (marketcombobits & (1 << 0)) ) return 1; //inside New York
	if ( (lhour(ET) >=17) || (lhour(ET) <2) && (marketcombobits & (1 << 1)) ) return 1; //inside Sydney
	if ( (lhour(ET) >=19) || (lhour(ET) <4) && (marketcombobits & (1 << 2)) ) return 1; //inside Tokyo
	if ( (lhour(ET) >=3) && (lhour(ET) <12) && (marketcombobits & (1 << 3)) ) return 1; //inside London
	return 0; //default - current market not in combination, don't allow trade opens
}
function checkModifiers()
{
	int reversedir = 0; //default normal trade direction (0) unless specified otherwise
	int fridayclose = 0; //enforce auto-close and no trades after NYSE 3pm Friday
	int hourblockstart = 0; //block trade opens beginning at NY hour
	int hourblockend = 0; //block trade opens ending at NY hour
	int dayopencombo = 63;//optimize(61,1,63,1); //combo of days to open; 63=every day
	int dayclosecombo = 0; //combo of days to close after NYSE 4pm; 0=none; 63=every day
	int marketopencombo = 15; //optimize(3,1,15,1); //combo of markets to allow trade opens; 15=every market

	if ( (!fridayClose(fridayclose) //close NYSE 3pm on Friday
		|| !todayCloseCombo(dayclosecombo) ) //close NYSE 4pm on selected days
		&& todayOpenCombo(dayopencombo) //open on selected days only
		&& marketOpenCombo(marketopencombo) //open during selected markets only
		&& hourOpen(hourblockstart,hourblockend) ) //open during selected hours only
			return 1; //ok to place new trades
	else
		return 0; //no trade, restricted by a modifier	
}
function run()
{
	//Parameters
  	set(PARAMETERS);
	StartDate = 20080101;
	EndDate = 20131220;
	BarPeriod = 60; // optimize(60,60,1440,60);
	int maxtrades = 1;
	
	if(is(TESTMODE)) NumSampleCycles = 3; //oversampling on Test only, not Train
	if (Train) { RollLong = 0; RollShort = 0; } //help prevent asymmetry in parameters & profit factors
	DataSplit = 70; //70% training, 30% OOS test
	NumWFOCycles = 5;
	int maxtrades = 1;

	//require minimum 30 trades per WFO cycle or stop training
	static int LastWFOCycle = 0, LastNumTrades = 0;
	if(Train && (WFOCycle != LastWFOCycle) )
	{
		if(LastNumTrades > 0 and LastNumTrades < 30)
		{
			char tradecount[100];
			sprintf(tradecount,"Not enough trades per cycle: %d",LastNumTrades);
			quit(tradecount);
		}
	LastWFOCycle = WFOCycle;
	}
	LastNumTrades = NumWinTotal+NumLossTotal;
	
	//edge trading logic
  var  BarsPassed = optimize(820,500,1500, 10);
  
  vars Price = series(price());
  vars Trend = series(LowPass(Price,BarsPassed));

  Stop = optimize(5,1,15,1,-5)*ATR(100);
   
  if (checkModifiers())
  {
  		if(valley(Trend))
   	   reverseLong(maxtrades);
 		else if(peak(Trend))
   		reverseShort(maxtrades);
  }
}


As you can see, I have not optimised any of the modifiers. I seem to have lost all the returns once I plugged in the modifiers. I will leave it as it is and investigate tomorrow. A really fun learning experience.

Page 2 of 5 1 2 3 4 5

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