• Welcome back! Thank you for being a part of this Traders Community. Let's discuss and share :)
    Selamat datang kembali! Trimakasih telah menjadi bagian dari Komunitas Trader ini. Mari berdiskusi dan berbagi :)

Suggestion bantuan betulkan ea ini

issue is, ea not trade money then if needet no signal up or down way,going high minus margin level..
its same like manualy trade ...I think is going down way....
right now testing....
 
/*
ScalpVolumeX EA
Scalping EA M5 - Entry based on tick volume >= 7 and candle direction
Includes: Auto Lot, Max Spread, Time & Day Filter, Trailing Stop
*/

#property strict

extern double MaxSpread = 20; // Max allowed spread (points)
extern bool AutoLot = true;
extern double RiskPer1000 = 0.01; // Lot per $1000 if AutoLot true
extern double FixedLot = 0.01; // Lot size if AutoLot false

extern int TP_Pips = 10;
extern int SL_Pips = 10;
extern int TrailStart = 5;
extern int TrailStep = 5;

extern int StartHour = 6;
extern int EndHour = 20;
extern bool Monday = true;
extern bool Tuesday = true;
extern bool Wednesday = true;
extern bool Thursday = true;
extern bool Friday = true;

int OnInit() {
return(INIT_SUCCEEDED);
}

bool IsTradingHour() {
int hour = TimeHour(TimeCurrent());
if (hour < StartHour || hour >= EndHour) return false;

int day = TimeDayOfWeek(TimeCurrent());
if ((day == 1 && !Monday) ||
(day == 2 && !Tuesday) ||
(day == 3 && !Wednesday) ||
(day == 4 && !Thursday) ||
(day == 5 && !Friday)) return false;

return true;
}

bool SpreadOK() {
double spread = (Ask - Bid) / Point;
return (spread <= MaxSpread);
}

double GetLotSize() {
double lot;
if (AutoLot) {
lot = AccountBalance() * RiskPer1000 / 1000.0;
} else {
lot = FixedLot;
}

double minLot = MarketInfo(Symbol(), MODE_MINLOT);
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);

lot = MathMax(lot, minLot);
lot = MathMin(lot, maxLot);
lot = NormalizeDouble(MathFloor(lot / lotStep) * lotStep, 2);

return lot;
}

bool NoOpenOrders() {
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 20250617)
return false;
}
}
return true;
}

void CheckSignal() {
if (!IsTradingHour() || !SpreadOK() || !NoOpenOrders()) return;

int vol = (int)Volume[1];
if (vol < 7) return;

double lot = GetLotSize();
double sl = SL_Pips * Point;
double tp = TP_Pips * Point;

int ticket;
if (Close[1] > Open[1]) {
ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, 3, Ask - sl, Ask + tp, "Buy", 20250617, 0, clrBlue);
if (ticket < 0) Print("OrderSend BUY failed: ", GetLastError());
} else if (Close[1] < Open[1]) {
ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, 3, Bid + sl, Bid - tp, "Sell", 20250617, 0, clrRed);
if (ticket < 0) Print("OrderSend SELL failed: ", GetLastError());
}
}

void ManageTrailingStop() {
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 20250617) {
if (OrderType() == OP_BUY) {
double price = Bid;
if (price - OrderOpenPrice() >= TrailStart * Point) {
double newSL = price - TrailStep * Point;
if (newSL > OrderStopLoss()) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), newSL, OrderTakeProfit(), 0, clrBlue))
Print("OrderModify BUY failed: ", GetLastError());
}
}
}
else if (OrderType() == OP_SELL) {
double price = Ask;
if (OrderOpenPrice() - price >= TrailStart * Point) {
double newSL = price + TrailStep * Point;
if (newSL < OrderStopLoss() || OrderStopLoss() == 0.0) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), newSL, OrderTakeProfit(), 0, clrRed))
Print("OrderModify SELL failed: ", GetLastError());
}
}
}
}
}
}
}

int start() {
CheckSignal();
ManageTrailingStop();
return 0;
}
 

Attachments

/*
ScalpVolumeX EA
Scalping EA M5 - Entry based on tick volume >= 7 and candle direction
Includes: Auto Lot, Max Spread, Time & Day Filter, Trailing Stop
*/

#property strict

extern double MaxSpread = 20; // Max allowed spread (points)
extern bool AutoLot = true;
extern double RiskPer1000 = 0.01; // Lot per $1000 if AutoLot true
extern double FixedLot = 0.01; // Lot size if AutoLot false

extern int TP_Pips = 10;
extern int SL_Pips = 10;
extern int TrailStart = 5;
extern int TrailStep = 5;

extern int StartHour = 6;
extern int EndHour = 20;
extern bool Monday = true;
extern bool Tuesday = true;
extern bool Wednesday = true;
extern bool Thursday = true;
extern bool Friday = true;

int OnInit() {
return(INIT_SUCCEEDED);
}

bool IsTradingHour() {
int hour = TimeHour(TimeCurrent());
if (hour < StartHour || hour >= EndHour) return false;

int day = TimeDayOfWeek(TimeCurrent());
if ((day == 1 && !Monday) ||
(day == 2 && !Tuesday) ||
(day == 3 && !Wednesday) ||
(day == 4 && !Thursday) ||
(day == 5 && !Friday)) return false;

return true;
}

bool SpreadOK() {
double spread = (Ask - Bid) / Point;
return (spread <= MaxSpread);
}

double GetLotSize() {
double lot;
if (AutoLot) {
lot = AccountBalance() * RiskPer1000 / 1000.0;
} else {
lot = FixedLot;
}

double minLot = MarketInfo(Symbol(), MODE_MINLOT);
double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP);
double maxLot = MarketInfo(Symbol(), MODE_MAXLOT);

lot = MathMax(lot, minLot);
lot = MathMin(lot, maxLot);
lot = NormalizeDouble(MathFloor(lot / lotStep) * lotStep, 2);

return lot;
}

bool NoOpenOrders() {
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 20250617)
return false;
}
}
return true;
}

void CheckSignal() {
if (!IsTradingHour() || !SpreadOK() || !NoOpenOrders()) return;

int vol = (int)Volume[1];
if (vol < 7) return;

double lot = GetLotSize();
double sl = SL_Pips * Point;
double tp = TP_Pips * Point;

int ticket;
if (Close[1] > Open[1]) {
ticket = OrderSend(Symbol(), OP_BUY, lot, Ask, 3, Ask - sl, Ask + tp, "Buy", 20250617, 0, clrBlue);
if (ticket < 0) Print("OrderSend BUY failed: ", GetLastError());
} else if (Close[1] < Open[1]) {
ticket = OrderSend(Symbol(), OP_SELL, lot, Bid, 3, Bid + sl, Bid - tp, "Sell", 20250617, 0, clrRed);
if (ticket < 0) Print("OrderSend SELL failed: ", GetLastError());
}
}

void ManageTrailingStop() {
for (int i = 0; i < OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == 20250617) {
if (OrderType() == OP_BUY) {
double price = Bid;
if (price - OrderOpenPrice() >= TrailStart * Point) {
double newSL = price - TrailStep * Point;
if (newSL > OrderStopLoss()) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), newSL, OrderTakeProfit(), 0, clrBlue))
Print("OrderModify BUY failed: ", GetLastError());
}
}
}
else if (OrderType() == OP_SELL) {
double price = Ask;
if (OrderOpenPrice() - price >= TrailStart * Point) {
double newSL = price + TrailStep * Point;
if (newSL < OrderStopLoss() || OrderStopLoss() == 0.0) {
if (!OrderModify(OrderTicket(), OrderOpenPrice(), newSL, OrderTakeProfit(), 0, clrRed))
Print("OrderModify SELL failed: ", GetLastError());
}
}
}
}
}
}
}

int start() {
CheckSignal();
ManageTrailingStop();
return 0;
}
thanks bro oppiek
 
Back
Top