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();     
     }
}