Can I call MathSrand() multiple times in EA? - page 2

 
It's still very confusing why you would need to randomize your magic numbers. If you think it will trick the broker then that's not going to accomplish your goal. Your broker doesn't care what magic number is they only care whether an account is on book A or book B, and if it were really that easy to trick the dumb brokers we'd all be baiting them with fake stops to get better fills. If you want to manage a pool of orders by date just use the date. Magic numbers were implemented in order to create a unique ID so mql programs can know which orders to manage. In summary, randomizing magic numbers to fool the broker won't work/matter so use the date and avoid the inevitable errors you will introduce...
 

Ilan, est-ce que ce genre de codage peut vous aider?


Files:
Capture.JPG  54 kb
 
SanjayBalraj:
It's still very confusing why you would need to randomize your magic numbers. If you think it will trick the broker then that's not going to accomplish your goal. Your broker doesn't care what magic number is they only care whether an account is on book A or book B, and if it were really that easy to trick the dumb brokers we'd all be baiting them with fake stops to get better fills. If you want to manage a pool of orders by date just use the date. Magic numbers were implemented in order to create a unique ID so mql programs can know which orders to manage. In summary, randomizing magic numbers to fool the broker won't work/matter so use the date and avoid the inevitable errors you will introduce...

 I agree with you, that trying to trick the broker by changing magic numbers won't work.  However, I know some people might disagree with us.  I was trying to include an option for someone where I can say "ok, you think brokers may track by magic number, and you don't like that.  so here is an option to prevent that."

That little nugget came into my mind, and I wanted to see if I could tackle the issue.  I found a way to make it 'work'.  If I only call rand() right after seeding with a constant seed, it returns the same number every time. So using the day+month from OrderOpenTime()as the seed will return the magic number that I used from that same day.  But I see I've been trying to solve an imaginary problem, though. I guess it just turned into a puzzle for me that I had to crack, rather than trying to find effective code.  What I was trying to do would probably also cause problems for people that were trying to use another EA to interact with orderhistory for example.  Thank you for your help.

 
whroeder1:

That is because you refused to answer the question "why do you think you need a random number." That answer is your true issue. I answered your question (#3) that you do not want random MNs (which you ignored,) and others also asked (which you refuse to answer, and insist on your way.)

If you use any random sequence, then on a terminal restart, you will have a new MN and loose connection with any open orders. #6 is wrong the moment you hold an order overnight . All you've done is alienate those trying to help you and your "solution" will cost you.

Yes, you are right.  Thank you for posting the link earlier. I've been studying what you said, and I think building an array of magic numbers for the different strategies using a similar method to the one you posted may work best

sdfgdfg

fgdfgdfg
 
Philippe Giry:

Ilan, est-ce que ce genre de codage peut vous aider?


Je vais probablement utiliser ceci:

for(int i=OrdersHistoryTotal-1; i>=0; i--)
{
   if(!OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)
      continue;
   if(!IsOurTicket())
      continue;
   
   MakeTradeHistory(OrderTicket());
}



bool IsOurTicket()
{
   for(int k=0;k<ArraySize(MagicNumbers);k++)
      if(OrderMagicNumber()==MagicNumbers[k])
         return(true);
   return(false);
}
 
Ian Tavener :

Je vais probablement utiliser ceci:

Ok, il sera efficace aussi sûrement.
 
Ian Tavener:

 I agree with you, that trying to trick the broker by changing magic numbers won't work.  However, I know some people might disagree with us.  I was trying to include an option for someone where I can say "ok, you think brokers may track by magic number, and you don't like that.  so here is an option to prevent that."

...

You can even remove completely magic number usage if you want. If you want to do something like that, push the logic to the end. Either a broker can or it can't track magic numbers, if he can/do it what you coded is not a complete solution, if he can't/don't do it it's useless.
 
Please post in English on this forum.