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

 

paladin80, the problem is not opening an order... it works fine... I skimmed this part to make it clear which variables from the post of 01.05.12 19:15 where used further...

the problem is this (see below), it's a one-off execution and for some reason Vol increases to infinity, hence the Lts increases to infinity... it's not clear... please see the post in question and tell me what's wrong...

if ((Opn_S==true)||(Opn_B==true))               // Если есть сигнал на открытие ордера
      {                                         // Вычисляем объем умножая на VP
      if (AccountBalance()<50000) Vol=Opn_Lots*VP;
      if (AccountBalance()>50000) Vol=2*Opn_Lots*VP;
      }
 
w_ersoc:

Does anyone know how to convert the number of pips into currency?

i.e. if the profit is in units of currency, then 50 pips should be converted into units of currency... i.e. leverage should be taken into account...? 0_о


profit=lot*points*TICK_VALUE
 

oDin48, have you ever thought that all of a sudden an order opens and an error slips somewhere? Then the order will open and Vol will increase?

I am saying off the top of my head, because similar situations have occurred to me before, when programming in other languages

Try to show the error number in the message window and see what it is

 

gogent, everything was working fine until I wrote the trading criteria, or rather everything was fine with the others, but there's something wrong with these... so i don't think it's the "order opening" code... The order openings do not cycle, they open one at a time when the signal goes off... ... so it is either a condition related to Vol or a condition related to VP... I am trying to rewrite the same in different words, let's see what happens...

Added:

It's about the VP. Something in the code below is wrong... it is executed, as I understand it, every time one MA is higher than the other... i.e. always... Is the additional condition not working? Why? Like Opn_B, Cls_B, Opn_S, Cls_S, works fine, not created on every tick, but VP goes to infinity somewhere...

if ((Opb==0) && (MA_1_t > MA_2_t + Rastvor*Point))           // Если разница между
     {                                          // ..МА 1 и 2 большая
      Opn_B=true;                               // Критерий откр. Buy
      Cls_S=true;                               // Критерий закр. Sell
      Opb++;                                    // Открытие только одного ордера
      Ops=0;
         if (VKO1>=Ask) {VP=VP*Koff;}           // При прибыли предыдущего умножать на коэф.
         if (VKO1<Ask) {VP=VP*Koff1;}           // При убытке предыдущего умножать на коэф1.
      }
 if ((Ops==0) && (MA_1_t < MA_2_t - Rastvor*Point))           // Если разница между
     {                                          // ..МА 1 и 2 большая
      Opn_S=true;                               // Критерий откр. Sell
      Cls_B=true;                               // Критерий закр. Buy
      Ops++;                                    // Открытие только одного ордера
      Opb=0;
         if (VKO0<=Bid) {VP=VP*Koff;}           // При прибыли предыдущего умножать на коэф
         if (VKO0>Bid) {VP=VP*Koff1;}           // При убытке предыдущего умножать на коэф1
      }
 
sergeev:

profit=lot*points*TICK_VALUE

thank you! =)

 

I'm sorry, one more question has arisen. is there a simple way to lock an order at take profit?

i.e. let's say there are 3 orders, and one of them closed. how can i signal it closed and get its profit (or loss)?

 
If I set my EA to work on H4 only, and during testing/optimisation I leave a different period (say H1), it won't affect it, will it?
 
w ersoc, every tick(i.e. in start()) check if the order has closed at TP. And by the way, all actions of the EA are registered in the log (or only during testing?).
 
paladin80, if the EA's trading criteria are based on bars / candlesticks / averages and so on, then as far as I understand it, it will, but if it is not, then it won't...
 
gogent:
w ersoc, every tick (i.e. in start()) check if the order has closed at TP. And by the way, all actions of the EA are registered in the log (or only during testing...?)

now of course testing is more important...

the end result is that there will always be a previously closed profit... The logic of the problem is that only when take profit is triggered, we should somehow make a flag.

Reason: