[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 203

 
smartemiy:

Guys!

how do i make every 40th order a bigger lot? :: market and pending

How about this?

Not exactly, you should count the number of orders in the history a = (OrdersHistoryTotal()+ 1) % 40

Well, this does not take into account how many orders may be open at the same time; otherwise, we would have to add the OrdersTotal (probably, minus the pending orders).

 
splxgf:

Not exactly, we need to count the number of orders in the history a = (OrdersHistoryTotal()+ 1) % 40

Well, this does not take into account how many orders may be open at the same time; otherwise, we would have to add the OrdersTotal (probably, minus the pending orders).


And what if there were open positions in other symbols or other Expert Advisors? Think about what you are writing
 
Figar0:

For starters, your lot calculation function is declared inside the start function. Take it out. Then there will be some errors with undeclared variable, but I think you can handle them on your own.
One more question, in which function to declare lot calculation? init, deinit?
 
skyjet:
Another question, in which function should I declare lot calculation? init, deinit?

Better to make a separate function and use it when needed (before opening a new position)
 
Can the computer slow down because of the abundance of code (not optimised) in the EA? I.e. will the opening of trades and the process of making decisions by the EA itself be slowed down if it has a large code ?
 
Vinin:

Better to make a separate function and use it when needed (before opening a new position)
Victor, following your advice I added the function. Now it doesn't compile.
void CheckForOpen()
double Lots()
  {
   double lot;
   lot=(AccountFreeMargin()*AccountLeverage()*Risk)/(MarketInfo(Symbol(), MODE_LOTSIZE));
   lot=NormalizeDouble(lot,1);
   return(lot);
  }
 

Keeping Teak History



avatar
1
Gangrr 22.09.2011 17:32

Hi all!

Question is - there is a script for saving tick history

...

FileSeek(ExtHandle,0,SEEK_END);

FileWrite(ExtHandle, TimeToStr(TimeCurrent(), TIME_DATE | TIME_SECONDS), Bid, Ask, iVolume(Symbol(), NULL, 0));

...

it writes like this:

...

2011.08.15 08:38:49;76.936;76.946;1389

2011.08.15 08:38:51;76.934;76.953;1390
2011.08.15 08:38:56;76.929;76.958;1391
2011.08.15 08:38:56;76.935;76.945;1392

...

That is, it turns out that the minimum unit of time is a second. So my question is, is there any way to write ticks in milliseconds ?

Thank you in advance.

 
1
Gangrr 22.09.2011 17:32

So it turns out that the minimum unit of time is a second. So question - is there any way to write ticks in milliseconds ?


Look at GetTickCount... or else refer to the Windows function
 
skyjet:
Victor, following your advice I added the function. Now it doesn't compile.

void CheckForOpen()
  {



  }

double Lots()
  {
   double lot;
   lot=(AccountFreeMargin()*AccountLeverage()*Risk)/(MarketInfo(Symbol(), MODE_LOTSIZE));
   lot=NormalizeDouble(lot,1);
   return(lot);
  }
Nested functions are not allowed
 
Vinin:

Nested functions are not allowed
This is not a nested function, but part of the basic MACD Sample EA. I'm trying to add a calculated lot. The main and only start() function
Reason: