Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 953

 
Rustam Bikbulatov:

What's wrong with me? How can I make only open orders be considered? This code also captures partially closed orders, which I do not need

Actually I do not understand it a bit. Why does the function of the int type return a value of the string type? It doesn't throw an error during compilation?
 
Igor Kryuchkov:

I have anOBJ_RECTANGLE object linked by price and time, not by coordinates.

И? That's correct. When you compress the timeline, the rectangle is also compressed. Is it logical? Are you struggling with logic?

Keep track of the shift in the graph.

 
Artyom Trishkin:

И? That's right. When you shrink the timeline, the rectangle shrinks too. Is that logical? Are you struggling with logic?

Track the shift in the graph.

Please tell me which way to dig.

 
Igor Kryuchkov:

Please tell me which way to go.

You've quoted from my post exactly what I told you to do.

There are several types of objects that you can use for your purposes. What you are using now is definitely not the right one.

That leaves several options. And all of them are here, you just have to read and ask what you don't understand:

Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Типы объектов
  • www.mql5.com
При создании графического объекта функцией ObjectCreate() необходимо указать тип создаваемого объекта, который может принимать одно из значений перечисления ENUM_OBJECT. Дальнейшие уточнения свойств созданного объекта возможно с помощью функций по работе с графическими объектами.
 
Igor Kryuchkov:

Please tell me which way to go.

The objects I have shown above and this:

Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Типы событий графика
Документация по MQL5: Константы, перечисления и структуры / Константы графиков / Типы событий графика
  • www.mql5.com
Существуют 11 видов событий, которые можно обрабатывать с помощью функции предопределенной функции OnChartEvent(). Для пользовательских событий предусмотрено 65535 идентификаторов в диапазоне от CHARTEVENT_CUSTOM до CHARTEVENT_CUSTOM_LAST включительно. Для генерации пользовательского события необходимо использовать функцию EventChartCustom...
 
Artyom Trishkin:

The objects I showed above, and this:

I don't see an object to solve my problem, do you? Unless OBJ_TEXT supports a frame!?

 


Rectangle_label is what I need.

But I tried to translate Time, Price with ChartTimePriceToXY into coordinates. I was able to draw in the right place, but again, when scrolling the chart, it stands in place, which doesn't work for me.


It's the same story with BitMap, because it's attached by coordinates, which means all BitMaps will stand in place when scrolling the chart, it doesn't suit me.


Then overall question, is it possible to implement my idea I described above?

 
Igor Kryuchkov:


Rectangle_label is what I need.

But I tried to translate Time, Price with ChartTimePriceToXY into coordinates. I was able to draw in the right place, but again, when scrolling the chart, it stands in place, which doesn't work for me.


It's the same story with BitMap, because it's attached by coordinates, which means all BitMaps will stand in place when scrolling the chart, it doesn't suit me.


Then overall question, is it possible to implement my idea that I described above?

Yes.

I gave you the help link for OnChartEvent()

 

Hi all, I have a problem with lstrcpyW () on MT5,


lstrcpyW () defined in winbase.mqh:string lstrcpyW(ushort &string1[],const string string2);


this code copies string to clipboard, how do I change it to make it work


//+------------------------------------------------------------------+
//| This piece of code will copy any text we want to the clipboard   |
//+------------------------------------------------------------------+
/*
#import "kernel32.dll"
   int GlobalAlloc(int Flags, int Size);   long                 GlobalAlloc(uint flags,ulong bytes);
   int GlobalLock(int hMem);               long                  GlobalLock(HANDLE mem);            
   int GlobalUnlock(int hMem);             int                    GlobalUnlock(HANDLE mem);
   int GlobalFree(int hMem);               long                 GlobalFree(HANDLE mem);
   int lstrcpyW(int ptrhMem, string Text);
#import


#import "user32.dll"
   int OpenClipboard(int hOwnerWindow);         int   OpenClipboard(HANDLE wnd_new_owner)
   int EmptyClipboard();                        int   EmptyClipboard(void);
   int CloseClipboard();                        int   CloseClipboard(void);
   int SetClipboardData(int Format, int hMem);  long  SetClipboardData(uint format,HANDLE mem);
#import
*/
#define  GMEM_MOVEABLE   2
#define  CF_UNICODETEXT  13



#include <WinAPI\winuser.mqh>
#include <WinAPI\winbase.mqh>
// Copies the specified text to the clipboard, returning true if successful
bool CopyTextToClipboard(string Text)
{ 
   bool bReturnvalue = false;
   long wnd_new_owner=0 ;
   // Try grabbing ownership of the clipboard 
   if (OpenClipboard(wnd_new_owner) != 0) {
      // Try emptying the clipboard
      if (EmptyClipboard() != 0) {
         // Try allocating a block of global memory to hold the text 
         int lnString = StringLen(Text);
         long hMem = GlobalAlloc(GMEM_MOVEABLE, lnString * 2 + 2);
         if (hMem != 0) {
            // Try locking the memory, so that we can copy into it
            long ptrMem = GlobalLock(hMem);
            if (ptrMem != 0) {
               // Copy the string into the global memory
               lstrcpyW(ptrMem, Text);            
               // Release ownership of the global memory (but don't discard it)
               GlobalUnlock(hMem);            

               // Try setting the clipboard contents using the global memory
               if (SetClipboardData(CF_UNICODETEXT, hMem) != 0) {
                  // Okay
                  bReturnvalue = true;   
               } else {
                  // Failed to set the clipboard using the global memory
                  GlobalFree(hMem);
               }
            } else {
               // Meemory allocated but not locked
               GlobalFree(hMem);
            }      
         } else {
            // Failed to allocate memory to hold string 
         }
      } else {
         // Failed to empty clipboard
      }
      // Always release the clipboard, even if the copy failed
      CloseClipboard();
   } else {
      // Failed to open clipboard
   }

   return (bReturnvalue);
}




void OnStart(){

bool re = false ;

re =CopyTextToClipboard("11111");

printf(re);

}
 
Reason: