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

 
Ekburg:

What are these functions, what's the point of them? I've never seen or used one before.


It's not a function, it's a way of comparing non-normalized numbers. They cannot be compared to each other, but the result of subtracting one from the other can be compared to zero.

And the check I have is like this:

//+------------------------------------------------------------------+ 
 double ND(double nd){return(NormalizeDouble(nd,Digits));}
//+------------------------------------------------------------------+ 
if(ND(price)!=OrderOpenPrice()||ND(SL)!=OrderStopLoss()||ND(TP)!=OrderTakeProfit()||Expiration!=OrderExpiration())
   {
   OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE);
}
else return;
     
 
lottamer:

Hello forum members,

I decided to write an EA for myself. I'm reading an mql4 tutorial since I trade MT4. And here's the interesting thing. mqh files downloaded from this tutorial open (automatically) in MetaEditor 5 (I also have Mt5 installed)! Does it mean they will not work with Mt4?


Try to compile it and you will find out.
 
rigonich:


This is not a function, but a way of comparing non-normalized numbers. they cannot be compared to each other, but the result of subtracting one from the other can be compared to zero.

And my check is like this:

You say it right, but you do it "your own way"... And it is more literate (after all):

//+------------------------------------------------------------------+ 
 double ND(double nd){return(NormalizeDouble(nd,Digits));}
//+------------------------------------------------------------------+ 
if (ND (price - OrderOpenPrice()) != 0.0 || ND (SL - OrderStopLoss()) != 0.0 || ND (TP - OrderTakeProfit()) != 0.0 || Expiration != OrderExpiration())
{OrderModify( int ticket, double price, double stoploss, double takeprofit, datetime expiration, color arrow_color=CLR_NONE);}

...although I don't agree with all the comparison conditions. You can read about the conditions here.

 
rigonich:

Try to compile and you will find out.

yes...you just need to open these mqh files with 4Editor...
 
Desead:

Need to normalise the price chart, any currency pair of your choice. I need it for an indicator. I tried to divide the current value by the previous one - I get some kind of oscillator around 1. I have come up with an idea that I should convert the chart from absolute to relative values, i.e. in this case I will be able to see the percentage change of quote. It has been implemented. It is already better and practically what we need. However, my ultimate desire is to normalize quotes in the range [0:1] .By the way, here is what I need but in bourgeois - I would like the same in russian: http://people.revoledu.com/kardi/tutorial/Similarity/Normalization.html

I already got tired of fighting with this. I can't delete all pending orders normally, I just don't get the hang of it:

I even added to the loop FOR WHILE the deleted orders are still there, but I still have not deleted them. I have many pending orders to delete, i.e. about 20, may be it is something complicated?


It seems that the problem of deleting the orders has been solved. I use a separate function to count the number of "necessary" (to be removed) orders, Total, call this function and while with a condition (Total>0), then the cycle of removing for (int i=Total-1 ;i<=0l; i--), again f-kind of"necessary", counter of removing attempts with exit fromwhile when the given level is reached. This way all of them are deleted.
 
TarasBY:

Here is an example of deleting orders, including pending ones (I deleted with this one):

Not all pending orders are present in your code (in selection filter). Another error variant: check the Magick received by pending orders when they open (in your own code).

Thank you for your reply. I do not need all pending orders, only bylimit and selllimit and I set them only, the magik is the same everywhere. If I can't solve the problem with my own efforts, I have to look into your scripts, I can't do it otherwise, it just won't delete it.

I was thinking about something. I set the deletion of all pending robots in one place only - when I unload my robot, it will be placed in deinit. Maybe this section has some kind of time limit? When I delete only a few orders, everything is fine, but when I unload a whole grid, then what the hell happens, a dozen orders are always left and it's not an option to clean it manually.

 
rigonich:

Hurrah, it seems I have solved the problem of deleting orders. I calculated the number of "necessary" (to be removed) orders in a separate function, called this function, then while with a condition (Total>0), then the cycle of removing for(int i=Total-1 ;i<=0l; i--), again, the function of counting the "necessary", counter of removal attempts with the exit fromwhile when the specified level is reached. This way everything is deleted.
By the way, this is a good alternative, let this while keep on running its loop till the end of the world, thank you, I will try it now.
 

you need to insert the terms HAVE an open trade (one, without any majors) in one row, for example, with a crossover of averages.

found this

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

int start()

{

for(int i=0; i<OrdersTotal(); i++)

{

if ((OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) )

PlaySound ("alert.wav");

return(0);

}}

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

There isan open position but no sound.

Can you tell me what's wrong?

Or how easy it is to write the condition:

IF MA 5 crosses MA 10 and there is an open position - close that position.

this seems to be where void.... is needed

 
lottamer:

Yes...you just need to open these mqh files with 4Editor...

If they are from MQL4 tutorial, they will be opened by4thEditor. Put them in the includ folder or rename them tomq4 and put them in the Expert folder, the main one if it is an EA, or the scripts or indicators folders respectively, and open them.
 
Desead:
Good option by the way, and let this while race its cycle to the end of the world until it deletes the orders, thanks, I'll try it now.


It takes 2.5 seconds to execute it in mt4.
Reason: