[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 287

 
Sorento:
2011.03.30 08:40:21 USDCAD,M1: 3 4 4.00000000 ask=0.9729 bid=0.9725


int Ret[3];

Ret[0]=NormalizeDouble((Ask-Bid)/Point,0); 
Print (Ret[0]," ",(Ask-Bid)/Point," ask=",Ask," bid=",Bid); 
it works like this
 
abolk:

it works like this!
Thank you!
 
Sorento:
Thank you!


In general, it is time for MT developers to create a section in the documentation and explain in detail the problem and the need to use normalisation.

There is only a modest example without emphasis in the documentation for this situation:

int    i = 1 / 2.0;   // выражение приводится к типу double, затем приводится к целевому типу int, результат: 0

Section "Type Approach" https://docs.mql4.com/ru/basis/types/casting

 
Roger:

To FoxUA.

When Order 3 (Sell) is closed, that Order 1 (Buy) still semaphores that it was closed on Stop Loss and so 2 orders in a row are placed, because Total=1.


i.e. i look for a solution to this issue, i.e. what to replace total 1 to get rid of such an effect
 
Can you tell me if the script can open orders not only in the window of the chart to which it is attached, but also on other currency pairs, if it is properly prescribed on which other currency pairs you need to open?
 
CreAndr:
Can you tell me if the script can open orders not only in the window of the chart to which it is attached, but also on other currency pairs, if it is properly prescribed on which other currency pairs you need to open?

maybe
 
abolk:

maybe
#property show_inputs
//--------------------------------------------------------------------
extern double TakeProfit = 1000;
extern double Lots = 0.01;
extern double StopLoss = 500.0;
extern int MagNum = 1974;
int slip = 100;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()

{
//::::Открытие и выставление ордеров


OrderSend("EURUSD",OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,NormalizeDouble(Bid - StopLoss*Point,Digits),NormalizeDouble(Ask + TakeProfit * Point,Digits),"CleverEA",MagNum,0,Green);
OrderSend("GBPUSD",OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,NormalizeDouble(Bid - StopLoss*Point,Digits),NormalizeDouble(Ask + TakeProfit * Point,Digits),"CleverEA",MagNum,0,Green);
OrderSend("USDJPY",OP_SELL,Lots,NormalizeDouble(Bid,Digits),slip,NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit * Point,Digits),"CleverEA",MagNum,0,Red);
OrderSend("USDCHF",OP_SELL,Lots,NormalizeDouble(Bid,Digits),slip,NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit * Point,Digits),"CleverEA",MagNum,0,Red);

return (0);

}


but this option, will it work or not?
Files:
 
CreAndr:

OrderSend("EURUSD",OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,NormalizeDouble(Bid - StopLoss*Point,Digits),NormalizeDouble(Ask + TakeProfit * Point,Digits)," CleverEA",MagNum,0,Green);


but this option, will it work or not?


No, what you highlighted will be returned from the current tool. Bids, asks, digits and so on should be requested with MarketInfo explicitly specifying the tool
 
CreAndr:
#property show_inputs
//--------------------------------------------------------------------
extern double TakeProfit = 1000;
extern double Lots = 0.01;
extern double StopLoss = 500.0;
extern int MagNum = 1974;
int slip = 100;


//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()

{
//::::Открытие и выставление ордеров


OrderSend("EURUSD",OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,NormalizeDouble(Bid - StopLoss*Point,Digits),NormalizeDouble(Ask + TakeProfit * Point,Digits),"CleverEA",MagNum,0,Green);
OrderSend("GBPUSD",OP_BUY,Lots,NormalizeDouble(Ask,Digits),slip,NormalizeDouble(Bid - StopLoss*Point,Digits),NormalizeDouble(Ask + TakeProfit * Point,Digits),"CleverEA",MagNum,0,Green);
OrderSend("USDJPY",OP_SELL,Lots,NormalizeDouble(Bid,Digits),slip,NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit * Point,Digits),"CleverEA",MagNum,0,Red);
OrderSend("USDCHF",OP_SELL,Lots,NormalizeDouble(Bid,Digits),slip,NormalizeDouble(Ask + StopLoss*Point,Digits),NormalizeDouble(Bid - TakeProfit * Point,Digits),"CleverEA",MagNum,0,Red);

return (0);

}

But will this option work or not?


It won't. You have to use the MarketInfo function https://docs.mql4.com/ru/common/MarketInfo.

there are examples of your problem on the page

 
Thank you for your help.
Reason: