Godot zrobił tylko szkic, potwierdził tym samym, że patent działa. Ale szkic to szkic i ten szkic trzeba by dopracować.
Do super EA trzeba pewnie włożyć dużo pracy i czasu resztę sami rozumiecie
Pewnie tak jak ze skryptami z hotkey ten temat z czasem się rozwinie tyle, że ten chyba jest już bardziej zaawansowany. Uczmy się.
Akcja z klawisza
besot pisze:U mnie nie działa sell pokazuje się komunikat invalid stops Czy kontynuowac? i nie składa zlecenia a bay działa.
Kod: Zaznacz cały
//+------------------------------------------------------------------+
//| KeyAction.mq4 |
//| Copyright © 2008, Godot. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Godot."
#property link ""
#include <WinUser32.mqh>
#include <stdlib.mqh>
#property show_inputs
//----global variables
extern bool allplatforms = False;
extern double lots = 1;
extern int stoploss = 10;
extern int takeprofit = 0;
#import "IdleLib.dll"
extern int GetLastKeyWP();
extern int GetLastMouseWP();
extern int IdleLibInit();
extern int IdleLibUnInit();
extern string GetActiveWndName();
//----constans
#define K_BSP 8
#define K_TAB 9
#define K_SHIFT 16
#define K_CTRL 17
#define K_ALT 18
#define K_PAUSE 19
#define K_SPACE 32
#define K_PGUP 33
#define K_PGDN 34
#define K_END 35
#define K_HOME 36
#define K_LEFT 37
#define K_UP 38
#define K_RIGHT 39
#define K_DOWN 40
#define K_PRT_SCR 44
#define K_INSERT 45
#define K_DELETE 46
#define K_0 48
#define K_1 49
#define K_2 50
#define K_3 51
#define K_4 52
#define K_5 53
#define K_6 54
#define K_7 55
#define K_8 56
#define K_9 57
#define K_A 65
#define K_B 66
#define K_C 67
#define K_D 68
#define K_E 69
#define K_F 70
#define K_G 71
#define K_H 72
#define K_I 73
#define K_J 74
#define K_K 75
#define K_L 76
#define K_M 77
#define K_N 78
#define K_O 79
#define K_P 80
#define K_Q 81
#define K_R 82
#define K_S 83
#define K_T 84
#define K_U 85
#define K_V 86
#define K_W 87
#define K_X 88
#define K_Y 89
#define K_Z 90
#define K_F1 112
#define K_F2 113
#define K_F3 114
#define K_F4 115
#define K_F5 116
#define K_F6 117
#define K_F7 118
#define K_F8 119
#define K_F9 120
#define K_F10 121
#define K_F11 122
#define K_F12 123
//---variables
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
double start() {
int lastkey, trigger;
string lastwnd;
ObjectCreate("keyaction",OBJ_LABEL,0,0,0);
ObjectSet("keyaction",OBJPROP_CORNER,0);
ObjectSet("keyaction",OBJPROP_COLOR,Red);
ObjectSet("keyaction",OBJPROP_FONTSIZE,10);
ObjectSet("keyaction",OBJPROP_XDISTANCE,0);
ObjectSet("keyaction",OBJPROP_YDISTANCE,0);
ObjectSetText("keyaction","");
IdleLibInit();
while(lastkey != 27) {
lastkey = GetLastKeyWP();
lastwnd = GetActiveWndName();
if(allplatforms)
lastwnd="Go";
if((lastkey != 0) && (lastwnd != "")){
if(trigger != lastkey) {
trigger = lastkey;
}
else {
lastkey = 0;
trigger = 0;
}
}
else {
lastkey = 1;
trigger = 1;
}
//---
switch(lastkey) {
case K_C: CloseAll();
continue;
case K_R: OrderRevers();
continue;
case K_B: OrderOpen(0);
continue;
case K_S: OrderOpen(1);
continue;
default : {ObjectSetText("keyaction","");Sleep(250);}
}
if(lastkey != 0)
Print(" "+lastkey);
}
IdleLibUnInit();
return(0);
}
//----------------------------------------------------------------------------------+
//----------------------------------------------------------------------------------+
//----------------------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| funkcja odwracająca pozycję |
//+------------------------------------------------------------------+
int OrderRevers() {
int cmd;
ObjectSetText("keyaction","ZLECENIE ODWROTNE");
if(OrdersTotal() > 0) {
while(!OrderSelect(0,SELECT_BY_POS,MODE_TRADES)){}
cmd = OrderType();
CloseAll();
if(cmd == OP_BUY)
OrderOpen(1);
else
OrderOpen(0);
}
else
return(0);
return(0);
}
//+--------------------------------------------------------------------+
//| funkcja zamykająca wszystkie otwarte pozycję, pomijając oczekujące |
//+--------------------------------------------------------------------+
void CloseAll() {
bool result;
int i, cmd, ntr;
double price;
//----
ObjectSetText("keyaction","ZAMYKANIE POZYCJI");
for(i=0; i<OrdersTotal(); i++) {
OrderSelect(i, SELECT_BY_POS);
cmd = OrderType();
result = false;
if(cmd < 2) {
ntr=0;
while(result != true) {
if(cmd == OP_BUY) price = MarketInfo(OrderSymbol(),MODE_BID);
else price = MarketInfo(OrderSymbol(),MODE_ASK);
result = OrderClose(OrderTicket(), OrderLots(), price, 3, CLR_NONE);
ntr++;
if(ntr==3)// co trzecia nieudana próba pyta
if(MessageBox(StringConcatenate(ErrorDescription(GetLastError()), "\n\nCzy kontynuować ?"), "INFORMACJA", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1) == IDNO)
return(0);
else ntr = 0;
RefreshRates();
}
i--;
}
}
}
//+------------------------------------------------------------------+
//| funkcja OpenOrder(int cmd);argumenty OP_BUY OP_SELL |
//+------------------------------------------------------------------+
int OrderOpen(int cmd)
{
ObjectSetText("keyaction","OTWIERANIE ZLECENIA");
int nNum = 0,ticket = -1,ntr = 3;
double price,sl=0,tp=0;
while(ticket==-1) {
if(cmd == OP_BUY) {
price = MarketInfo(Symbol(),MODE_ASK);
if(stoploss > 0)
sl = price-(stoploss*Point);
if(takeprofit > 0)
tp = price+(takeprofit*Point);
}
else {
price = MarketInfo(Symbol(),MODE_BID);
if(stoploss > 0)
sl = price+(stoploss*Point);
if(takeprofit > 0)
tp = price+(takeprofit*Point);
}
ticket = OrderSend(Symbol(), cmd, lots, price, 3, sl, tp, StringConcatenate("MagicNumber: ", DoubleToStr(1, 0), ": Go"), 1,CLR_NONE);
nNum ++;
if(nNum >= ntr) { //co ntr nieudana próba pyta czy kontynuować
PlaySound("timeout.wav");
if(MessageBox(StringConcatenate(ErrorDescription(GetLastError()), "\n\nCzy kontynuować ?"), "INFORMACJA", MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON1) == IDNO)
return(0);
else nNum = 0;
}
RefreshRates();
}
return(1);
}
poprawione
EDIT : prosze używać przycisku Code do umiesczania kodów Mod Andrzej Pierz
Dodano po 4 godzinach 33 minutach:
a przepraszam Pana Moda, nie wiedzialem gdyz jestem tu nowy i wszystko tez ciezko pamietac:)
na przyszlosc bede mial to na uwadze:)
dzieki
Ucze sie ucze:) i sie jeszcze dlugo uczyc bede...