А что пишется в логах терминала?
в том то и дело что ничего (только инфа об открытии ордера)!!
//+------------------------------------------------------------------+
//| Tsyrus |
//| Tsyrus@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Tsyrus"
#property link "Tsyrus@mail.ru"
#define MIN_STOPLOSS_POINT 2
#define MIN_TAKEPROFIT_POINT 2
#define MAGIC 888888
extern string sNameExpert = "Tsyrus DFS";
extern int nAccount =0;
extern double dBuyStopLossPoint = 0;
extern double dSellStopLossPoint = 0;
extern double dBuyTakeProfitPoint = 0;
extern double dSellTakeProfitPoint = 0;
extern double dBuyTrailingStopPoint = 0;
extern double dSellTrailingStopPoint = 0;
extern double dLots = 0.10;
extern int nSlippage = 5;
extern bool lFlagUseHourTrade = False;
extern int nFromHourTrade = 0;
extern int nToHourTrade = 23;
extern bool lFlagUseSound = True;
extern string sSoundFileName = "alert.wav";
extern string sSoundFileName2 = "alert.wav";
extern string sSoundFileName3 = "alert.wav";
extern color colorOpenBuy = Lime;
extern color colorCloseBuy = Black;
extern color colorOpenSell = DeepPink;
extern color colorCloseSell = Black;
void deinit() {
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come else!");
return(0);
}
}
if(Bars < 100){
Print("bars less than 100");
return(0);
}
if (nAccount > 0 && nAccount != AccountNumber()){
Comment("Trade on account :"+AccountNumber()+" FORBIDDEN!");
return(0);
}
if((dBuyStopLossPoint > 0 && dBuyStopLossPoint < MIN_STOPLOSS_POINT) ||
(dSellStopLossPoint > 0 && dSellStopLossPoint < MIN_STOPLOSS_POINT)){
Print("StopLoss less than " + MIN_STOPLOSS_POINT);
return(0);
}
if((dBuyTakeProfitPoint > 0 && dBuyTakeProfitPoint < MIN_TAKEPROFIT_POINT) ||
(dSellTakeProfitPoint > 0 && dSellTakeProfitPoint < MIN_TAKEPROFIT_POINT)){
Print("TakeProfit less than " + MIN_TAKEPROFIT_POINT);
return(0);
}
double diCustom0=iCustom(NULL, 1440, "FATL-GBP", Close, 0, 0);
double diCustom1=iCustom(NULL, 1440, "FATL-OPEN-GBP", Close, 0, 0);
double diCustom2=iCustom(NULL, 1440, "FATL-GBP", Close, 0, 0);
double diCustom3=iCustom(NULL, 1440, "FATL-OPEN-GBP", Close, 0, 0);
if(AccountFreeMargin() < (1000*dLots)){
Print("We have no money. Free Margin = " + AccountFreeMargin());
return(0);
}
bool lFlagBuyOpen = false, lFlagSellOpen = false, lFlagBuyClose = false, lFlagSellClose = false;
lFlagBuyOpen = (diCustom0>diCustom1);
lFlagSellOpen = (diCustom2<diCustom3);
lFlagBuyClose = False;
lFlagSellClose = False;
if (!ExistPositions()){
if (lFlagBuyOpen){
OpenBuy();
return(0);
}
if (lFlagSellOpen){
OpenSell();
return(0);
}
}
if (ExistPositions()){
if(OrderType()==OP_BUY){
if (lFlagBuyClose){
bool flagCloseBuy = OrderClose(OrderTicket(), OrderLots(), Bid, nSlippage, colorCloseBuy);
if (flagCloseBuy && lFlagUseSound)
PlaySound(sSoundFileName2);
return(0);
}
}
if(OrderType()==OP_SELL){
if (lFlagSellClose){
bool flagCloseSell = OrderClose(OrderTicket(), OrderLots(), Ask, nSlippage, colorCloseSell);
if (flagCloseSell && lFlagUseSound)
PlaySound(sSoundFileName2);
return(0);
}
}
}
if (dBuyTrailingStopPoint > 0 || dSellTrailingStopPoint > 0){
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;
if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;
if (OrderSymbol()==Symbol() && lMagic) {
if (OrderType()==OP_BUY && dBuyTrailingStopPoint > 0) {
if (Bid-OrderOpenPrice() > dBuyTrailingStopPoint*Point) {
if (OrderStopLoss()<Bid-dBuyTrailingStopPoint*Point)
ModifyStopLoss(Bid-dBuyTrailingStopPoint*Point);
}
}
if (OrderType()==OP_SELL) {
if (OrderOpenPrice()-Ask>dSellTrailingStopPoint*Point) {
if (OrderStopLoss()>Ask+dSellTrailingStopPoint*Point || OrderStopLoss()==0)
ModifyStopLoss(Ask+dSellTrailingStopPoint*Point);
}
}
}
}
}
}
return (0);
}
bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;
if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;
if (OrderSymbol()==Symbol() && lMagic) {
return(True);
}
}
}
return(false);
}
void ModifyStopLoss(double ldStopLoss) {
bool lFlagModify = OrderModify(OrderTicket(), OrderOpenPrice(), ldStopLoss, OrderTakeProfit(), 0, CLR_NONE);
if (lFlagModify && lFlagUseSound)
PlaySound(sSoundFileName3);
}
void OpenBuy() {
double dStopLoss = 0, dTakeProfit = 0;
if (dBuyStopLossPoint > 0)
dStopLoss = Bid-dBuyStopLossPoint*Point;
if (dBuyTakeProfitPoint > 0)
dTakeProfit = Ask + dBuyTakeProfitPoint * Point;
int numorder = OrderSend(Symbol(), OP_BUY, dLots, Ask, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenBuy);
if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
Print("Попытка отправки письма об открытии ордера в ",TimeToStr(TimeCurrent()));
SendMail("Expert", "Order was opened");
}
void OpenSell() {
double dStopLoss = 0, dTakeProfit = 0;
if (dSellStopLossPoint > 0)
dStopLoss = Ask+dSellStopLossPoint*Point;
if (dSellTakeProfitPoint > 0)
dTakeProfit = Bid-dSellTakeProfitPoint*Point;
int numorder = OrderSend(Symbol(),OP_SELL, dLots, Bid, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenSell);
if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
SendMail("Expert", "Order was opened");
Print("Попытка отправки письма об открытии ордера в ",TimeToStr(TimeCurrent()));
}
//| Tsyrus |
//| Tsyrus@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Tsyrus"
#property link "Tsyrus@mail.ru"
#define MIN_STOPLOSS_POINT 2
#define MIN_TAKEPROFIT_POINT 2
#define MAGIC 888888
extern string sNameExpert = "Tsyrus DFS";
extern int nAccount =0;
extern double dBuyStopLossPoint = 0;
extern double dSellStopLossPoint = 0;
extern double dBuyTakeProfitPoint = 0;
extern double dSellTakeProfitPoint = 0;
extern double dBuyTrailingStopPoint = 0;
extern double dSellTrailingStopPoint = 0;
extern double dLots = 0.10;
extern int nSlippage = 5;
extern bool lFlagUseHourTrade = False;
extern int nFromHourTrade = 0;
extern int nToHourTrade = 23;
extern bool lFlagUseSound = True;
extern string sSoundFileName = "alert.wav";
extern string sSoundFileName2 = "alert.wav";
extern string sSoundFileName3 = "alert.wav";
extern color colorOpenBuy = Lime;
extern color colorCloseBuy = Black;
extern color colorOpenSell = DeepPink;
extern color colorCloseSell = Black;
void deinit() {
Comment("");
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start(){
if (lFlagUseHourTrade){
if (!(Hour()>=nFromHourTrade && Hour()<=nToHourTrade)) {
Comment("Time for trade has not come else!");
return(0);
}
}
if(Bars < 100){
Print("bars less than 100");
return(0);
}
if (nAccount > 0 && nAccount != AccountNumber()){
Comment("Trade on account :"+AccountNumber()+" FORBIDDEN!");
return(0);
}
if((dBuyStopLossPoint > 0 && dBuyStopLossPoint < MIN_STOPLOSS_POINT) ||
(dSellStopLossPoint > 0 && dSellStopLossPoint < MIN_STOPLOSS_POINT)){
Print("StopLoss less than " + MIN_STOPLOSS_POINT);
return(0);
}
if((dBuyTakeProfitPoint > 0 && dBuyTakeProfitPoint < MIN_TAKEPROFIT_POINT) ||
(dSellTakeProfitPoint > 0 && dSellTakeProfitPoint < MIN_TAKEPROFIT_POINT)){
Print("TakeProfit less than " + MIN_TAKEPROFIT_POINT);
return(0);
}
double diCustom0=iCustom(NULL, 1440, "FATL-GBP", Close, 0, 0);
double diCustom1=iCustom(NULL, 1440, "FATL-OPEN-GBP", Close, 0, 0);
double diCustom2=iCustom(NULL, 1440, "FATL-GBP", Close, 0, 0);
double diCustom3=iCustom(NULL, 1440, "FATL-OPEN-GBP", Close, 0, 0);
if(AccountFreeMargin() < (1000*dLots)){
Print("We have no money. Free Margin = " + AccountFreeMargin());
return(0);
}
bool lFlagBuyOpen = false, lFlagSellOpen = false, lFlagBuyClose = false, lFlagSellClose = false;
lFlagBuyOpen = (diCustom0>diCustom1);
lFlagSellOpen = (diCustom2<diCustom3);
lFlagBuyClose = False;
lFlagSellClose = False;
if (!ExistPositions()){
if (lFlagBuyOpen){
OpenBuy();
return(0);
}
if (lFlagSellOpen){
OpenSell();
return(0);
}
}
if (ExistPositions()){
if(OrderType()==OP_BUY){
if (lFlagBuyClose){
bool flagCloseBuy = OrderClose(OrderTicket(), OrderLots(), Bid, nSlippage, colorCloseBuy);
if (flagCloseBuy && lFlagUseSound)
PlaySound(sSoundFileName2);
return(0);
}
}
if(OrderType()==OP_SELL){
if (lFlagSellClose){
bool flagCloseSell = OrderClose(OrderTicket(), OrderLots(), Ask, nSlippage, colorCloseSell);
if (flagCloseSell && lFlagUseSound)
PlaySound(sSoundFileName2);
return(0);
}
}
}
if (dBuyTrailingStopPoint > 0 || dSellTrailingStopPoint > 0){
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;
if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;
if (OrderSymbol()==Symbol() && lMagic) {
if (OrderType()==OP_BUY && dBuyTrailingStopPoint > 0) {
if (Bid-OrderOpenPrice() > dBuyTrailingStopPoint*Point) {
if (OrderStopLoss()<Bid-dBuyTrailingStopPoint*Point)
ModifyStopLoss(Bid-dBuyTrailingStopPoint*Point);
}
}
if (OrderType()==OP_SELL) {
if (OrderOpenPrice()-Ask>dSellTrailingStopPoint*Point) {
if (OrderStopLoss()>Ask+dSellTrailingStopPoint*Point || OrderStopLoss()==0)
ModifyStopLoss(Ask+dSellTrailingStopPoint*Point);
}
}
}
}
}
}
return (0);
}
bool ExistPositions() {
for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
bool lMagic = true;
if (MAGIC > 0 && OrderMagicNumber() != MAGIC)
lMagic = false;
if (OrderSymbol()==Symbol() && lMagic) {
return(True);
}
}
}
return(false);
}
void ModifyStopLoss(double ldStopLoss) {
bool lFlagModify = OrderModify(OrderTicket(), OrderOpenPrice(), ldStopLoss, OrderTakeProfit(), 0, CLR_NONE);
if (lFlagModify && lFlagUseSound)
PlaySound(sSoundFileName3);
}
void OpenBuy() {
double dStopLoss = 0, dTakeProfit = 0;
if (dBuyStopLossPoint > 0)
dStopLoss = Bid-dBuyStopLossPoint*Point;
if (dBuyTakeProfitPoint > 0)
dTakeProfit = Ask + dBuyTakeProfitPoint * Point;
int numorder = OrderSend(Symbol(), OP_BUY, dLots, Ask, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenBuy);
if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
Print("Попытка отправки письма об открытии ордера в ",TimeToStr(TimeCurrent()));
SendMail("Expert", "Order was opened");
}
void OpenSell() {
double dStopLoss = 0, dTakeProfit = 0;
if (dSellStopLossPoint > 0)
dStopLoss = Ask+dSellStopLossPoint*Point;
if (dSellTakeProfitPoint > 0)
dTakeProfit = Bid-dSellTakeProfitPoint*Point;
int numorder = OrderSend(Symbol(),OP_SELL, dLots, Bid, nSlippage, dStopLoss, dTakeProfit, sNameExpert, MAGIC, 0, colorOpenSell);
if (numorder > -1 && lFlagUseSound)
PlaySound(sSoundFileName);
SendMail("Expert", "Order was opened");
Print("Попытка отправки письма об открытии ордера в ",TimeToStr(TimeCurrent()));
}
Вы упускаете торговые возможности:
- Бесплатные приложения для трейдинга
- 8 000+ сигналов для копирования
- Экономические новости для анализа финансовых рынков
Регистрация
Вход
Вы принимаете политику сайта и условия использования
Если у вас нет учетной записи, зарегистрируйтесь
Помогите плиз!