نهاركم سعيد
فكرة الاكسبرت وضع اوامر بيع و شراء علا الشرت في المكان المراد بواسطة الفارة
buy limit = B + left mouse click in disired place on the chart
sell limit = S + left mouse clic
المشكلة الاكسبرت يعمل جيدا علا كل الازواج ماعدا ازواج اليان مرة يعمل و 10 لا و حتى المرات اللتي لا يعمل فيها لا ياتي باي رسالة خطاء على هذه الازواج
هذا الكود الرجاء المساعدة و لو بفكرة
//+------------------------------------------------------------------+
//| BetaTrader1.mq4 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| MQL5: automated forex trading, strategy tester and custom indicators with MetaTrader |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#import "user32.dll"
bool GetAsyncKeyState(int nVirtKey);
#import
#define KEYEVENTF_EXTENDEDKEY 0x0001
#define KEYEVENTF_KEYUP 0x0002
extern double Risk = 5 ;
extern int TakeProfit = 50;
extern int StopLoss = 20 ;
extern int MagicNumber = 1234;
int ticket ;
extern double LotSize = 0.01 ;
double pips;
#define VK_LBUTTON 1 //Left mouse button
#define VK_CONTROL 17 //B key
#define VK_MENU 18 //S key
#define VK_B 66
#define VK_S 83
double prix ;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
double ticksize=MarketInfo(Symbol(),MODE_TICKSIZE);
if (ticksize==0.00001 || ticksize==0.001)
pips = ticksize*10;
else
pips = ticksize;
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
const long &lparam,
const double &dparam,
const string &sparam)
{
//---************************************************** *************getting mouse data********************************//
if( id==CHARTEVENT_CLICK && GetAsyncKeyState(VK_B ) )
{
int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
ChartXYToTimePrice(0,x,y,window,dt,price);
prix = NormalizeDouble(price,5);
//************************************************** ********************Trading*********************** *****************//
ticket = OrderSend(Symbol(),2,LotSize,prix,2,prix-(StopLoss*pips),prix +(TakeProfit*pips),NULL,MagicNumber,0,clrNONE);
if (ticket < 0)
{
Print("open buyLimit error ==",GetLastError());
}
}
// ---************************************************** *************getting mouse data********************************//
if( id==CHARTEVENT_CLICK &&GetAsyncKeyState(VK_S ) )
{
int x =(int)lparam;
int y =(int)dparam;
datetime dt =0;
double price =0;
int window=0;
ChartXYToTimePrice(0,x,y,window,dt,price);
prix = NormalizeDouble(price,5);
//************************************************** ********************Trading*********************** *****************//
ticket = OrderSend(Symbol(),3,LotSize,prix,2,prix+(StopLoss *pips),prix-(TakeProfit*pips),NULL,MagicNumber,0,clrNONE);
if (ticket < 0)
{
Print("open SellLimit error ==",GetLastError());
}
}
}
//+------------------------------------------------------------------+