#define SIGNAL_NONE 0
#define SIGNAL_BUY 1
#define SIGNAL_SELL 2
#define SIGNAL_CLOSEBUY 3
#define SIGNAL_CLOSESELL 4
extern string Remark1 = "== Main Settings ==";
extern int MagicNumber = 0;
extern bool SignalsOnly = False;
extern bool Alerts = False;
extern bool SignalMail = False;
extern bool PlaySounds = False;
extern bool EachTickMode = True;
extern bool CloseOnOppositeSignal = True;
extern double Lots = 0;
extern bool MoneyManagement = False;
extern int Risk = 0;
extern int Slippage = 5;
extern bool UseStopLoss = True;
extern int StopLoss = 150;
extern bool UseTakeProfit = True;
extern int TakeProfit = 60;
extern bool UseTrailingStop = False;
extern int TrailingStop = 30;
extern bool MoveStopOnce = False;
extern int MoveStopWhenPrice = 50;
extern int MoveStopTo = 1;
extern string Remark2 = "";
extern string Remark3 = "== MA Fast Settings ==";
extern int MA1Period = 15;
extern int MA1Shift = 0;
extern int MA1Method = 0;
extern int MA1Price = 0;
extern string Remark4 = "";
extern string Remark5 = "== MA Slow Settings ==";
extern int MA2Period =30;
extern int MA2Shift = 0;
extern int MA2Method = 0;
extern int MA2Price = 0;
extern double Use_ATR_Pct = 0.7;
extern bool Use_ATR_Stop = true;
int BarCount;
int Current;
bool TickCheck = False;
int init() {
// код доступен только после оплаты
}
double getATR()
{
double atr=iATR(NULL,0,10,0);
double atr_val = atr*Use_ATR_Pct;
return(atr_val);
}
double getATRBuyTakeProfit(double price)
{
double initTP;
initTP=price+getATR();
return(initTP);
}
double getATRBuyStopLoss(double price)
{
double initSL;
initSL=price-(3*(getATR()));
return(initSL);
}
double getATRSellTakeProfit(double price)
{
double initTP;
initTP=price-getATR();
return(initTP);
}
double getATRSellStopLoss(double price)
{
double initSL;
initSL=price+(3*(getATR()));
return(initSL);
}
int deinit() {
return(0);
}
int start()
{
// код доступен только после оплаты
}
int Order = SIGNAL_NONE;
int Total, Ticket;
double StopLossLevel, TakeProfitLevel;
if (EachTickMode && Bars != BarCount) TickCheck = False;
Total = OrdersTotal();
Order = SIGNAL_NONE;
if (MoneyManagement)
{
if (Risk<1 || Risk>100)
{
Comment("Invalid Risk Value.");
return(0);
}
else
{
Lots=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);
}
}
double EURUSDMA1A = iMA("EURUSD", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 0);
double EURUSDMA1B = iMA("EURUSD", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 1);
double EURUSDMA2A = iMA("EURUSD", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 0);
double EURUSDMA2B = iMA("EURUSD", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 1);
double USDCHFMA1A = iMA("USDCHF", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 0);
double USDCHFMA1B = iMA("USDCHF", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 1);
double USDCHFMA2A = iMA("USDCHF", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 0);
double USDCHFMA2B = iMA("USDCHF", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 1);
double EURCHFMA1A = iMA("EURCHF", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 0);
double EURCHFMA1B = iMA("EURCHF", 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 1);
double EURCHFMA2A = iMA("EURCHF", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 0);
double EURCHFMA2B = iMA("EURCHF", 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 1);
double MA1A = iMA(NULL, 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 0);
double MA1B = iMA(NULL, 0, MA1Period, MA1Shift, MA1Method, MA1Price, Current + 1);
double MA2A = iMA(NULL, 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 0);
double MA2B = iMA(NULL, 0, MA2Period, MA2Shift, MA2Method, MA2Price, Current + 1);
bool IsTrade = False;
for (int i = 0; i < Total; i ++) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderType() <= OP_SELL && OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
IsTrade = True;
if(OrderType() == OP_BUY) {
if(CloseOnOppositeSignal && EURUSDMA1A < EURUSDMA2A && EURUSDMA1B >= EURUSDMA2B && EURCHFMA1A < EURCHFMA2A && EURCHFMA1B >= EURCHFMA2B && USDCHFMA1A > USDCHFMA2A && USDCHFMA1B <= USDCHFMA2B) Order = SIGNAL_CLOSEBUY;
if (Order == SIGNAL_CLOSEBUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {
OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, MediumSeaGreen);
if (SignalMail) SendMail("[Signal Alert]", "[" + Symbol() + "] " + DoubleToStr(Bid, Digits) + " Close Buy");
if (!EachTickMode) BarCount = Bars;
IsTrade = False;
continue;
}
if(MoveStopOnce && MoveStopWhenPrice > 0) {
if(Bid - OrderOpenPrice() >= Point * MoveStopWhenPrice) {
if(OrderStopLoss() < OrderOpenPrice() + Point * MoveStopTo) {
OrderModify(OrderTicket(),OrderOpenPrice(), OrderOpenPrice() + Point * MoveStopTo, OrderTakeProfit(), 0, Red);
if (!EachTickMode) BarCount = Bars;
continue;
}
}
}
if(UseTrailingStop && TrailingStop > 0) {
if(Bid - OrderOpenPrice() > Point * TrailingStop) {
if(OrderStopLoss() < Bid - Point * TrailingStop) {
Показано первые 50% кода (символов: 8406)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.