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

 
Link_x:
I can't grasp it.
OK, I've already found an alternative. :)

Let MTS make trades without SL and TP, but close all if the potential profit is greater than X.
Is it possible to close orders in this way?
Do we have to keep track of the orders in this way?
The first parameter of the OrderClose(.......) function has to be the ticket of the position (it has to be found beforehand using OrderSelect() )
 
Figure out the sl variable, you have an integer, then you have a fraction.
 
vadynik:

Is the function fractional or shouldn't it be?

Happy New Year! Have a drink and don't sweat it!!!!!!!!!!!!!!!!!! :-)
 
Link_x:

Even so does not close orders, I do not like it.
It seems to be my faults, which I am not able to find as a result of inexperience.


guru, where are you going... ?... :-))) are you out of your mind ...

there are crowds praying, they don't know where to go, and he can't get his feet right... :-)))

 
vadynik:

Is the function fractional or shouldn't it be?
void VirtualTral(int Dist_Tral,int Start_Tral,int Magic,int SL)

\\здесь у тебя SL - целая, не знаю, какое значение ты сюда посылаешь
{

double dist=Dist_Tral;
double start=Start_Tral;
double sl=SL;

//здесь уже дробная, но так как до этого была целая, значит....
 
if(OrdersTotal()<=0)
ObjectDelete("Stop"); 

int i, k=OrdersTotal();

  for (i=k-1; i>=0; i--) 
   {
          if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
     {  

             if (Bid-NormalizeDouble(OrderOpenPrice(),Digits)>NormalizeDouble(start*Point,Digits))
      
          {                                                                                                                        
                    if((NormalizeDouble(Bid-sl*Point,Digits))>(NormalizeDouble(dist*Point,Digits)))//здесь sl подразумевается как отступ от цены, тогда dist должна быть ценой
                {         
                                                 
                          sl=NormalizeDouble(Bid-dist*Point,Digits); //а здесь sl - это уже цена, вполне определенная
                          //Print(+dist); 
                          //Print(+sl); 
                          ObjectCreate("Stop",OBJ_HLINE,0,D'2013.02.20 12:30',sl); // и здесь, это определенное значение цены
                                                                        
                          ObjectSet("Stop",OBJPROP_STYLE,1);                         
                          ObjectMove("Stop",0,D'2013.02.20 12:30',sl);            
   
 
vadynik:

Why should dist be the price? Because I count the difference between bid and offer and compare this delta with distance and if it is more it is necessary to pull up the stop, I do not understand where exactly the fault?



Let's do it in numbers

if((NormalizeDouble(Bid-sl*Point,Digits))>(NormalizeDouble(dist*Point,Digits))

Suppose the Bid is 1.3333, sl is 100, dist is 20, then

1.3333-100 * 0.0001=1.3233 that is more than 20 * 0.0001 = 0.02 always

 
gyfto:

I have a lamer question about usability. The chart can be scrolled left and right, as well as squeezed and stretch. But how do I scroll up and down?

I've figured it out, with the chart can be dragged up and down with the mouse.

 
Integer:
r772ra

Thank you for your help, dear traders - programmers. :)
 

Please advise how to calculate percentages in MQL4

for example x=10+3% how to write it programmatically?

I can't find it in the reference book.

 
clubsmi:

Please advise how to calculate percentages in MQL4

for example x=10+3% how to write it programmatically?

I can't find it in the reference book.



x=10*1.03