[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 122

 
Fduch писал(а) >>

By the way, OrdersTotal() returns a number of int type. And int can take values:

I.e. theoretically maximum number of oders: 2147483647

Thank you for your unbiased reply!!!

 

Please help, I can't understand, it's written in the book that this code works:

//--------------------------------------------------------------------
// Book_expert_33.mq4
// Intended as an example in MQL4 tutorial.
//--------------------------------------------------------------------
int Count=0; // Global variable.
//--------------------------------------------------------------------
int init() // Special init()
{
Alert ("The init() function worked at start"); // Message
return; // Exit init()
}
} //--------------------------------------------------------------------
int start() // Special init()
{
double Price=Bid; // Local variable.
Count++; // Tick counter
Alert("New tick ",Count," Price = ",Price);// Message
return; // Exit start()
}
//--------------------------------------------------------------------
int deinit() // Special function deinit()
{
Alert ("Deinit() triggered during upload"); // Message
return; // Exit deinit()
}
//--------------------------------------------------------------------

I don't write prices for new ticks, the function triggers on startup and unloading.



 
Please advise non-programmer where and how to insert Sleep(1200000) to have a delay of 10 minutes after order closing.
Files:
1_1.rar  26 kb
 
v43 писал(а) >>
Please advise a non-programmer where and how to insert Sleep(1200000) to have a 10 min delay after order close, I really need it.

Please - put the code through the SRC bouton - it's impossible to read this way.

For such a long interval it is better not to do it via Sleep, but to wait for such a tick when this time has passed - like:

   static datetime DontCloseBefore = 0;
   //....
   
   OrderSend(....);
   DontCloseBefore = TimeCurrent() + 10*60; //10 minutes
   //....
   
   if( DontCloseBefore!=0)
   {
      if(TimeCurrent()> DontCloseBefore) && ( some other conditions - like existing order))
      {
         DontCloseBefore = 0; //important - reset the state engine
         OrderClose(...);
      }
   }
If DontCloseBefore == 0 then nothing, if there is a delay, then you have to wait until the current time becomes longer than what is prescribed in DontCloseBefore, zero out DontCloseBefore and close
 

Does anyone know if there is a command to find out if a certain Indicator is open in the window, e.g. MA(20) ?

Thank you!

 
chief2000 >> :

Does anyone know if there is a command to find out if a certain Indicator is open in the window, e.g. MA(20) ?

Thank you!



int WindowFind( string name)
Returns the number of the chart subwindow containing indicator with specified name, if it is found, otherwise -1 is returned.
WindowFind() returns -1 if the custom indicator searches itself during init().
 
 
keekkenen >> :


int WindowFind( string name)
Returns number of chart subwindow containing indicator with specified name, if found, otherwise returns -1.
WindowFind() returns -1 if the custom indicator looks for itself during init ().

I see that some clarification is needed:

my goal is to check if MA is running, if yes, find out with what Period. As the result I need to get "20" if there is MA(20).

For this, we can use WindowFind() with a for-cycle, but I don't want to waste computer resources since

this check should only be done once at the beginning (WindowFind() in init() doesn't work?).

 

Please. Someone write a simple EA:

- Open Buy.

- Take=20, Stop Loss=20;

- when close triggered, we open a Buy position again with exactly the same parameters (take=20; stop=20).

-If Stop Loss triggers, we open a Sell with exactly the same parameters (take=20; stop=20), and so on.

The same can be done, but first we open a Sell position instead of a Buy position.

As a symbolic remuneration for the work I can pass an account for 5grn. (If the Ukrainian operators).

 

Why does running MA(20) in the main window

 WindowFind("MA(20)")

returns "-1" ?

Reason: