Compare commits

...

1 Commits

Author SHA1 Message Date
9nix6 dd2f769c89 Update for version 2.11 2019-05-14 17:22:40 +02:00
6 changed files with 95 additions and 53 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ ulong currentTicket;
// the RangeBars indicator attached. // the RangeBars indicator attached.
// //
//#define SHOW_INDICATOR_INPUTS #define SHOW_INDICATOR_INPUTS
// //
// You need to include the RangeBars.mqh header file // You need to include the RangeBars.mqh header file
Binary file not shown.
+6 -6
View File
@@ -30,14 +30,14 @@ double VtcNormalizeLots(string symbol, double lotsToNormalize)
return lotsMin; return lotsMin;
int a = (int)(lotsToNormalize / lotsStep); int a = (int)(lotsToNormalize / lotsStep);
double Lots = a * lotsStep; double normalizedLots = a * lotsStep;
if(Lots < lotsMin) if(normalizedLots < lotsMin)
Lots = lotsMin; normalizedLots = lotsMin;
if(Lots > lotsMax) if(normalizedLots > lotsMax)
Lots = lotsMax; normalizedLots = lotsMax;
return Lots; return normalizedLots;
} }
double NormalizePrice(string symbol, double price, double tick = 0) double NormalizePrice(string symbol, double price, double tick = 0)
+1 -1
View File
@@ -7,7 +7,7 @@
#ifdef SHOW_INDICATOR_INPUTS #ifdef SHOW_INDICATOR_INPUTS
#ifdef MQL5_MARKET_DEMO #ifdef MQL5_MARKET_DEMO
int barSizeInTicks = 210; // Range bar size (in points) int barSizeInTicks = 180; // Range bar size (in points)
ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation ENUM_BOOL atrEnabled = false; // Enable ATR based bar size calculation
ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period ENUM_TIMEFRAMES atrTimeFrame = PERIOD_D1; // Use ATR period
int atrPeriod = 14; // ATR period int atrPeriod = 14; // ATR period
+1 -1
View File
@@ -6,7 +6,7 @@
#property copyright "Copyright 2017, AZ-iNVEST" #property copyright "Copyright 2017, AZ-iNVEST"
#property link "http://www.az-invest.eu" #property link "http://www.az-invest.eu"
//#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay204" //#define RANGEBAR_INDICATOR_NAME "RangeBars\\RangeBarsOverlay211"
#define RANGEBAR_INDICATOR_NAME "Market\\Range Bars Charting" #define RANGEBAR_INDICATOR_NAME "Market\\Range Bars Charting"
#define RANGEBAR_OPEN 00 #define RANGEBAR_OPEN 00
+86 -44
View File
@@ -19,6 +19,10 @@
#define Ask SymbolInfoDouble(_symbol,SYMBOL_ASK) #define Ask SymbolInfoDouble(_symbol,SYMBOL_ASK)
#define Bid SymbolInfoDouble(_symbol,SYMBOL_BID) #define Bid SymbolInfoDouble(_symbol,SYMBOL_BID)
bool suppressLogOutput = false;
void SuppressGlobalLogOutput() { suppressLogOutput = true; };
#endif #endif
#define _point SymbolInfoDouble(_symbol,SYMBOL_POINT) #define _point SymbolInfoDouble(_symbol,SYMBOL_POINT)
@@ -49,6 +53,7 @@ class CTradingChecks
private: private:
ENUM_TC_ERROR _err; ENUM_TC_ERROR _err;
bool _suppressLogOutput;
public: public:
@@ -56,6 +61,7 @@ class CTradingChecks
~CTradingChecks(); ~CTradingChecks();
string GetCheckErrorToString(); string GetCheckErrorToString();
void SuppressLogOutput() { _suppressLogOutput = true; };
bool OkToOpenOrder(string _symbol,ENUM_ORDER_TYPE type, double lots, double entryPrice, double sl, double tp); bool OkToOpenOrder(string _symbol,ENUM_ORDER_TYPE type, double lots, double entryPrice, double sl, double tp);
bool OkToModifyOrder(string _symbol,ulong ticket,double price, double sl, double tp); bool OkToModifyOrder(string _symbol,ulong ticket,double price, double sl, double tp);
@@ -67,6 +73,7 @@ class CTradingChecks
CTradingChecks::CTradingChecks(void) CTradingChecks::CTradingChecks(void)
{ {
suppressLogOutput = false;
} }
CTradingChecks::~CTradingChecks(void) CTradingChecks::~CTradingChecks(void)
@@ -226,15 +233,22 @@ bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
if(!OrderCalcMargin(type,symb,lots,price,margin)) if(!OrderCalcMargin(type,symb,lots,price,margin))
{ {
//--- something went wrong, report and return false //--- something went wrong, report and return false
Print("Error in ",__FUNCTION__," code=",GetLastError()); if(suppressLogOutput == false)
{
Print("Error in ",__FUNCTION__," code=",GetLastError());
}
return(false); return(false);
} }
//--- if there are insufficient funds to perform the operation //--- if there are insufficient funds to perform the operation
if(margin>free_margin) if(margin>free_margin)
{ {
//--- report the error and return false //--- report the error and return false
Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError()); if(suppressLogOutput == false)
Print("Required margin:"+DoubleToString(margin,2)+"; free margin:"+DoubleToString(free_margin,2)); {
Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
Print("Required margin:"+DoubleToString(margin,2)+"; free margin:"+DoubleToString(free_margin,2));
}
return(false); return(false);
} }
//--- checking successful //--- checking successful
@@ -248,7 +262,11 @@ bool CheckMoneyForTrade(string symb, double lots,int type)
if(free_margin<0) if(free_margin<0)
{ {
string oper=(type==OP_BUY)? "Buy":"Sell"; string oper=(type==OP_BUY)? "Buy":"Sell";
Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError()); if(suppressLogOutput == false)
{
Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError());
}
return(false); return(false);
} }
//--- checking successful //--- checking successful
@@ -290,8 +308,11 @@ double PositionVolume(string symbol)
else else
{ {
//--- report a failure to select position //--- report a failure to select position
Print(__FUNCTION__," Failed to perform PositionSelect() for symbol ", if(suppressLogOutput == false)
{
Print(__FUNCTION__," Failed to perform PositionSelect() for symbol ",
symbol," Error ",GetLastError()); symbol," Error ",GetLastError());
}
return(-1); return(-1);
} }
} }
@@ -359,8 +380,11 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
int stops_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_STOPS_LEVEL); int stops_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_STOPS_LEVEL);
if(stops_level!=0) if(stops_level!=0)
{ {
PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must"+ if(suppressLogOutput == false)
{
PrintFormat("SYMBOL_TRADE_STOPS_LEVEL=%d: StopLoss and TakeProfit must"+
" not be nearer than %d points from the closing price",stops_level,stops_level); " not be nearer than %d points from the closing price",stops_level,stops_level);
}
} }
//--- //---
bool SL_check=false,TP_check=false; bool SL_check=false,TP_check=false;
@@ -372,13 +396,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : (Bid-SL>stops_level*_point); SL_check= (SL==0) ? true : (Bid-SL>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+
" (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Bid=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,Bid-stops_level*_point,Bid,stops_level); EnumToString(type),SL,Bid-stops_level*_point,Bid,stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : (TP-Bid>stops_level*_point); TP_check= (TP==0) ? true : (TP-Bid>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+
" (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Bid=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,Bid+stops_level*_point,Bid,stops_level); EnumToString(type),TP,Bid+stops_level*_point,Bid,stops_level);
@@ -390,13 +414,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : (SL-Ask>stops_level*_point); SL_check= (SL==0) ? true : (SL-Ask>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+
" (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Ask=%.5f + SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,Ask+stops_level*_point,Ask,stops_level); EnumToString(type),SL,Ask+stops_level*_point,Ask,stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : (Ask-TP>stops_level*_point); TP_check= (TP==0) ? true : (Ask-TP>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+
" (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Ask=%.5f - SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,Ask-stops_level*_point,Ask,stops_level); EnumToString(type),TP,Ask-stops_level*_point,Ask,stops_level);
@@ -409,13 +433,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : ((price-SL)>stops_level*_point); SL_check= (SL==0) ? true : ((price-SL)>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+
" (Open-StopLoss=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Open-StopLoss=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,price-stops_level*_point,(int)((price-SL)/_point),stops_level); EnumToString(type),SL,price-stops_level*_point,(int)((price-SL)/_point),stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : ((TP-price)>stops_level*_point); TP_check= (TP==0) ? true : ((TP-price)>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+
" (TakeProfit-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (TakeProfit-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,price+stops_level*_point,(int)((TP-price)/_point),stops_level); EnumToString(type),TP,price+stops_level*_point,(int)((TP-price)/_point),stops_level);
@@ -427,13 +451,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : ((SL-price)>stops_level*_point); SL_check= (SL==0) ? true : ((SL-price)>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+
" (StopLoss-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (StopLoss-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,price+stops_level*_point,(int)((SL-price)/_point),stops_level); EnumToString(type),SL,price+stops_level*_point,(int)((SL-price)/_point),stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : ((price-TP)>stops_level*_point); TP_check= (TP==0) ? true : ((price-TP)>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+
" (Open-TakeProfit=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Open-TakeProfit=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,price-stops_level*_point,(int)((price-TP)/_point),stops_level); EnumToString(type),TP,price-stops_level*_point,(int)((price-TP)/_point),stops_level);
@@ -446,13 +470,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : ((price-SL)>stops_level*_point); SL_check= (SL==0) ? true : ((price-SL)>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be less than %.5f"+
" (Open-StopLoss=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Open-StopLoss=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,price-stops_level*_point,(int)((price-SL)/_point),stops_level); EnumToString(type),SL,price-stops_level*_point,(int)((price-SL)/_point),stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : ((TP-price)>stops_level*_point); TP_check= (TP==0) ? true : ((TP-price)>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be greater than %.5f"+
" (TakeProfit-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (TakeProfit-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,price-stops_level*_point,(int)((TP-price)/_point),stops_level); EnumToString(type),TP,price-stops_level*_point,(int)((TP-price)/_point),stops_level);
@@ -464,13 +488,13 @@ bool CheckStopLoss_Takeprofit(string _symbol, ENUM_ORDER_TYPE type,double price,
{ {
//--- check the StopLoss //--- check the StopLoss
SL_check= (SL==0) ? true : ((SL-price)>stops_level*_point); SL_check= (SL==0) ? true : ((SL-price)>stops_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+ PrintFormat("For order %s StopLoss=%.5f must be greater than %.5f"+
" (StopLoss-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (StopLoss-Open=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),SL,price+stops_level*_point,(int)((SL-price)/_point),stops_level); EnumToString(type),SL,price+stops_level*_point,(int)((SL-price)/_point),stops_level);
//--- check the TakeProfit //--- check the TakeProfit
TP_check= (TP==0) ? true : ((price-TP)>stops_level*_point); TP_check= (TP==0) ? true : ((price-TP)>stops_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+ PrintFormat("For order %s TakeProfit=%.5f must be less than %.5f"+
" (Open-TakeProfit=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)", " (Open-TakeProfit=%d points ==> SYMBOL_TRADE_STOPS_LEVEL=%d points)",
EnumToString(type),TP,price-stops_level*_point,(int)((price-TP)/_point),stops_level); EnumToString(type),TP,price-stops_level*_point,(int)((price-TP)/_point),stops_level);
@@ -508,9 +532,14 @@ bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)
return(true); // order can be modified return(true); // order can be modified
//--- there are no changes in the Open, StopLoss and Takeprofit levels //--- there are no changes in the Open, StopLoss and Takeprofit levels
else else
{
//--- notify about the error //--- notify about the error
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f", if(suppressLogOutput == false)
{
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f",
ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit()); ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit());
}
}
} }
//--- came to the end, no changes for the order //--- came to the end, no changes for the order
return(false); // no point in modifying return(false); // no point in modifying
@@ -535,9 +564,14 @@ bool PositionModifyCheck(ulong ticket,double sl,double tp)
return(true); // position can be modified return(true); // position can be modified
//--- there are no changes in the StopLoss and Takeprofit levels //--- there are no changes in the StopLoss and Takeprofit levels
else else
{
//--- notify about the error //--- notify about the error
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f", if(suppressLogOutput == false)
{
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f",
ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit()); ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit());
}
}
} }
//--- came to the end, no changes for the order //--- came to the end, no changes for the order
return(false); // no point in modifying return(false); // no point in modifying
@@ -570,9 +604,14 @@ bool OrderModifyCheck(int ticket,double price,double sl,double tp)
return(true); // order can be modified return(true); // order can be modified
//--- there are no changes in the Open, StopLoss and Takeprofit levels //--- there are no changes in the Open, StopLoss and Takeprofit levels
else else
{
//--- notify about the error //--- notify about the error
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f", if(suppressLogOutput == false)
{
PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f",
ticket,OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit()); ticket,OrderOpenPrice(),OrderStopLoss(),OrderTakeProfit());
}
}
} }
//--- came to the end, no changes for the order //--- came to the end, no changes for the order
return(false); // no point in modifying return(false); // no point in modifying
@@ -590,8 +629,11 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol, ulong ticket)
int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL); int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL);
if(freeze_level!=0) if(freeze_level!=0)
{ {
PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+ if(suppressLogOutput == false)
{
PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+
" nearer than %d points from the activation price",freeze_level,freeze_level); " nearer than %d points from the activation price",freeze_level,freeze_level);
}
} }
//--- select order for working //--- select order for working
if(!OrderSelect(ticket)) if(!OrderSelect(ticket))
@@ -614,7 +656,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol, ulong ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((Ask-price)>freeze_level*_point); check=((Ask-price)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order %s #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
EnumToString(type),ticket,(int)((Ask-price)/_point),freeze_level); EnumToString(type),ticket,(int)((Ask-price)/_point),freeze_level);
return(check); return(check);
@@ -624,7 +666,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol, ulong ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((price-Bid)>freeze_level*_point); check=((price-Bid)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified: Open-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order %s #%d cannot be modified: Open-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
EnumToString(type),ticket,(int)((price-Bid)/_point),freeze_level); EnumToString(type),ticket,(int)((price-Bid)/_point),freeze_level);
return(check); return(check);
@@ -635,7 +677,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol, ulong ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((price-Ask)>freeze_level*_point); check=((price-Ask)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order %s #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
EnumToString(type),ticket,(int)((price-Ask)/_point),freeze_level); EnumToString(type),ticket,(int)((price-Ask)/_point),freeze_level);
return(check); return(check);
@@ -645,7 +687,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol, ulong ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((Bid-price)>freeze_level*_point); check=((Bid-price)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified: Bid-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order %s #%d cannot be modified: Bid-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
EnumToString(type),ticket,(int)((Bid-price)/_point),freeze_level); EnumToString(type),ticket,(int)((Bid-price)/_point),freeze_level);
return(check); return(check);
@@ -663,7 +705,7 @@ bool CheckPositionForFREEZE_LEVEL(string _symbol, ulong ticket)
//--- get the SYMBOL_TRADE_FREEZE_LEVEL level //--- get the SYMBOL_TRADE_FREEZE_LEVEL level
int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL); int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL);
if(freeze_level!=0) if(freeze_level!=0 && suppressLogOutput == false)
{ {
PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+ PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+
" nearer than %d points from the activation price",freeze_level,freeze_level); " nearer than %d points from the activation price",freeze_level,freeze_level);
@@ -687,12 +729,12 @@ bool CheckPositionForFREEZE_LEVEL(string _symbol, ulong ticket)
case POSITION_TYPE_BUY: case POSITION_TYPE_BUY:
{ {
SL_check=(sl == 0) ? true: (Bid-sl>freeze_level*_point); SL_check=(sl == 0) ? true: (Bid-sl>freeze_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("Position %s #%d cannot be modified: Bid-StopLoss=%d points"+ PrintFormat("Position %s #%d cannot be modified: Bid-StopLoss=%d points"+
" < SYMBOL_TRADE_FREEZE_LEVEL=%d points)", " < SYMBOL_TRADE_FREEZE_LEVEL=%d points)",
EnumToString(pos_type),ticket,(int)((Bid-sl)/_point),freeze_level); EnumToString(pos_type),ticket,(int)((Bid-sl)/_point),freeze_level);
TP_check=(tp == 0) ? true: (tp-Bid>freeze_level*_point); TP_check=(tp == 0) ? true: (tp-Bid>freeze_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("Position %s #%d cannot be modified: TakeProfit-Bid=%d points"+ PrintFormat("Position %s #%d cannot be modified: TakeProfit-Bid=%d points"+
" < SYMBOL_TRADE_FREEZE_LEVEL=%d points)", " < SYMBOL_TRADE_FREEZE_LEVEL=%d points)",
EnumToString(pos_type),ticket,(int)((tp-Bid)/_point),freeze_level); EnumToString(pos_type),ticket,(int)((tp-Bid)/_point),freeze_level);
@@ -704,12 +746,12 @@ bool CheckPositionForFREEZE_LEVEL(string _symbol, ulong ticket)
case POSITION_TYPE_SELL: case POSITION_TYPE_SELL:
{ {
SL_check=(sl == 0) ? true: (sl-Ask>freeze_level*_point); SL_check=(sl == 0) ? true: (sl-Ask>freeze_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("Position %s cannot be modified: StopLoss-Ask=%d points"+ PrintFormat("Position %s cannot be modified: StopLoss-Ask=%d points"+
" < SYMBOL_TRADE_FREEZE_LEVEL=%d points)", " < SYMBOL_TRADE_FREEZE_LEVEL=%d points)",
EnumToString(pos_type),(int)((sl-Ask)/_point),freeze_level); EnumToString(pos_type),(int)((sl-Ask)/_point),freeze_level);
TP_check=(tp == 0) ? true: (Ask-tp>freeze_level*_point); TP_check=(tp == 0) ? true: (Ask-tp>freeze_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("Position %s cannot be modified: Ask-TakeProfit=%d points"+ PrintFormat("Position %s cannot be modified: Ask-TakeProfit=%d points"+
" < SYMBOL_TRADE_FREEZE_LEVEL=%d points)", " < SYMBOL_TRADE_FREEZE_LEVEL=%d points)",
EnumToString(pos_type),(int)((Ask-tp)/_point),freeze_level); EnumToString(pos_type),(int)((Ask-tp)/_point),freeze_level);
@@ -726,7 +768,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- get the SYMBOL_TRADE_FREEZE_LEVEL level //--- get the SYMBOL_TRADE_FREEZE_LEVEL level
int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL); int freeze_level=(int)SymbolInfoInteger(_symbol,SYMBOL_TRADE_FREEZE_LEVEL);
if(freeze_level!=0) if(freeze_level!=0 && suppressLogOutput == false)
{ {
PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+ PrintFormat("SYMBOL_TRADE_FREEZE_LEVEL=%d: Cannot modify order"+
" nearer than %d points from the activation price",freeze_level,freeze_level); " nearer than %d points from the activation price",freeze_level,freeze_level);
@@ -752,7 +794,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((Ask-price)>freeze_level*_point); check=((Ask-price)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order OP_BUYLIMIT #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_BUYLIMIT #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((Ask-price)/_point),freeze_level); ticket,(int)((Ask-price)/_point),freeze_level);
return(check); return(check);
@@ -762,7 +804,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((price-Bid)>freeze_level*_point); check=((price-Bid)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order OP_SELLLIMIT #%d cannot be modified: Open-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_SELLLIMIT #%d cannot be modified: Open-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((price-Bid)/_point),freeze_level); ticket,(int)((price-Bid)/_point),freeze_level);
return(check); return(check);
@@ -773,7 +815,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((price-Ask)>freeze_level*_point); check=((price-Ask)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order OP_BUYSTOP #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_BUYSTOP #%d cannot be modified: Ask-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((price-Ask)/_point),freeze_level); ticket,(int)((price-Ask)/_point),freeze_level);
return(check); return(check);
@@ -783,7 +825,7 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=((Bid-price)>freeze_level*_point); check=((Bid-price)>freeze_level*_point);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order OP_SELLSTOP #%d cannot be modified: Bid-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_SELLSTOP #%d cannot be modified: Bid-Open=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((Bid-price)/_point),freeze_level); ticket,(int)((Bid-price)/_point),freeze_level);
return(check); return(check);
@@ -794,12 +836,12 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check TakeProfit distance to the activation price //--- check TakeProfit distance to the activation price
bool TP_check=(tp == 0) ? true: (tp-Bid>freeze_level*_point); bool TP_check=(tp == 0) ? true: (tp-Bid>freeze_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((tp-Bid)/_point),freeze_level); ticket,(int)((tp-Bid)/_point),freeze_level);
//--- check TakeProfit distance to the activation price //--- check TakeProfit distance to the activation price
bool SL_check=(sl == 0) ? true: (Bid-sl>freeze_level*_point); bool SL_check=(sl == 0) ? true: (Bid-sl>freeze_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((Bid-sl)/_point),freeze_level); ticket,(int)((Bid-sl)/_point),freeze_level);
return(SL_check&&TP_check); return(SL_check&&TP_check);
@@ -810,12 +852,12 @@ bool CheckOrderForFREEZE_LEVEL(string _symbol,int ticket)
{ {
//--- check TakeProfit distance to the activation price //--- check TakeProfit distance to the activation price
bool TP_check=(tp == 0) ? true: (Ask-tp>freeze_level*_point); bool TP_check=(tp == 0) ? true: (Ask-tp>freeze_level*_point);
if(!TP_check) if(!TP_check && suppressLogOutput == false)
PrintFormat("Order OP_SELL %d cannot be modified: Ask-TakeProfit=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_SELL %d cannot be modified: Ask-TakeProfit=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((Ask-tp)/_point),freeze_level); ticket,(int)((Ask-tp)/_point),freeze_level);
//--- check TakeProfit distance to the activation price //--- check TakeProfit distance to the activation price
bool SL_check=(sl == 0) ? true: (sl-Ask>freeze_level*_point); bool SL_check=(sl == 0) ? true: (sl-Ask>freeze_level*_point);
if(!SL_check) if(!SL_check && suppressLogOutput == false)
PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points", PrintFormat("Order OP_BUY %d cannot be modified: TakeProfit-Bid=%d points < SYMBOL_TRADE_FREEZE_LEVEL=%d points",
ticket,(int)((sl-Ask)/_point),freeze_level); ticket,(int)((sl-Ask)/_point),freeze_level);
return(SL_check&&TP_check); return(SL_check&&TP_check);
@@ -847,7 +889,7 @@ bool CheckPendingOrderEntryChange(string _symbol, ulong ticket, double newEntryP
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check= (newEntryPrice < Ask); check= (newEntryPrice < Ask);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified", PrintFormat("Order %s #%d cannot be modified",
EnumToString(type),ticket); EnumToString(type),ticket);
return(check); return(check);
@@ -857,7 +899,7 @@ bool CheckPendingOrderEntryChange(string _symbol, ulong ticket, double newEntryP
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=(newEntryPrice > Bid); check=(newEntryPrice > Bid);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified", PrintFormat("Order %s #%d cannot be modified",
EnumToString(type),ticket); EnumToString(type),ticket);
return(check); return(check);
@@ -868,7 +910,7 @@ bool CheckPendingOrderEntryChange(string _symbol, ulong ticket, double newEntryP
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=(newEntryPrice > Ask); check=(newEntryPrice > Ask);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified", PrintFormat("Order %s #%d cannot be modified",
EnumToString(type),ticket); EnumToString(type),ticket);
return(check); return(check);
@@ -878,7 +920,7 @@ bool CheckPendingOrderEntryChange(string _symbol, ulong ticket, double newEntryP
{ {
//--- check the distance from the opening price to the activation price //--- check the distance from the opening price to the activation price
check=(newEntryPrice < Bid); check=(newEntryPrice < Bid);
if(!check) if(!check && suppressLogOutput == false)
PrintFormat("Order %s #%d cannot be modified", PrintFormat("Order %s #%d cannot be modified",
EnumToString(type),ticket); EnumToString(type),ticket);
return(check); return(check);