新人对MQL4和MQL5的任何问题,对算法和代码的帮助和讨论 - 页 1138

 
Igor Makanu:

我已经很久没有使用SB了,我已经不记得一半了,但可以尝试通过每次对OBJ_EDIT对象做ChartRedraw()来进行软件选择和取消选择,你可以从SB中获得对象的名称,一定有一个Name方法

如果

HH:ChartRedraw()可能需要Sleep(),但Sleep()在指标中不起作用。

如果你的意思是让对象 属性OBJPROP_SELECTED 为 "真",则不是这样的。因为在这种情况下,该对象将在图表上被高亮显示,但输入框不会变成活动的。
 
Maksym Mudrakov:
如果你的意思是让对象 属性OBJPROP_SELECTED 为真,那就不是了。因为在这种情况下,该对象将在图表上被高亮显示,但输入框不会变成活动的。

在所有面板上勾选,它不能突出OBJ_EDIT对象的工作。

我不知道,请在论坛上搜索。

"标签"

"标签"

"输入焦点"

 
有什么方法可以在不关闭终端 的情况下更新MQL5/logs/*.log文件?要查看其新鲜的内容。
 
ascerdfg:
有什么方法可以在不关闭终端的情况下更新MQL5/logs/*.log文件?要查看其新鲜的内容。

在终端的右键点击上下文菜单--打开 ,这允许访问日志文件

不方便

 
Igor Makanu:

在终端的右键点击上下文菜单--打开 ,这允许访问日志文件

不方便

我应该在哪里点击?
 
ascerdfg:
我应该在哪里点击?

Rzewski不得不闭嘴......


 
Maksym Mudrakov:

该图有两个类型为OBJ_EDIT 的对象

目标是通过按Tab键来实现这两个输入字段之间的转换。

主要问题不是读取键盘事件,而是如何以编程方式使输入字段活跃起来。

我明白你需要使用user32.dll,但由于我不擅长,请帮助。

谢谢你。

解决办法已经找到。

#property strict

struct RECT
  {
   int               Left;   // x position of upper-left corner
   int               Top;    // y position of upper-left corner
   int               Right;  // x position of lower-right corner
   int               Bottom; // y position of lower-right corner
  };
struct POINT
  {
   int               posX;   // x position
   int               posY;   // y position
  };

#import "user32.dll"
void  mouse_event(int dwFlags,int dx,int dy,int dwData,int dwExtraInfo);
bool  GetWindowRect(int hWnd,RECT &lpRect);
int   GetSystemMetrics(int nIndex);
bool  GetCursorPos(POINT &lpPoint);
bool  SetCursorPos(int x,int y);
#import

string edits[], pref;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   pref="EA_EDIT_SELECT_";
   int size=6;
   ArrayResize(edits,size);

   int width=100, heigh=25;
   int x=width, y=heigh;
   for(int i=0; i<size; i++)
     {
      string num=(string)(i/2+1);
      string text="Name ";
      edits[i]=pref+(string)i;
      if(i%2==0)
        {
         text="First "+text+num;
         x=width;
         y+=heigh+5;
        }
      else
        {
         text="Last "+text+num;
         x=2*width+5;
        }
      EditCreate(edits[i],x,y,width,heigh,text);
     }
   EventEditSelect(edits);
   return(INIT_SUCCEEDED);

  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   ObjectsDeleteAll(0,pref,-1,-1);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id == CHARTEVENT_KEYDOWN)
      EventEditSelect(edits);
   else
      if(id == CHARTEVENT_OBJECT_ENDEDIT)
        {
         bool stateTab=TerminalInfoInteger(TERMINAL_KEYSTATE_TAB)<0;
         if(stateTab)
            EventEditSelect(edits);
        }
  }
//--------------------------------------------------------------------+
//      Create Edit                                                   |
//--------------------------------------------------------------------+
void EditCreate(string           name="Edit",              // object name
                int              x=0,                      // X coordinate
                int              y=0,                      // Y coordinate
                int              width=50,                 // width
                int              height=18,                // height
                string           text="Text")              // text
  {
   ObjectCreate(0,name,OBJ_EDIT,0,0,0) ;
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
   ObjectSetString(0,name,OBJPROP_TEXT,text);
   ObjectSetString(0,name,OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,12);
   ObjectSetInteger(0,name,OBJPROP_ALIGN,ALIGN_CENTER);
   ObjectSetInteger(0,name,OBJPROP_READONLY,false);
   ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
   ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrWhite);
   ObjectSetInteger(0,name,OBJPROP_BORDER_COLOR,clrGray);
   ObjectSetInteger(0,name,OBJPROP_BACK,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,false);
   ObjectSetInteger(0,name,OBJPROP_SELECTED,false);
  }
//--------------------------------------------------------------------+
//      MOVE BETWEEN OBJ_EDIT BY TAB KEY                              |
//--------------------------------------------------------------------+
void EventEditSelect(string &editNames[])
  {
   bool back=TerminalInfoInteger(TERMINAL_KEYSTATE_SHIFT)<0;

   int size=ArraySize(editNames);
   if(size==0)
      return;
   static int index=0;

   if(!back)
     {
      if(index==size-1)
         index=0;
      else
         index++;
     }
   else
     {
      if(index==0)
         index=size-1;
      else
         index--;
     }

   string name=editNames[index];
   int x=(int)ObjectGetInteger(0,name,OBJPROP_XDISTANCE);
   int y=(int)ObjectGetInteger(0,name,OBJPROP_YDISTANCE);
   int width=(int)ObjectGetInteger(0,name,OBJPROP_XSIZE);
   int height=(int)ObjectGetInteger(0,name,OBJPROP_YSIZE);

   MouseClick(int ((2*x+width)/2),int((2*y+height)/2));
  }
void MouseClick(const int x, const int y)
  {
   Sleep(50);
   POINT currentPoint;
   GetCursorPos(currentPoint);
   POINT clickPoint=ConvertXY(x,y);
   mouse_event(0x8007,clickPoint.posX,clickPoint.posY,0,0);
   SetCursorPos(currentPoint.posX,currentPoint.posY);
   Sleep(50);
  }
POINT ConvertXY(const int x,const int y)
  {
   POINT AbsolutePoint;
   RECT  WndRect;
   int BorderX=5,BorderY=5;
   int screenX=GetSystemMetrics(0);
   int screenY=GetSystemMetrics(1);
   GetWindowRect(WindowHandle(_Symbol,_Period),WndRect);
   AbsolutePoint.posX=int ((x+WndRect.Left+BorderX)*65535/screenX);
   AbsolutePoint.posY=int ((y+WndRect.Top +BorderY)*65535/screenY);
   return(AbsolutePoint);
  }
 
MQL5,ObjectCreate没有绘制任何东西,对象甚至没有出现在对象列表中。创建是在OnInit完成的,也许这就是问题所在?
同时,如果我们将机器人从图表中移除,创建的对象 将被显示出来
 
Roman Sharanov:
MQL5,ObjectCreate没有绘制任何东西,对象甚至没有出现在对象列表中。创建是在OnInit完成的,也许这就是问题所在?
然而,如果我们从图表中移除机器人,所创建的对象 将被显示出来

有可能对象坐标的价格和时间都等于零。这样检查:按Ctrl+B,在出现的对话框中,按 "全部 "按钮,查看现有对象的列表。如果有,打开属性,看看坐标。

 
Artyom Trishkin:

Rzewski不得不闭嘴......


在什么时候你必须右键单击?
原因: