Download MetaTrader 5
To add comments, please log in or register
Let your idle PCs do something useful. Join MQL5 Cloud Network!
PieroNetto
189
PieroNetto 2014.10.20 15:43 

How do i get the Point amount caculation  between OrderOpenPrice and StoppLoss in an open order?

thanks 

honest_knave
954
honest_knave 2014.10.20 16:11  

One way would be to OrderSelect the order, then subtract the OrderOpenPrice from the OrderStopLoss

MathAbs might be useful to.

PieroNetto
189
PieroNetto 2014.10.21 10:39  
void start()//void MinimumProfit()
{
      double resOS;
      if (OrdersTotal()>0)
      resOS=OrderSelect(0,SELECT_BY_POS,MODE_BASE);
      int A=OrderOpenPrice();
      int B=OrderStopLoss();
      int C=MP(A,B);
}
int MP(int val1,int val2);
{
      MSL=(val1-val2);
return(MSL);
}

thats what i have now but i have errors. i would like to see samples to learn. reference only shows a little to understand. please point me in the right way to see some 

MathAbs code. I guess im wrong with this function

Thanks 

Carl Schreiber
5938
Carl Schreiber 2014.10.21 10:54  
pieronetto:

thats what i have now but i have errors. i would like to see samples to learn. reference only shows a little to understand. please point me in the right way to see some 

MathAbs code. I guess im wrong with this function

Thanks 

1) I would strongly suggest to use brackets {..}!!

2) What do you expect to happen if OrdersTotal()==0 and/or resOS == false?

3) Have a little look in your Mt4-reference search for MathAbs..

PieroNetto
189
PieroNetto 2014.10.21 15:00  
void start()//void MinimumProfit()
{
      bool resOS;
      double A,B,C,D,F,MP,SL;
      resOS=OrderSelect(0,SELECT_BY_POS,MODE_BASE);
      A=OrderOpenPrice();
      B=OrderStopLoss();
      C=OrderClosePrice();
      D=B-A;
      SL=MathAbs(D*100000);
      F=C-A;
      MP=MathAbs(F*100000);
      if(MP>SL)
      {
      Alert("Close Position");
      }
return;
}

That what i have now it works. Please need to know about that *100000 if this is right?

I think i should put it this way other wise he shows somthing like 0.0004 and not 43 Point

honest_knave
954
honest_knave 2014.10.21 15:05  
Try dividing by Point rather than multiplying by 100000
PieroNetto
189
PieroNetto 2014.10.21 15:40  
honest_knave:
Try dividing by Point rather than multiplying by 100000
void start()//void MinimumProfit()
{
      bool resOS;
      double A,B,C,D,F,MP,SL;
      resOS=OrderSelect(0,SELECT_BY_POS,MODE_BASE);
      A=OrderOpenPrice();
      B=OrderStopLoss();
      C=OrderClosePrice();
      D=B-A;
      SL=MathAbs(D*Point);
      {
      Print("StopLoss",SL);
      }
      F=C-A;
      MP=MathAbs(F*Point);
      {
      Print("MinimumProfit",MP);
      }
      if(MP>SL)
      {
      Alert("Close Position");
      }
return;
Than he shows 0 in the print?????????????
PieroNetto
189
PieroNetto 2014.10.21 15:42  
void start()//void MinimumProfit()
{
      bool resOS;
      double A,B,C,D,F,MP,SL;
      resOS=OrderSelect(0,SELECT_BY_POS,MODE_BASE);
      A=OrderOpenPrice();
      B=OrderStopLoss();
      C=OrderClosePrice();
      D=B-A;
      SL=MathAbs(D/Point);
      {
      Print("StopLoss",SL);
      }
      F=C-A;
      MP=MathAbs(F/Point);
      {
      Print("MinimumProfit",MP);
      }
      if(MP>SL)
      {
      Alert("Close Position");
      }
return;
Got it , forgot dividing sorry and thanks a lot for u help
/
To add comments, please log in or register