مرفق كود مؤشر ارسال الايميل وكود الاكسبرت واريد الدمج بينهما وليس لي خبره بالمؤشرات فلم انجح.
لو تكرمت كيف ادمج بينهما حتى يرسل الاكسبرت رسائل الى ايميلي تحتوي على معلومات الحساب .مع العلم ان ملف الDLL يوضع في مكتبة الميتاتريدر.
كود:
//+------------------------------------------------------------------+//| SendAdvancedEmail.mq4 |
//| Copyright 2014, Dorian Ocsovszki |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, Dorian Ocsovszki"
#property link "http://ocsovszki-dorian.blogspot.co.uk/2014/05/sendextendedemail-dll-function-for.html"
#property version "1.00"
#property strict
#property indicator_chart_window
#import "SendAdvancedEmail.dll"
void SendAdvancedEmail(string MailFrom, string MailFromName, string MailTo, string MailCC, string MailSubject, string MailBodyContent, string MailBodyTemplate, string MailPriority, string MailAttachmentPath, string MailAttachmentName, string SMTPServer, int SMTPPort, bool SMTPEnableSSL, int SMTPTimeout, string SMTPUsername, string SMTPPassword);
#import
input string Separator1 = NULL; //=== SCREENSHOT SETTINGS ===
input string PathToScreenshots = "C:\\DATA\\%MT4DIR%\\MQL4\\Files\\"; // Path to Screenshots ( %MT4DIR%\MQL4\Files )
input int SCWidth = 1920; // Screenshot Width
input int SCHeight = 1080; // Screenshot Height
input string Separator2 = NULL; //=== MAIL SETTINGS ===
input string MailFrom = ""; // FROM:
input string MailFromName = "MT4 Advanced eMail Notifier"; // FROM NAME:
input string MailTo = ""; // TO:
input string MailCC = ""; // CC: (Mail1;Mail2;MailN ...)
input string Separator3 = NULL; //=== SMTP SETTINGS ===
input string SMTPServer = "";
input int SMTPPort = 587;
input string SMTPUsername = "";
input string SMTPPassword = "";
int SMTPTimeout = 10000;
bool SMTPEnableSSL = true;
string MailSubject = "MT4 Notifier";
string MailBody = "MT4 Notifier MailBody";
string MailAttachmentPath = NULL;
string MailAttachmentName = NULL;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
string SCFileNameVer1 = StringConcatenate(Symbol(), "_Period", Period(), "_", TimeYear(TimeLocal()), "-", TimeMonth(TimeLocal()), "-", TimeDay(TimeLocal()), "_", PadString(DoubleToStr(TimeHour(TimeLocal()),0),"0",2), "-", PadString(DoubleToStr(TimeMinute(TimeLocal()),0),"0",2), "-", PadString(DoubleToStr(TimeSeconds(TimeLocal()),0),"0",2), ".gif" );
if (ShootScreenShot(SCFileNameVer1)) {
SendAdvancedEmailSimple("[FOREX] New Order Opened", "2014.05.18 13:38:15.738 OrderHistoryTest GBPNZD,M15: #40320001 2014.05.08 18:21:20 buy limit 2.00 GBPNZD 1.92168 0.00000 0.00000 2014.05.15 19:40:55 1.94523 0.00 0.00 0.00 cancelled 0", "C:\\DATA\\XMMT4-GBPNZD\\MQL4\\Libraries\\MailBody.html", "Normal", PathToScreenshots + SCFileNameVer1, SCFileNameVer1);
} else {
Print("ERROR: Screenshot failed. Email event cancelled.");
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
void SendAdvancedEmailSimple(string fMailSubject, string fMailBodyContent, string fMailBodyTemplate, string fMailPriority = "Normal", string fMailAttachmentPath = NULL, string fMailAttachmentName = NULL)
{
SendAdvancedEmail(MailFrom, MailFromName, MailTo, MailCC, fMailSubject, fMailBodyContent, fMailBodyTemplate, fMailPriority, fMailAttachmentPath, fMailAttachmentName, SMTPServer, SMTPPort, SMTPEnableSSL, SMTPTimeout, SMTPUsername, SMTPPassword);
}
bool ShootScreenShot(string SCFileName)
{
bool status = WindowScreenShot(SCFileName,SCWidth,SCHeight,-1,-1,-1);
return (status);
}
string PadString(string toBePadded, string paddingChar, int paddingLength)
{
while(StringLen(toBePadded) < paddingLength)
{
toBePadded = StringConcatenate(paddingChar,toBePadded);
}
return (toBePadded);
}
كود:
//+------------------------------------------------------------------+//| FireStrategy_EA.mq4 |
//| ENG.ABDELOUAHAB KEBICI |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "ENG.ABDELOUAHAB KEBICI"
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
extern double lot=0.1;
extern double lot2=0.3;
extern double Increment_lot=0.4;
extern int Gap=20;
extern string _Use_One_Type_Order_="=====Use One Type Order=====";
extern bool Use_BuyOrder=false;
extern bool Use_SellOrder=false;
extern string _Close_At_TotalProfit="=====Close at TotalProfit=====";
extern double TotalProfit=50;
extern string _UseFullHedget="=====Use Full Hedge=====";
extern bool UseFullHedge=true;
extern double Floating=200;
extern string __="=======Time Filter========";
extern bool UseTimeFilter= true;
extern int Start_Time = 6;
extern int Finish_Time =21;
extern string ___ooo___="=================";
extern int MagicNumber=2016;
double point;
int digits,Q;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
if(Digits==5 || Digits==3)Q=10;
else Q=1;
if(Digits<4)
{
point=0.01;
digits=2;
}
else
{
point=0.0001;
digits=4;
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
DeletPendOrders();
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
double SL,TP,lot1,lots,Lots;
void OnTick()
{
Comment("AccountEquity = ",AccountEquity(),"\n",
"AccountBalance = ",AccountBalance(),"\n",
"=============","\n",
"SommeLots_Buy = ",SommeLots_Buy(),"\n",
"SommeLots_Sell = ",SommeLots_Sell(),"\n",
"=============","\n",
"Floating = ",ProfitAllorders()
);
//+------------------------------------------------------------------+
//| Time |
//+------------------------------------------------------------------+
datetime Current_Time = TimeHour(TimeCurrent());
if (UseTimeFilter&&orderstotal()<1){
if (Start_Time == 0) Start_Time = 24; if (Finish_Time == 0) Finish_Time = 24; if (Current_Time == 0) Current_Time = 24;
if ( Start_Time < Finish_Time )
{
if ( (Current_Time < Start_Time) || (Current_Time >= Finish_Time) ) {Comment("Non-Trading Hours!");return;}
}
if ( Start_Time > Finish_Time )
{
if ( (Current_Time < Start_Time) && (Current_Time >= Finish_Time) ){Comment("Non-Trading Hours!"); return;}
}
}
//---
//+------------------------------------------------------------------+
//| FullHedge |
//+------------------------------------------------------------------+
if(UseFullHedge==true&&SommeLots_Buy()>SommeLots_Sell()&&MathAbs(ProfitAllorders())>=Floating&&ProfitAllorders()<0){
Lots=NormalizeDouble(SommeLots_Buy(),Digits)-NormalizeDouble(SommeLots_Sell(),Digits);
int ticket91000=OrderSend(Symbol(),OP_SELL,Lots,NormalizeDouble(Bid,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Red);
DeletPendOrders();
return;
}
if(UseFullHedge==true&&SommeLots_Sell()>SommeLots_Buy()&&MathAbs(ProfitAllorders())>=Floating&&ProfitAllorders()<0){
Lots=NormalizeDouble(SommeLots_Sell(),Digits)-NormalizeDouble(SommeLots_Buy(),Digits);
int ticket100001=OrderSend(Symbol(),OP_BUY,Lots,NormalizeDouble(Ask,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Blue);
DeletPendOrders();
return;
}
//+------------------------------------------------------------------+
//| First Trades |
//+------------------------------------------------------------------+
if (orderstotal()<1&&Use_BuyOrder==true&&Use_SellOrder==false){
lot1=lot;
int ticket1=OrderSend(Symbol(),OP_BUY,lot1,NormalizeDouble(Ask,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Blue);
}
if (orderstotal()<1&&Use_SellOrder==true&&Use_BuyOrder==false){
lot1=lot;
int ticket2=OrderSend(Symbol(),OP_SELL,lot1,NormalizeDouble(Bid,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Red);
}
//+------------------------------------------------------------------+
//| OpenNext Orders |
//+------------------------------------------------------------------+
if(orderstotal()>0&&TypeLastOrder()=="buy"&&orderstotalPend_Sell()<1&&SommeLots_Buy()!=SommeLots_Sell()){
if(orderstotal()==1)lots=lot2;else lots=LastLotBuy()+Increment_lot;
int ticket11=OrderSend(Symbol(),OP_SELLSTOP,lots,NormalizeDouble(OpenorderBuy()-Gap*point,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Red);
}
if(orderstotal()>0&&TypeLastOrder()=="sell"&&orderstotalPend_Buy()<1&&SommeLots_Buy()!=SommeLots_Sell()){
if(orderstotal()==1)lots=lot2;else lots=LastLotSell()+Increment_lot;
int ticket22=OrderSend(Symbol(),OP_BUYSTOP,lots,NormalizeDouble(OpenorderSell()+Gap*point,Digits),3*Q,SL,TP,"FireStrategy",MagicNumber,0,Blue);
}
//+------------------------------------------------------------------+
//| Close orders at TotalProfit |
//+------------------------------------------------------------------+
if(ProfitAllorders()>=TotalProfit){
CloseBuyOrders();
CloseSellOrders();
DeletPendOrders();
}
//---
}
//+------------------------------------------------------------------+
int orderstotal()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
bool ticket1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber()&&OrderType()!=OP_BUYSTOP&&OrderType()!=OP_SELLSTOP)
{
cnt++;
}
}
return(cnt);
}
//***************
int orderstotalBuy()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
bool ticket1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber())
{
if(OrderType()==OP_BUY) cnt++;
}
}
return(cnt);
}
//****
int orderstotalSell()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
bool ticket2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber())
{
if(OrderType()==OP_SELL) cnt++;
}
}
return(cnt);
}
//*****
double OpenorderBuy()
{
double openorderBuy=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket7=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==OP_BUY)
{
openorderBuy=OrderOpenPrice();
}
}
return(openorderBuy);
}
//---------------------
double OpenorderSell()
{
double openorderSell=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket8=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==OP_SELL)
{
openorderSell=OrderOpenPrice();
}
}
return(openorderSell);
}
//**/////////
string TypeLastOrder() {
string type;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket88=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber ){
if(OrderType()==OP_BUY)type="buy";
if(OrderType()==OP_SELL)type="sell";
}
}
return (type);
}
//*******
double LastLotBuy()
{
double B=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket4=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==OP_BUY)
{
B=OrderLots();
}
}
return(B);
}
//*****************
double LastLotSell()
{
double S=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket5=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderType()==OP_SELL)
{
S=OrderLots();
}
}
return(S);
}
//---
int orderstotalPend_Buy()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
bool ticket1=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber())
{
if(OrderType()==OP_BUYSTOP) cnt++;
}
}
return(cnt);
}
//****
int orderstotalPend_Sell()
{
int cnt=0;
for(int i=0;i<OrdersTotal();i++)
{
bool ticket2=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && MagicNumber==OrderMagicNumber())
{
if(OrderType()==OP_SELLSTOP) cnt++;
}
}
return(cnt);
}
//*****
double ProfitAllorders()
{
double ProfitAllorders=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket112=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
ProfitAllorders=ProfitAllorders+OrderProfit();
}
}
return(ProfitAllorders);
}
//---
void CloseBuyOrders()
{
int cnt=OrdersTotal();
for(int i=cnt-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if(OrderType()==OP_BUY&&OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
bool ticketclose1=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3*Q,Red);
}
}
}
void CloseSellOrders()
{
int cnt=OrdersTotal();
for(int i=cnt-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if(OrderType()==OP_SELL&&OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
bool ticketclose2=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3*Q,Blue);
}
}
}
//---
void DeletPendOrders(){
int cnt=OrdersTotal();
for(int i=cnt-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
if((OrderType()==OP_BUYSTOP||OrderType()==OP_SELLSTOP)&&OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) {
bool ticketclose1=OrderDelete(OrderTicket(),Blue) ;
}
}
}
//---
double SommeLots_Buy(){
double SLot=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket133=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber&&OrderType()==OP_BUY)
{
SLot=SLot+OrderLots();
}
}
return(SLot);
}
//---
double SommeLots_Sell(){
double SsLot=0;
for(int i=0;i<=OrdersTotal();i++)
{
bool ticket133=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber&&OrderType()==OP_SELL)
{
SsLot=SsLot+OrderLots();
}
}
return(SsLot);
}
//*********************************