Hello, this is my first script and is a very basic 5/8 ema cross. It checks the 5/8 ema's of the candle before last and compares them to the latest closed candles 5/8 ema situation.
When there is a fresh crossover (ie it just happened) it enters in the direction of the cross and closes all open orders in the other direction. If there is no cross it just adds on in the direction of the trend.
It makes 6% on eurusd daily charts and 69% on audusd. I'm sure this could be optimised and made better but at the end of the day it is not the best system idea to start with, I just wanted to code something simple as a start.
I'd be grateful if anyone could take a look at the code for me and tell me if it does indeed do what I intended it to do and whether I have coded it elegantly or if I could have done it more simply.
Thanks
function run()
{
var* ClosePrice = series(priceClose());
var* PrevClosePrice = series(priceClose(1));
var* prev5ema = series(EMA(PrevClosePrice,5));
var* curr5ema = series(EMA(ClosePrice,5));
var* prev8ema = series(EMA(PrevClosePrice,8));
var* curr8ema = series(EMA(ClosePrice,8));
if (*prev5ema > *prev8ema && *curr5ema < *curr8ema)
enterShort();
if (*prev5ema < *prev8ema && *curr5ema > *curr8ema)
enterLong();
if (*prev5ema > *prev8ema && *curr5ema > *curr8ema)
enterLong();
if (*prev5ema < *prev8ema && *curr5ema < *curr8ema)
enterShort();
}