#property version "1.00"
#include <stdlib.mqh>
extern int StopLoss = 50;
extern double Lots = 1.0;
extern int MagicNumber = 9723;
extern string SettingIndi = "=====";
extern int MoveShift = 12;
extern int MAPeriod = 9;
extern int OsMA = 3;
extern int Dist2 = 20;
extern double Std = 0.4;
extern int BPeriod = 20;
int StartHour = 0;
int EndHour = 24;
bool ShowInfo = true;
int Corner = 1;
int PT = 1,
DIGIT,SlipPage;
double POINT;
int TakeProfit = 0;
int init()
{
// код доступен только после оплаты
}
int deinit()
{
DelObject();
Comment("");
return(0);
}
int start()
{
// код доступен только после оплаты
}
void SetupTrade()
{
int x = 2147483647;
double value_2 = iCustom(Symbol(),Period(),"ma_bbands",MoveShift,MAPeriod,OsMA,Dist2,Std,BPeriod,2,1);
double value_3 = iCustom(Symbol(),Period(),"ma_bbands",MoveShift,MAPeriod,OsMA,Dist2,Std,BPeriod,3,1);
Comment(value_2,"==",value_3);
bool buy1 = value_2 > 0;
bool sell1 = value_3 > 0;
bool closebuy = sell1;
bool closesell = buy1;
datetime candleTime = iTime(Symbol(),Period(),0); static datetime timeTrade;
bool trade = Hour() >= StartHour && Hour() <= EndHour;
if(closebuy) CloseOrder(OP_BUY);
if(closesell) CloseOrder(OP_SELL);
if(trade && TotalOrder()==0)
{
if(buy1 && IsOrder("buy#1") && timeTrade != candleTime)
{
Order(OP_BUY,"buy#1");
timeTrade = candleTime;
}
if(sell1 && IsOrder("sell#1") && timeTrade != candleTime)
{
Order(OP_SELL,"sell#1");
timeTrade = candleTime;
}
}
}
bool IsOrder(string comment)
{
bool isOrder = true;
if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(StringFind(OrderComment(),comment) != -1) isOrder = false;
if(OrderType() == OP_BUY)
{
if(OrderStopLoss() > OrderOpenPrice()) isOrder = false;
}
if(OrderType() == OP_SELL)
{
if(OrderStopLoss() < OrderOpenPrice() && OrderStopLoss() > 0) isOrder = false;
}
}
}
return(isOrder);
}
double TotalPips()
{
double totalPip = 0, pip = 0;
string date = TimeToString(TimeCurrent(),TIME_DATE);
for(int i = OrdersHistoryTotal()-1; i >= 0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(StringFind(TimeToString(OrderCloseTime(),TIME_DATE),date) != -1)
{
if(OrderType() == OP_BUY)
{
pip = (OrderClosePrice()-OrderOpenPrice())/POINT;
totalPip += pip;
}
if(OrderType() == OP_SELL)
{
pip = (OrderOpenPrice()-OrderClosePrice())/POINT;
totalPip += pip;
}
}
}
}
}
return(totalPip);
}
int TotalOrder(int ordertype = -1)
{
int Order = 0;
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
if(ordertype == -1)
Order++;
else if(ordertype == OrderType())
Order++;
}
}
}
return(Order);
}
double SetupLot()
{
double lot = 0, firstLot = 0,
MinLot = MarketInfo(Symbol(),MODE_MINLOT),
MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);
for(int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber)
{
lot = MathMax(lot,OrderLots());
}
}
}
lot = Lots;
if(MinLot == 0.01)
firstLot = NormalizeDouble(firstLot,2);
else
firstLot = NormalizeDouble(firstLot,1);
if(lot == 0)
lot = Lots;
if(lot < MinLot) lot = MinLot;
if(lot > MaxLot) lot = MaxLot;
if(MinLot == 0.01)
lot = NormalizeDouble(lot,2);
else
lot = NormalizeDouble(lot,1);
return(lot);
}
double AskPrice(string symbol = "")
{
if(symbol == "") symbol = Symbol();
return(MarketInfo(symbol,MODE_ASK));
}
double BidPrice(string symbol = "")
{
if(symbol == "") symbol = Symbol();
return(MarketInfo(symbol,MODE_BID));
}
int StopLevel(string symbol = "")
{
if(symbol == "") symbol = Symbol();
return(MarketInfo(symbol,MODE_STOPLEVEL));
}
string OrderCmd(int ordertype)
{
string label;
switch(ordertype)
{
case 0: label = "Buy"; break;
case 1: label = "Sell"; break;
case 2: label = "Buy Limit"; break;
case 3: label = "Sell Limit"; break;
case 4: label = "Buy Stop"; break;
case 5: label = "Sell Stop"; break;
}
return(label);
}
int Order(int ordertype, string comment)
{
int ticket;
double lot = SetupLot(),price, sl = 0, tp = 0;
if(ordertype == OP_BUY)
{
price = AskPrice();
if(StopLoss > 0) sl = NormalizeDouble(price-(StopLoss*POINT),DIGIT);
if(TakeProfit > 0) tp = NormalizeDouble(price+(TakeProfit*POINT),DIGIT);
}
if(ordertype == OP_SELL)
{
price = BidPrice();
if(StopLoss > 0) sl = NormalizeDouble(price+(StopLoss*POINT),DIGIT);
if(TakeProfit > 0) tpПоказано первые 50% кода (символов: 7905)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.