Hello Dan,
I tried to make a simple simulation program to test the strategy. I used positions of 1 lot per trade for testing purposes. The algorithm made a profit of almost 4.000 USD since 1st of December., however, it was not that profitable the previous months. If you like see below the code and let me know if the idea is correct (I am pretty new in this kind of programming and trading):
input int UpperGreen32EMA=32;
input int LowerGreen32EMA=32;
input int Yellow14EMA=14;
double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
string signal="";
double UpperGreen32EMAArray[], LowerGreen32EMAArray[],Yellow14EMAArray[];
int UpperGreen32EMADefinition = iMA(_Symbol,_Period,UpperGreen32EMA,0,MODE_EMA,PRICE_HIGH);
int LowerGreen32EMADefinition = iMA(_Symbol,_Period,LowerGreen32EMA,0,MODE_EMA,PRICE_LOW);
int Yellow14EMADefinition = iMA(_Symbol,_Period,Yellow14EMA,0,MODE_EMA,PRICE_CLOSE);
CopyBuffer(UpperGreen32EMADefinition,0,0,4,UpperGreen32EMAArray);
CopyBuffer(LowerGreen32EMADefinition,0,0,4,LowerGreen32EMAArray);
CopyBuffer(Yellow14EMADefinition,0,0,4,Yellow14EMAArray);
#Here you check if Yellow 14 EMA crosses the Lower Green 32 in order to signal for a buy
if (Yellow14EMAArray[1] < LowerGreen32EMAArray [1])
if (Yellow14EMAArray[3] > LowerGreen32EMAArray [3])
{
signal="buy";
}
#Here you check if Yellow 14 EMA crosses the Upper Green 32 in order to signal for a sell
if (Yellow14EMAArray[1] > UpperGreen32EMAArray [1])
if (Yellow14EMAArray[3] < UpperGreen32EMAArray [3])
{
signal="sell";
}
if (signal == "sell" && PositionsTotal()<1)
trade.Sell(1.0,NULL,Bid,(Bid+200 * _Point),(Bid-150 * _Point), NULL);
if (signal == "buy" && PositionsTotal()<1)
trade.Buy(1.0,NULL,Ask,(Ask-200 * _Point),(Ask+150 * _Point), NULL);