Hi guys!
I am trying to implement the strategy presented on today's Mechanical Forex blog: Price action system

This is the code I got so far:

Code:
// http://mechanicalforex.com/2014/01/global-trading-building-a-forex-price-action-based-system-for-the-4-majors.html

function run() 
{

	StartDate = 2002;
	BarPeriod = 1440;
	LookBack = 200;
	NumWFOCycles = 10; // activate WFO, 10 cycles
	

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

	if(priceClose(9) > priceClose(10) && priceOpen(158) > priceLow(130) && priceClose(156) > priceClose(173)) 
		reverseLong(1);
		Stop = 1.8*ATR(20);
	if(priceClose(9) < priceClose(10) && priceOpen(158) < priceLow(130) && priceClose(156) < priceClose(173)) 
		reverseShort(1);
		Stop = 1.8*ATR(20);
	}
}



For completing the code I need some advice how to implement the following:

Quote:
Note that the system reverses trades on opposite signals so if a system is within a long and it receives a short signal it will close the long and go short. Another important factor is that the system uses a 180% of the 20-ATR stop-loss which is updated whenever a signal in the same direction is received (for those of you with the doubt, adding new positions on new signals in the same direction increases draw downs significantly, much more than it does profits). Another important aspect – if you want to reproduce my tests – is that my data is refactored within the F4 framework to be GMT +1/+2, the refactoring also makes all Monday candles start at 4 and all Friday candles end at 19 (GMT +1/+2 time).


The system seems to be quite interesting in long term trading. (Especially with some additions like OptimalF and equity curve trading, etc.)
So thanks in advance for any tips laugh