Hi everyone,
I couold not post this in the main thread and so I am posting here. I think I may have found an error in the mode 2 code of the EA. If I am in error I aplogize. If you look at the code bellow for the buy you see it uses the bid. I think this should be the ask because we sell at the bid and buy at the ask. So when looking for a buy we should be using the ask price for comparison. Again if I am incorrect I apologize in advance.
// MOVING AVERAGE
Var1 = iMA(NULL, PERIOD_H4, 1, 0, MODE_LWMA, PRICE_MEDIAN, 1);
Var2 = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 1);
BbLower = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 0);
BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
RefreshRates();
//if (Var1 > BbLower) { Buy(no2_Buy1MA); }//if (Var2 < BbLower && Var1 > BbLower)
if (Bid > BbLower && Var1 < Var2) { Buy(no2_Buy1MA); }
}//void Mode2Buy()
void Mode2Sell()
{
//Equates to #1 Sell 1 MA 25 BB
//if (DoesTradeExist()) return;
RefreshRates();
double Var1, Var2;
//---- indicators
// MOVING AVERAGE
Var1 = iMA(NULL, PERIOD_H4, 1, 0, MODE_LWMA, PRICE_MEDIAN, 1);
Var2 = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 1);
//BbLower = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 0);
BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
//BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
//if (Var2 > BbUpper && Var1 < BbUpper)
//if( Var1 < BbUpper) { Sell(no2_Sel1MA); }//if( Var1 < BbUpper)
if( Bid < BbUpper && Var1 > Var2) { Sell(no2_Sel1MA); }
I couold not post this in the main thread and so I am posting here. I think I may have found an error in the mode 2 code of the EA. If I am in error I aplogize. If you look at the code bellow for the buy you see it uses the bid. I think this should be the ask because we sell at the bid and buy at the ask. So when looking for a buy we should be using the ask price for comparison. Again if I am incorrect I apologize in advance.
// MOVING AVERAGE
Var1 = iMA(NULL, PERIOD_H4, 1, 0, MODE_LWMA, PRICE_MEDIAN, 1);
Var2 = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 1);
BbLower = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 0);
BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
RefreshRates();
//if (Var1 > BbLower) { Buy(no2_Buy1MA); }//if (Var2 < BbLower && Var1 > BbLower)
if (Bid > BbLower && Var1 < Var2) { Buy(no2_Buy1MA); }
}//void Mode2Buy()
void Mode2Sell()
{
//Equates to #1 Sell 1 MA 25 BB
//if (DoesTradeExist()) return;
RefreshRates();
double Var1, Var2;
//---- indicators
// MOVING AVERAGE
Var1 = iMA(NULL, PERIOD_H4, 1, 0, MODE_LWMA, PRICE_MEDIAN, 1);
Var2 = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 1);
//BbLower = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_LOWER, 0);
BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
//BbUpper = iBands(NULL, PERIOD_H4, 25, 2, 0, PRICE_CLOSE, MODE_UPPER, 0);
//if (Var2 > BbUpper && Var1 < BbUpper)
//if( Var1 < BbUpper) { Sell(no2_Sel1MA); }//if( Var1 < BbUpper)
if( Bid < BbUpper && Var1 > Var2) { Sell(no2_Sel1MA); }