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

 

I must be missing something:

extern double LotsStep = 0.1;
       double Lots;
...

int start()
{
   ...
   
   if (NewOrder)
   { 
      if (OrdersTotal() == 0)
         Lots = LotsStep;
      else
         Lots += LotsStep;
      
      Lots = TrueLots(Lots);
      if (Lots < 0)
      {
         Alert("Не хватает денег на ", DoubleToStr(-Lots, 2), " лотов!");
         Lots = 0;
         Buy  = False;
         Sell = False;
      }
      
      NewOrder = False;
   }
      
   //Блок открытия на бай
   
   ...
}

double TrueLots(double Lots)
{
   double Free    = AccountFreeMargin();
   double One_Lot = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   
   if (Lots > Max_Lot)
   {
      Alert("...");
      Lots = Max_Lot;
   }

   if (Lots*One_Lot > Free)
      return(-Lots);
   
   return(Lots);
}

 

One more problem, I had an error '(' function definition unexpected, I put this function " double LotSize()
".
I want toincrease each subsequent lot to be opened, but I want it to be opened only with series of signals for buy, and when opposite signals come, counter zeroed and new pyramid started to be built, if it is possible, that is why I took this code fragment, because I thought it was responsible for this step, but it didn't turn out so...

 
MaxZ:

I must be missing something:


Thank you. I'll try it now.
 
SeALALex:
There you go.


Look at the trailer - correct it for yourself.

Files:
b-lots.mqh  3 kb
 
SeALALex:

Thanks, I will try it now.

I've also added a check to make sure that a given number of Lots can be opened. Improvise and you'll be lucky! :))


The logic is as follows:

If there are no orders in the market (here, I exclude pending orders), then we assign the initial value to the Lots variable (in this case, the very step).

If there are already orders in the market, then, at every opening, the Lots parameter will be increased by the value of LotsStep.

I don't know what your specific task is, that's why I wrote "improvise".


Roman.:


Look at the trailer - correct it for yourself.

You'd better master everything with your own hands and at the same time you'll learn how to code! :D

 
MaxZ:

I must be missing something:


Maxim, if you have time, have a look at this topic... :-)))

I can't come up with a "common denominator" for all EAs at once (a universal option)... :-(((

In my codes of EAs - it says about "dabble" overflow...

I will ask a detailed question with screenshots in that thread ...

P.S. For some versions of owls - it works fine, for others it doesn't... Now it's just all done by the book, including multiplication... His product also needs to be broken down for universal approach into multipliers. I made an array, as you recommended for TWR variable, but so far it's not working for all EAs, for some EAs the data type "double" still overflows with trades up to 1000 pieces on history...when calculating the final optimal f.

 
MaxZ:

I must be missing something:


I'm sorry, I don't always catch it.


NewOrder error -'NewOrder' - variable not defined, where do I name it first?

 
Roman.:


Maxim, if you have time, have a look at this topic... :-)))

What am I supposed to see in the ProCapital forum thread? :))


Roman.:


I cannot come to a "common denominator" for all EAs at once (a universal option)... :-(((

In my codes of Expert Advisors - it says about "dabble" overflow...

I will ask a detailed question with screenshots in that thread ...

P.S. For some versions of owls - it works fine, for others it doesn't... Now it's just done by book, including multiplication... Its product also needs to be broken down for universal approach into multipliers. I made an array, as you recommended for TWR variable, but so far it's not working for all EAs, for some EAs the data type "double" still overflows with trades up to 1000 pieces on history...when calculating the final optimal f.

In the ProCapital branch? Why there? Post it, I'll look at the screenshots, I'll think about it.
 
MaxZ:

What am I supposed to see in the ProCapital forum thread? :))


In the branch of ProCapital? Why there? Post it, I'll look at the screenshots, I'll think about it.


Sorry, there was a wrong link in the buffer - an old one... :-)))

Here.

Now myself at work - detailed question with screenshots - will post in the same thread tonight or tomorrow. :-)))

 
SeALALex:

I'm sorry, I don't always catch it on the fly.


NewOrder error -'NewOrder' - variable not defined, where do I call it first?

With experience comes experience! ;)


NewOrder is a bool-type variable. It must be declared at the beginning of the Start() function, for example. Everything depends on your code's structure.

We set variable NewOrder to True, when we want to open an order.

For example, our EA will work with open prices and the Moving Average indicator:

if ((Close[2] <= MA2 && Close[1] > MA1) || (Close[2] < MA2 && Close[1] >= MA1))
{
   NewOrder = True;
   Buy = True;
}
Reason: