the attached ea has the timeperiod=0; by default, meaning it will use the period of the chart it is attached to. Also, fixed the StopLoss bug, and changed trailing stop default parameter to the minimum accepted by the author's origional coding...
Code:
extern int timeframe=0;
extern double stopLoss = 50;
extern double lTakeProfit = 20;
extern double sTakeProfit = 15;
extern double lTrailingStop = 10;
extern double sTrailingStop = 10;
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "100 pips";
extern int Slippage = 2;
extern bool UseSound = true;
extern string NameFileSound = "shotgun.wav";
extern double Lots = 0.1;
Code:
void OpenBuy() {
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLot();
ldStop = Ask-Point*stopLoss;
ldTake = GetTakeProfitBuy();
lsComm = GetCommentForOrder();
OrderSend(Symbol
(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,0,0,clOpenBuy);
if (UseSound) PlaySound(NameFileSound);
}
void OpenSell() {
double ldLot, ldStop, ldTake;
string lsComm;
ldLot = GetSizeLot();
ldStop = Bid+Point*stopLoss;
ldTake = GetTakeProfitSell();
lsComm = GetCommentForOrder();
OrderSend(Symbol
(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,0,0,clOpenSell);
if (UseSound) PlaySound(NameFileSound);
}
for some reason, this expert only seems to place trades when the timeframe is set to 5... and if you set a hard stoploss of 50, watch out below, cause thats where account equity is falling...