Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 514

 
r772ra:



Thanks.

Please advise, as long as you haven't put up any fences.

What could be made simpler?

input int    Slippage   = 10;   // установим значение проскальзывания 
extern string ___START_SETUP_ = "---ОСНОВА---";  
input double StartLot   = 0.02; 
extern double LotMultiplicator = 1.3;
extern int N_LotMult = 2;
extern string ___STEP_SETUP_BLOK_ = "--- БЛОК УСЛОВИЙ СЕТКИ ---";
extern int Mode_Step = 1;
extern int Step = 5;
extern int StepUv_Step = 5;
extern string ___CLOSE_SETUP_BLOK_ = "--- БЛОК УСТАНОВОК ЗАКРЫТИЯ ---";
extern int TakeProfit = 40;


double z,y, lot=StartLot, count, step=Step;

  
void OnTick()
  {  
   
     int i_buy=0; int i_sell=0;
     for(int i=0;i<OrdersTotal();i++){
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true && OrderSymbol()==Symbol()){
              switch(OrderType()){// Есть ли открыте ордера
                 case OP_BUY:
                    i_buy++;
                 break;
                 case OP_SELL:
                    i_sell++;
                 break;
               }
               
              y = int((OrderOpenPrice()-Ask)/Point); 
              z = OrderLots();
              
              count++;            
          }   
     }
    
     if(LotMultiplicator > 1 && count > N_LotMult) lot = z + z/LotMultiplicator;    
     if(Mode_Step==1) step = Step + count*StepUv_Step;

     if((i_buy==0 && i_sell==0) || y >= step) //--- нет открытых ордеров, открываем
         OrderSend(Symbol(), OP_BUY,lot,Ask,Slippage,0,Ask+TakeProfit*Point(),WindowExpertName()+" "+(string)0,0,0,clrBlue);
     
       count=0;
   
 
Zolotai:


Thanks.

Please advise, as long as you haven't put up any fences.

What could be made simpler?


PLEASE learn how to insert the code correctly! CTRL+ALT+M or SRC.
 
evillive:
PLEASE learn how to insert the code correctly! CTRL+ALT+M or SRC.

Done.
 
Zolotai:


Spc.

Please advise, as long as you haven't put up any fences.

What could be made simpler?


And there are no compilation errors? And no execution errors either?

First describe what you want to end up with.Because there are questions about some places in the code:

 y = int((OrderOpenPrice()-Ask)/Point); //подставьте в уравнение реальные цены
if((i_buy==0 && i_sell==0) || y >= step) //--- нет открытых ордеров, открываем открывает позицию всегда когда y >= step, а это будет практически всегда по формуле выше, за исключением коридора шириной в "step"
 
evillive:

And there are no compilation errors? And no execution errors either?

First, describe what you want to end up with, because there are questions about some places in the code:




Is there anything that could be simplified. Maybe some extra variables... All I have now is opening in steps, increasing the lot and that's it. I don't need TP yet. Is it possible to make it a bit simpler, less code...
 
Is there a lot of him? There's nothing to simplify there, on the contrary, it should be aggravated )))
 
evillive:
Is there a lot of him? There's nothing to simplify there, on the contrary, it should be aggravated )))

Thanks. Could you suggest a function. If i want to place stop and takeaway order with last order, then the first order will be averaged. The second to last order with the first one and so on. As if we go to the middle...
 
I'm sure there are plenty of netizens in the kodobase - mediums, martins, anti-martins, for all tastes.
 
evillive:
I'm sure there are plenty of netizens in the kodobase - mediums, martins, anti-martins, for all tastes.

Yeah, but, you know. You have to poke around in other people's codes. Which I don't understand, and it takes a lot of time To figure it out.
 
artmedia70:
With such questions you should go to the 610th build thread- the developers are there


Thank you, gone.
Reason: