[ARCHIVE!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Can't go anywhere without you - 4. - page 246

 
Zhunko:
Where is OBJECT_PREFIX initialised?

In global variables
 
Stells:

in global variables
Then print the object name and prefix.
 

How do I calculate a profit for an order?

if(OrderType() == 0) profitbuy += ((Bid - OrderOpenPrice())*OrderLots()*(tickvalue/ticksize))+OrderSwap()+OrderCommission();

What have I done wrong? On Eur/Usd it works, but on Usd/Jpy it works, but not correctly.

 

I've decided to try using the change timeframe function, it seems easier and clearer to me. It does not compile. Maybe it's me, of course something stupid. I have written it in this way.

'fChangePeriod' - variable not defined C:\terminal\experts/indicators/timeframe.mq4 (37, 12)

'WM_COMMAND' - variable not defined C:Terminal/experts/indicators/timeframe.mq4 (62, 22)

//+------------------------------------------------------------------+
//|                                                    таймфрейм.mq4 |
//|                        Copyright 2012, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2012, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
extern int nPeriod=30,P=1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if(P<0){fChangePeriod;P--;}
//----
   return(0);
  }
//+------------------------------------------------------------------+

void fChangePeriod(int nPeriod)
{
   int hWnd, wParam;
   
   switch(nPeriod)
   {
      case PERIOD_M1:  wParam = 33137; break;
      case PERIOD_M5:  wParam = 33138; break;
      case PERIOD_M15: wParam = 33139; break;
      case PERIOD_M30: wParam = 33140; break;
      case PERIOD_H1:  wParam = 33135; break;
      case PERIOD_H4:  wParam = 33136; break;
      case PERIOD_D1:  wParam = 33134; break;
      case PERIOD_W1:  wParam = 33141; break;
      case PERIOD_MN1: wParam = 33334; break;
   }
        
   hWnd = WindowHandle(Symbol(),Period());
        
   PostMessageA(hWnd,WM_COMMAND,wParam,0);
}
 
I don't know dll yet, for this script to work, should I put this dll in one of the folders? I'm a little confused.
 
Vinin:

Give me the code.

Don't be silent, say something, am I thinking straight or not?

 
Regarding the library, WinAPI functions, what is the root directory where ServicesMT4.rar should be placed? Just look ServicesMT4.rar, opened it, also no way - opening programs swear, wrong format specified.
 
Dimka-novitsek:
As for the library, WinAPI functions, what is the root directory in which you need to save ServicesMT4.rar? Just look ServicesMT4.rar, opened it, also does not work - programs openers swear, wrong format is specified.

There is a script included with examples of how to use all the library functions. Everything can be done in the same way.

The archive should be unpacked in MT4 directory or unpack everything separately. There is also an instruction with 5 points.

The archive is open for me. I just checked it. You should not make it up. I recommend that you read the instructions carefully.

Here is an example of an Expert Advisor:

#include <ServicesMT4.mqh>
void start()
  {
   int hwndChart = WindowHandle(Symbol(),Period());
   while (!IsStopped())
    {
     for (int i = 0; i < 9; i++)
      {
       ServiceSetTimeframeByNumber(hwndChart, i);
       Sleep(2000);
      }
    }
  }
 

Well, I think I've read... The files

ServicesMT4.mqh (94.1 Kb) View
WinUser32.mqh (70.3 Kb) View
Check_ServicesMT4.dll.mq4 (115.2 Kb)
ZH_All_Quotings 4.10912.mq4 (8.4 Kb) View

I put the files where they belong, no problem.

But this is 4. Unpack the archive with all of these and the library in MT4 directories to the root directory of MT4.

I do not understand it. What is the root directory? And how to remove ZIP from archive's name? Yes, the archive simply saved in the left folder on my computer, so I, it is signed there, I do not see in the name of ZIP, it is called ServicesMT4.rar, true, the extension is ZIP, but how to change it, if I need? Maybe not, but what is the root directory?

 
Dimka-novitsek:

Well, I think I've read... Files

ServicesMT4.mqh (94.1 Kb) View
WinUser32.mqh (70.3 Kb) View
Check_ServicesMT4.dll.mq4 (115.2 Kb)
ZH_All_Quotings 4.10912.mq4 (8.4 Kb) View

I put it without problems where it should be.

But this is 4. I unpacked the archive with all of these and the library in MT4 directories to the root MT4 directory.

I do not understand it. What is the root directory? And how to remove ZIP from archive's name? Yes, the archive simply saved in the left folder on my computer, so I, it is signed there, I do not see in the name of ZIP, it is called ServicesMT4.rar, true, the extension is ZIP, but how to change it, if I need? Maybe not necessary, but what is the root directory?

1. The listed files are in the archive. But the archive also contains the most important file of ServicesMT4.dll library itself. Otherwise it cannot be attached. We were recently deprived of this possibility.

2. The root directory of MT4 is the directory of your MT4. How else to explain it simply - I don't know.

To see the extensions, you have to configure the visibility of these extensions in the properties of the folder. I am very surprised that the programmer has disabled the visibility of extensions. Just like a dummy.

4. Hopefully after this it won't be difficult to rename the extension. Just in case, this is done from the right-click context menu of the mouse.

5. I have WinRar opening this file with any extension. The extension is only required to automatically associate files with programs to open them.

Reason: