Lindencourt Daily System

Posted By: hughbriss

Lindencourt Daily System - 10/31/12 10:23

This has to be my most sophisticated script yet (which is not saying much). It trades the Lindencourt Daily system which can be found here...

http://www.lindencourt.net/daily_fx_system.html

I had the problem that the system trades a stoch cross up above the 100 ema but also waits for the stochs to be above the 20 level or reversed for a down trend. I got round this by first determining whether the cross was valid, ie above the 100 ema and stochs crossed up. Then I determined that if there was no trade open and the stochs were in the right direction and the stochs were over 20 then enter long. Similar for short.

There is one thing that the script does not do which is to move to break even after 100 pips. I don't know what difference this would make to the system. In my manual trading I have found that half the time moving to break even doesn't really improve your returns but that's part of the system so to give it a fair go we should try to code this exactly.

I wonder if JCL or anyone else would be able to tell me how to move to break even afer a certain pip amount? (also how to do the same with ATR which makes more sense to me).

Here is the code anyway, it returns about 20% a year, nothing to write home about.

Code:
function run()
{    
     StartDate = 2006;
     BarPeriod = 1440;
               
     while(asset(loop("EUR/USD","AUD/USD","GBP/USD","USD/CHF","USD/JPY","USD/CAD","XAU/USD","XAG/USD")))
     {
     	
     // Set up variables
     
     var crossupvalid = 0;
     var crossdownvalid = 0;
     var *ClosePrice = series(priceClose());
     
     // Set up Stochs and 100 ema
     
     Stoch(8,3,MAType_SMA,3,MAType_SMA);
     var *stochk = series(rSlowK);
     var *stochd = series(rSlowD);
     var *ema100 = series(EMA(ClosePrice,100));
     
     // Set Stop Loss
          	
     Stop = 2* ATR(20);
     
     // Check for cross up or down and which side of 100 ema
         
     if(ClosePrice[0] > ema100[0] && stochk[0] > stochd[0])
	    crossupvalid = 1;
	  else
	    crossupvalid = 0;
	  if(ClosePrice[0] < ema100[0] && stochk[0] < stochd[0])
	    crossdownvalid = 1;
	  else
	    crossdownvalid = 0;
	    
	  // Check Stochs position in relation to 20/80 and if no open trades then enter
     
     if(numLong(0) == 0 && crossupvalid == 1 && stochk[0] > 20)
       enterLong();
     if(numShort(0) == 0 && crossdownvalid == 1 && stochk[0] < 80)
       enterShort();
       
     // Check for exit conditions
          
     if(numLong(0) > 0 && stochk[0] < stochd[0])  
       exitLong();
     if(numShort(0) > 0 && stochk[0] > stochd[0])
       exitShort();     
     }
}

Posted By: jcl

Re: Lindencourt Daily System - 10/31/12 18:57

Hmm, as far as I see, the script is different to your description of it. You're not checking stochk/stochd crossings, you're only checking if one is higher than the other. This gives a different trade behavior.

For a crossing, use

if(... && crossOver(stochk,stochd)) ...

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

Moving to breakeven after 100 pips profit would currently require a trade function. The next Zorro update, 1.04, will contain a special trailing mode that can be used to do that in a simpler way.
Posted By: hughbriss

Re: Lindencourt Daily System - 10/31/12 20:38

Yes but the system is not based just on the cross, the cross must happen and the stochk must be above 20 for an up cross and below 80 for a down cross so what the script does is determine if the price is above or below the 100 ema and that the stochs are in the right order, then as long as no other orders are open it will trade as long as the criteria are met. This means that if the price is above the 100 ema && the stochs are crossed && the stochs are above 20 that it will take a long order. Similar for short.

This prevents it from entering when the stochs cross below 20 and above 80. In testing this does make a difference to the profitability.
Posted By: SFF

Re: Lindencourt Daily System - 12/27/12 10:38

I have made another script from the above code and I don't understand the result - actually there is no result.
Please test it and explain why this happens.

Code:
function run(){
	
	int MA_Period = 34;
	
	int crossupvalid = 0;
   int crossdownvalid = 0;
	
	vars main_price = series(price());
	vars main_ma = series(SMA(main_price, MA_Period));
	
	Stoch(5,3,MAType_SMA,3,MAType_SMA);
	
     vars stochk = series(rSlowK);
     vars stochd = series(rSlowD);
	
	TakeProfit = 30*PIP;
	Stop = 20*PIP;
	
	    
	    if(numLong == 0 && main_price[0] > main_ma[0] && stochk[0] < 20)
         enterLong();
     if(numShort == 0 && main_price[0] < main_ma[0] && stochk[0] > 80)
       enterShort();
       
       if(numLong > 0 && stochk[0] < stochd[0])  
       exitLong();
     if(numShort > 0 && stochk[0] > stochd[0])
       exitShort();
}

Posted By: Pipinator

Re: Lindencourt Daily System - 12/28/12 05:01

Yea.. I get that alot laugh If there is no trade, there is no result.
So somehow you have managed to be over-selective in your trade filter behavior.

I would plot your indicators to visually see what you are triggering on.

To get the price bars without a trade use
set(PLOTPRICE+LOGFILE);

The first one gets you the price bars, the second created a log file where you can printf out to do some reality checks.

Good luck!

Pipinator
Posted By: jcl

Re: Lindencourt Daily System - 12/28/12 08:59

The reason is here not a too selective filter, but just wrong code. Look at the original system:

if(numLong(0) == 0 && ....

Your version is missing the (0). In C, a function without argument list is a function pointer, and can never be zero. So your system can never execute any trade.

Anyway better use the trade statistics variables, such as NumOpenLong and NumOpenShort. The old numLong() function is depreciated.
© 2024 lite-C Forums