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

 
MixanM #:

Hello, I have recently started working with MT4 and came across the following issue: there is no proper function to track a closed order. My algorithm is simple: when a new candle appears, I place two pending orders: a Sell Stop and a Bid Stop and I need to follow the closed order (Sell Stop or Bid Stop) when one of them closes and place one order instead of the closed one. Orders are placed - no problem, but I can not understand how to track closed ones, I put the code, but the message displays only SellSTOP, BAYSTOP does not respond:

//+----------------------------------------------------------------------------+
int LastClose()
  {
   int result=-1;
   datetime t=0;
   int i=OrdersHistoryTotal()-1;
   for(int pos=i;pos>=0;pos--)
     {
      if(OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY))
        {
         if(OrderSymbol()==_Symbol)
           {
            if(OrderType()==OP_BUY||OrderType()==OP_SELL)
              {
               if(t<OrderCloseTime())
                 {
                  t=OrderCloseTime(); result=OrderType();
                 }
              }
           }
        }
     }
   return(result);
  }
//+----------------------------------------------------------------------------+

MixanM OnTradeTransaction doesn't work , tried this:

It seems to be for MT5
 
Hello all, friends.
Here's a question.
The copying of deals on this service has not changed in so many years. The impression has long been that the developers are not at all interested in thinking about the convenience of its visitors.
It took the need of their own project.

I don't know if it's possible ?

1) I need the copier of deals, ( advisor ) I do not know what the load and how it is measured, you need that it would be able to copy from one and distribute more than a hundred accounts.
The question about copying. My aim is to get a trades volume based on deal percentages (i.e. I have 100 on my account; my follower has 1000 on his account; I open deal with 3% of my deposit and lot volume is recalculated by percentage of my deal; i.e. my deal with 3% is $3; follower has an open deal with 3% = $30; i.e. I don't know if it is really important or not).


2) Is it possible to withdraw a Subscriber's account details? I.e. first name, last name but most importantly the amount on the balance? If it is not possible to withdraw all the information, what is possible?

3) Dear programmers, Estimate the approximate cost of such a job, I do not want to be deceived and want to understand the adequate price.
Thank you!
 
Roman Voloshchuk Copying transactions on this service hasn't changed in so many years. The impression has long been that the developers are not at all interested in thinking about the convenience of its visitors.
It took the need of their own project.

I do not know if it is possible ?

1) I need the copier of deals, ( advisor ) I do not know what the load and how it is measured, you need that it would be able to copy from one and distribute more than a hundred accounts.
The question about copying. My aim is to get a trades volume based on deal percentages (i.e. I have 100 on my account; my follower has 1000 on his account; I open deal with 3% of my deposit and lot volume is recalculated by percentage of my deal; for this reason my deal with 3% is $3 while follower has opened deal with 3% = $30.


2) Is it possible to withdraw his account details? I.e. first name, last name but most importantly the amount on the balance? If it is not possible to withdraw all the information, what is possible?

3) Dear programmers, Estimate the approximate cost of such a job, I do not want to be deceived and want to understand the adequate price.
Thank you!

Subscriber data is harmful to take out.

Again, you have 50 in your account with a leverage of 500 and a subscriber has 5000 with a leverage of 33.

There's kind of a little bit of a calculation problem here. That's if we're talking about this service.

If we're talking about self-copying, then:

you have 50 in your account with a leverage of 2000 and a subscriber 5000 with a leverage of 33.

You will be able to open 3 positions with a small leverage while the subscriber will have no money left after the second one, as he will be exposing himself to margin.

---

It's not that simple.

 

Tretyakov Rostyslav #:
Это вроде для МТ5С

Thanks for the code, but yours also returns only even-numbered orders (SELLSTOP) for some reason, I can't understand why, maybe the sorting is wrong/ (I am running the code in the tester - maybe that's the problem?)

 
MixanM #:

Thanks for the code, but yours also returns only even-numbered orders (SELLSTOP) for some reason, I can't understand why, maybe the sorting is wrong/ (I am running the code in the tester - could this be the problem?)

my code returns the type of the last closed order - "0-Buy" or "1-Sell"
 
Tretyakov Rostyslav #:
my code returns the type of the last closed order - "0-Buy" or "1-Sell"

Well yes, that's what I meant - that it only returns data for a "sellstop" order. I added this to yours just to check visually:

...

if(t<OrderCloseTime())

{

t=OrderCloseTime(); result=OrderType();

Print("Order TIP :", OrderTicket());

}

....

 
MixanM #:

Well yes, that's what I meant - that it only returns data for a "sellstop" order. I added this to yours, just to check it visually:

Everything works correctly


 

As a newcomer, can you tell me if the return operator passes control back to the for loop or to the OnTick function?

void OnTick()
{
  for (выражение)
    {
        if (выражение)
         {
            .....
            ....
            return;
         }
    }
}
 
Олег Иванов the return operator pass control back to the for loop or to the OnTick function?

Return from the OnTick function

 
Олег Иванов the return statement transfer control back to the for loop or to the OnTick function?

The continuestatement passes control back to the beginning of the nearest external while, do-while or for statement

Reason: