Could you please see what is wrong with the following code....I described in the bottom what its doing wrong.
bool CheckMACrossExit(int cmd,int TimeFrame,int shift)
{
double MAFast = iMA(NULL, TimeFrame, FastMAExit, 0, MODE_LWMA, PRICE_CLOSE, shift);
double MASlow = iMA(NULL, TimeFrame, SlowMAExit, 0, MODE_EMA, PRICE_CLOSE, shift);
switch (cmd)
{
case OP_BUY : if(MAFast>MASlow) {return (true);}
break;
case OP_SELL : if(MAFast<MASlow) {return (true);}
}
return(false);
It seems like it does not care if its short or long,, it does not care if its crosses down or up it closes the trade anyways when there is a cross.
which is wrong
How can Change the above codding so it exits according to the rules below..1 and 2
1- Only IF Long trade is active and fastEMA Crosses below slowEMA Exit Long trade only....do not close the short trade
2- Only IF Short trade is active and fastEMA Crosses Up slowEMA Exit short trade only ....do not close a long trade
ANY HELP IS APPRICIATED!!
bool CheckMACrossExit(int cmd,int TimeFrame,int shift)
{
double MAFast = iMA(NULL, TimeFrame, FastMAExit, 0, MODE_LWMA, PRICE_CLOSE, shift);
double MASlow = iMA(NULL, TimeFrame, SlowMAExit, 0, MODE_EMA, PRICE_CLOSE, shift);
switch (cmd)
{
case OP_BUY : if(MAFast>MASlow) {return (true);}
break;
case OP_SELL : if(MAFast<MASlow) {return (true);}
}
return(false);
It seems like it does not care if its short or long,, it does not care if its crosses down or up it closes the trade anyways when there is a cross.
which is wrong
How can Change the above codding so it exits according to the rules below..1 and 2
1- Only IF Long trade is active and fastEMA Crosses below slowEMA Exit Long trade only....do not close the short trade
2- Only IF Short trade is active and fastEMA Crosses Up slowEMA Exit short trade only ....do not close a long trade
ANY HELP IS APPRICIATED!!