[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 588

 

Tell me where to find programmers who write EAs!

 

You also have to control the timing of the bar opening:

datetime bartime;

int init()
{
   ...
   bartime=0;
   ...
}

int start
{
   ...
   if(bartime<Time[0]) //если пришел новый бар
   {
       //делаем то что нужно
   }
   ...
   bartime=Time[0]; //обязательно запомнили обсчитанный бар
}

 
supernovik:

Tell me where to find programmers who write EAs!

https://www.mql5.com/ru/forum/116708
 
alsu:
...

3. fill the array for(i=1;i<=PerB;i++) MyATR[i-1]=(High[i]-Low[i])/Low[i]; index i starts from 1 as we need only closed bars

...

check it out, maybe it's just an error

Ok thanks, I will try it in the morning (my head is not good right now), but in this case (i=1) i will be able to refer to Open [0] price of the current bar?

P. S. Ok, I think I've got the gist - I'll try it in the afternoon.

 
Craft:
OK, I'll try, but in this case (i=1) I will be able to refer to the Open price of the current bar Open[0]&
Of course you can, nothing can prevent it. Generally speaking, in MQL one must treat array indexes very carefully, and constantly check them for correctness, because given the lack of debugging tools, the search for a possible error may take weeks. In addition, it often leads to "pseudo-grails" - programs that inadvertently peek 1 bar into the future and therefore give outstanding results during testing, but fail in real time.
 

Didn't hold out until the morning. It got a little better, but the order bloom placements could not be avoided. How can I set up a single order at the required condition? You mentioned: No, that would not work. Only through order history analysis - how can we do that or what else is suitable?

 
alsu:

You also have to control the timing of the bar opening:


Alsu, was that referring to my example?
 
Please advise, I am struggling with EA writing. I need to open a new order when the old one is closed by tp or sl.



I would be glad to help!
 
Top2n:
Please tell me, I am trying to write an EA. I should place a new order when the old one is closed by tp or sl.
I would appreciate it!

You need to separately insert (copy) into the code (outside of the Start) f-i that indicate how the last position was closed.

These are available at: https: //www.mql5.com/ru/forum/107476

pg. 21

The function isCloseLastPosByTake().
This function returns a flag to close the last position by Take. The flag is raised - True - TakeProfit has triggered. Flag lowered - False - position was closed for another reason

The isCloseLastPosByStop() function. This function returns a flag to close the last position by stop. Flag is up - True - StopLoss triggered. Flag lowered - False - position was closed for other reason

-------------------

Most likely, this will also require a f-type:

GetTypeLastClosePos() function. Page 20

This function returns the type of the last closed position or -1

=================================

Then, in the simplest case, the - The opening conditions would be :

//--------------Для бай-сделок-------------

if ( isCloseLastPosByTake(NULL, OP_BUY, -1)==true || isCloseLastPosByStop(NULL, OP_BUY, -1)==true) {

//if the last buy position has closed at take or stop, a new buy position will be opened

/------------

Same for sell trades ....

 

Please tell me how experienced wizards distinguish an EA from an indicator and a script (without "dissecting" it in the editor). I've got everything mixed up in my folders. The EA folder is full of non-working indicators and the indicator folder is full of non-working scripts. So I (just in case) copy the new EA indicator into both folders.

I think this is a big mistake made by the language creators. The file extension should be different.

What do the aksakals have to say?

Reason: