Author: Copyright 2018, Baskakov Vladimir
Price Data Components
Series array that contains the highest prices of each barSeries array that contains the lowest prices of each barSeries array that contains close prices for each barSeries array that contains open prices of each bar
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategyIt Closes Orders by itself
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
Explosion
ÿþ//+------------------------------------------------------------------+

//|                                                    Explosion.mq4 |

//|                                Copyright 2018, Baskakov Vladimir |

//|                        https://www.mql5.com/ru/users/kalipso1979 |

//+------------------------------------------------------------------+

#property copyright "Copyright 2018, Baskakov Vladimir"

#property link      "https://www.mql5.com/ru/users/kalipso1979"

#property version   "1.00"

#property strict



input double _Lots = 0.01;// Lot

input int _SL = 20;//SL

input int _TP = 10;//TP

input int _MagicNumber = 4425;//Magic

input int _TrailingStop = 25;//Trailing Stop

input int _TrailingStep = 5;//Trailing Step

input string _Comment = "FX BOT";//Comments

input int _Slippage = 3;//Slippage

input bool _OnlyOneOpenedPos = true;//Only one pos per bar

input bool _AutoDigits = true;// Autodigits

//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>



double OP_LOTS = 0.0;

// autodetect class for decimal places of current tool 

class CKDig

{

   public:

      CKDig(const bool useAutoDigits)

      {

         Set(useAutoDigits);

      }

      

      ~CKDig(void)

      {

      }

      

      uint Get(void)

      {

         return m_value;

      }

      

   private:      

      uint m_value;      

      

      void Set(const bool useAutoDigits)

      {

         m_value = 1;

         if (!useAutoDigits)

         {

            return;

         }

         

         if (Digits() == 3 || Digits() == 5)

         {

            m_value = 10;

         }

      }

};



CKDig *KDig;

#define K_DIG (KDig.Get())



datetime LAST_BUY_BARTIME = 0;

datetime LAST_SELL_BARTIME = 0;

// ---



// ---

void OnInit()

{

	// ---

	get_lots_by_input();

	// ---

	KDig  = new CKDig(_AutoDigits);

	// ---

}



// ---

void OnDeinit(const int reason)

{

	// ---

	// ---

	if(CheckPointer(KDig))

	{

	   delete KDig;

	}

	// ---

}



// ---

void OnTick()

{

	//  closing a deal

	if(find_orders(_MagicNumber))

	{

		if(cl_buy_sig())

		{

			cbm(_MagicNumber, _Slippage, OP_BUY);

		}

		if(cl_sell_sig())

		{

			cbm(_MagicNumber, _Slippage, OP_SELL);

		}

	}

	

	// opening a deal

	if(!find_orders(_MagicNumber, (_OnlyOneOpenedPos ? -1 : OP_BUY)))

	{

		if(op_buy_sig() && LAST_BUY_BARTIME != iTime(Symbol(), Period(), 0))

		{

			LAST_BUY_BARTIME = iTime(Symbol(), Period(), 0);

			open_positions(OP_BUY, OP_LOTS);	

		}

	}

	// ---

	if(!find_orders(_MagicNumber, (_OnlyOneOpenedPos ? -1 : OP_SELL)))

	{

		if(op_sell_sig() && LAST_SELL_BARTIME != iTime(Symbol(), Period(), 0))

		{

			LAST_SELL_BARTIME = iTime(Symbol(), Period(), 0);

			open_positions(OP_SELL, OP_LOTS);	

		}

	}

	// ---

	T_SL();

}



// ---



// ---

// ---

void get_lots_by_input() 

{

//  volume assignment by input parameter 

  OP_LOTS = _Lots;

  double MinLot = MarketInfo(Symbol(),MODE_MINLOT);

  double MaxLot = MarketInfo(Symbol(),MODE_MAXLOT);

  double LotStep = MarketInfo(Symbol(),MODE_LOTSTEP);



  if (OP_LOTS < MinLot) OP_LOTS = MinLot;

  if (OP_LOTS > MaxLot) OP_LOTS = MaxLot;

}



// ---

// ---

bool find_orders(int magic = -1, int type = -1, int time = -1, string symb = "NULL", double price = -1, double lot = -1)

{

	// open order search function | 

// returns true if at least one order with suitable parameters is found

	for (int i = OrdersTotal() - 1; i >= 0; i--)

	{

		if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

			break;

		if (((OrderType() == type) || (type == -1))

			&& ((OrderMagicNumber() == magic) || (magic == -1))

			&& ((OrderSymbol() == symb) || (symb == "NULL" && OrderSymbol() == Symbol()))

			&& ((OrderOpenTime() >= time) || (time == -1))

			&& ((OrderLots() == lot) || (lot == -1))

			&& ((NormalizeDouble(OrderOpenPrice(), Digits) == NormalizeDouble(price, Digits)) || (price == -1)))

		{

			return (true);

			break;

		}

	}

	return (false);

}



// ---

string Market_Err_To_Str(int errCode)

{

	// error code decoding function 

// function covers only trading error codes

	string errText;

	switch (errCode)

	{

	case 0:

		errText = "5B >H81>:";

		break;

	case 1:

		errText = "5B >H81:8, => @57C;LB0B =58725AB5=";

		break;

	case 2:

		errText = "1I0O >H81:0";

		break;

	case 3:

		errText = "5?@028;L=K5 ?0@0<5B@K";

		break;

	case 4:

		errText = "">@3>2K9 A5@25@ 70=OB";

		break;

	case 5:

		errText = "!B0@0O 25@A8O :;85=BA:>3> B5@<8=0;0";

		break;

	case 6:

		errText = "5B A2O78 A B>@3>2K< A5@25@><";

		break;

	case 7:

		errText = "54>AB0B>G=> ?@02";

		break;

	case 8:

		errText = "!;8H:>< G0ABK5 70?@>AK";

		break;

	case 9:

		errText = "54>?CAB8<0O >?5@0F8O =0@CH0NI0O DC=:F8>=8@>20=85 A5@25@0";

		break;

	case 64:

		errText = "!G5B 701;>:8@>20=";

		break;

	case 65:

		errText = "5?@028;L=K9 =><5@ AG5B0";

		break;

	case 128:

		errText = "AB5: A@>: >6840=8O A>25@H5=8O A45;:8";

		break;

	case 129:

		errText = "5?@028;L=0O F5=0";

		break;

	case 130:

		errText = "5?@028;L=K5 AB>?K";

		break;

	case 131:

		errText = "5?@028;L=K9 >1J5<";

		break;

	case 132:

		errText = " K=>: 70:@KB";

		break;

	case 133:

		errText = "">@3>2;O 70?@5I5=0";

		break;

	case 134:

		errText = "54>AB0B>G=> 45=53 4;O A>25@H5=8O >?5@0F88";

		break;

	case 135:

		errText = "&5=0 87<5=8;0AL";

		break;

	case 136:

		errText = "5B F5=";

		break;

	case 137:

		errText = "@>:5@ 70=OB";

		break;

	case 138:

		errText = ">2K5 F5=K";

		break;

	case 139:

		errText = "@45@ 701;>:8@>20= 8 C65 >1@010BK205BAO";

		break;

	case 140:

		errText = " 07@5H5=0 B>;L:> ?>:C?:0";

		break;

	case 141:

		errText = "!;8H:>< <=>3> 70?@>A>2";

		break;

	case 145:

		errText = ">48D8:0F8O 70?@5I5=0, B0: :0: >@45@ A;8H:>< 1;87>: : @K=:C";

		break;

	case 146:

		errText = ">4A8AB5<0 B>@3>2;8 70=OB0";

		break;

	case 147:

		errText = "A?>;L7>20=85 40BK 8AB5G5=8O >@45@0 70?@5I5=> 1@>:5@><";

		break;

	case 148:

		errText = ">;8G5AB2> >B:@KBKE 8 >B;>65==KE >@45@>2 4>AB83;> ?@545;0, CAB0=>2;5==>3> 1@>:5@><.";

		break;

	case 4000:

		errText = "5B >H81:8";

		break;

	case 4001:

		errText = "5?@028;L=K9 C:070B5;L DC=:F88";

		break;

	case 4002:

		errText = "=45:A <0AA820 - 2=5 480?07>=0";

		break;

	case 4003:

		errText = "5B ?0<OB8 4;O AB5:0 DC=:F89";

		break;

	case 4004:

		errText = "5@5?>;=5=85 AB5:0 ?>A;5 @5:C@A82=>3> 2K7>20";

		break;

	case 4005:

		errText = "0 AB5:5 =5B ?0<OB8 4;O ?5@540G8 ?0@0<5B@>2";

		break;

	case 4006:

		errText = "5B ?0<OB8 4;O AB@>:>2>3> ?0@0<5B@0";

		break;

	case 4007:

		errText = "5B ?0<OB8 4;O 2@5<5==>9 AB@>:8";

		break;

	case 4008:

		errText = "58=8F80;878@>20==0O AB@>:0";

		break;

	case 4009:

		errText = "58=8F80;878@>20==0O AB@>:0 2 <0AA825";

		break;

	case 4010:

		errText = "5B ?0<OB8 4;O AB@>:>2>3> <0AA820";

		break;

	case 4011:

		errText = "!;8H:>< 4;8==0O AB@>:0";

		break;

	case 4012:

		errText = "AB0B>: >B 45;5=8O =0 =>;L";

		break;

	case 4013:

		errText = "5;5=85 =0 =>;L";

		break;

	case 4014:

		errText = "58725AB=0O :><0=40";

		break;

	case 4015:

		errText = "5?@028;L=K9 ?5@5E>4";

		break;

	case 4016:

		errText = "58=8F80;878@>20==K9 <0AA82";

		break;

	case 4017:

		errText = "K7>2K DLL =5 @07@5H5=K";

		break;

	case 4018:

		errText = "52>7<>6=> 703@C78BL 181;8>B5:C";

		break;

	case 4019:

		errText = "52>7<>6=> 2K720BL DC=:F8N";

		break;

	case 4020:

		errText = "K7>2K 2=5H=8E 181;8>B5G=KE DC=:F89 =5 @07@5H5=K";

		break;

	case 4021:

		errText = "54>AB0B>G=> ?0<OB8 4;O AB@>:8, 2>72@0I05<>9 87 DC=:F88";

		break;

	case 4022:

		errText = "!8AB5<0 70=OB0";

		break;

	case 4050:

		errText = "5?@028;L=>5 :>;8G5AB2> ?0@0<5B@>2 DC=:F88";

		break;

	case 4051:

		errText = "54>?CAB8<>5 7=0G5=85 ?0@0<5B@0 DC=:F88";

		break;

	case 4052:

		errText = "=CB@5==OO >H81:0 AB@>:>2>9 DC=:F88";

		break;

	case 4053:

		errText = "H81:0 <0AA820";

		break;

	case 4054:

		errText = "5?@028;L=>5 8A?>;L7>20=85 <0AA820-B09<A5@88";

		break;

	case 4055:

		errText = "H81:0 ?>;L7>20B5;LA:>3> 8=48:0B>@0";

		break;

	case 4056:

		errText = "0AA82K =5A>2<5AB8<K";

		break;

	case 4057:

		errText = "H81:0 >1@01>B:8 3;>10;L=K5E ?5@5<5==KE";

		break;

	case 4058:

		errText = ";>10;L=0O ?5@5<5==0O =5 >1=0@C65=0";

		break;

	case 4059:

		errText = "$C=:F8O =5 @07@5H5=0 2 B5AB>2>< @568<5";

		break;

	case 4060:

		errText = "$C=:F8O =5 @07@5H5=0";

		break;

	case 4061:

		errText = "H81:0 >B?@02:8 ?>GBK";

		break;

	case 4062:

		errText = "68405BAO ?0@0<5B@ B8?0 string";

		break;

	case 4063:

		errText = "68405BAO ?0@0<5B@ B8?0 integer";

		break;

	case 4064:

		errText = "68405BAO ?0@0<5B@ B8?0 double";

		break;

	case 4065:

		errText = " :0G5AB25 ?0@0<5B@0 >68405BAO <0AA82";

		break;

	case 4066:

		errText = "0?@>H5==K5 8AB>@8G5A:85 40==K5 2 A>AB>O=88 >1=>2;5=8O";

		break;

	case 4067:

		errText = "H81:0 ?@8 2K?>;=5=88 B>@3>2>9 >?5@0F88";

		break;

	case 4099:

		errText = ">=5F D09;0";

		break;

	case 4100:

		errText = "H81:0 ?@8 @01>B5 A D09;><";

		break;

	case 4101:

		errText = "5?@028;L=>5 8<O D09;0";

		break;

	case 4102:

		errText = "!;8H:>< <=>3> >B:@KBKE D09;>2";

		break;

	case 4103:

		errText = "52>7<>6=> >B:@KBL D09;";

		break;

	case 4104:

		errText = "5A>2<5AB8<K9 @568< 4>ABC?0 : D09;C";

		break;

	case 4105:

		errText = "8 >48= >@45@ =5 2K1@0=";

		break;

	case 4106:

		errText = "58725AB=K9 A8<2>;";

		break;

	case 4107:

		errText = "5?@028;L=K9 ?0@0<5B@ F5=K 4;O B>@3>2>9 DC=:F88";

		break;

	case 4108:

		errText = "525@=K9 =><5@ B8:5B0";

		break;

	case 4109:

		errText = "">@3>2;O =5 @07@5H5=0. 5>1E>48<> 2:;NG8BL >?F8N  07@5H8BL A>25B=8:C B>@3>20BL 2 A2>9AB20E M:A?5@B0.";

		break;

	case 4110:

		errText = ";8==K5 ?>78F88 =5 @07@5H5=K. 5>1E>48<> ?@>25@8BL A2>9AB20 M:A?5@B0.";

		break;

	case 4111:

		errText = ">@>B:85 ?>78F88 =5 @07@5H5=K. 5>1E>48<> ?@>25@8BL A2>9AB20 M:A?5@B0.";

		break;

	case 4200:

		errText = "1J5:B C65 ACI5AB2C5B";

		break;

	case 4201:

		errText = "0?@>H5=> =58725AB=>5 A2>9AB2> >1J5:B0";

		break;

	case 4202:

		errText = "1J5:B =5 ACI5AB2C5B";

		break;

	case 4203:

		errText = "58725AB=K9 B8? >1J5:B0";

		break;

	case 4204:

		errText = "5B 8<5=8 >1J5:B0";

		break;

	case 4205:

		errText = "H81:0 :>>@48=0B >1J5:B0";

		break;

	case 4206:

		errText = "5 =0945=> C:070==>5 ?>4>:=>";

		break;

	default:

		errText = "H81:0 ?@8 @01>B5 A >1J5:B><";

	}

	// ---

	return (errText);

}



// ---

void open_positions(int signal, double lot, double price = 0.0, string symb = "NONE", int mode = 0)

{

	// order opening function 

	RefreshRates();

	// ---

	int symbDigits = 0;

	string _symb = symb;

	// ---

	if (_symb == "NONE")

	{

		symbDigits = Digits;

		_symb = Symbol();

	}

	else

		symbDigits = int(MarketInfo(_symb, MODE_DIGITS));

	// ---

	if (signal == OP_BUY)

		price = NormalizeDouble(MarketInfo(_symb, MODE_ASK), symbDigits); // opening price for purchases

	if (signal == OP_SELL)

		price = NormalizeDouble(MarketInfo(_symb, MODE_BID), symbDigits); // closing price for purchases

	// ---

	int err = 0;

	for (int i = 0; i <= 5; i++)

	{

	   RefreshRates();

	   // ---

		int ticket = OrderSend(_symb, // symbol

			signal, // type order

			lot, // volyme

			NormalizeDouble(price, symbDigits), // opening price

			_Slippage * KDig.Get(), //level of allowable requote

			0, // Stop Loss

			0, // Take Profit

			_Comment, // comments

			_MagicNumber, // magic

			0, //expiration date (used in pending orders)

			CLR_NONE); //the color of the arrow on the chart (CLR_NONE - the arrow is not drawn)

		// ---

		if (ticket != -1)

		{

			err = 0;

			// ---

			if (!IsTesting())

				Sleep(1000);

			// ---

			RefreshRates();

			// ---

			if(_SL != 0 || _TP != 0)

			{

				for (int tryModify = 0; tryModify <= 5; tryModify++)

				{

					RefreshRates();

					// ---

					if (OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES))

					{

						double sl = NormalizeDouble(get_sl(_SL * KDig.Get(), signal, price, _symb), symbDigits);

						double tp = NormalizeDouble(get_tp(_TP * KDig.Get(), signal, price, _symb), symbDigits);

						// ---

						if (sl != 0 || tp != 0)

   						if (OrderModify(OrderTicket(), OrderOpenPrice(), sl, tp, OrderExpiration()))

   							break;

						// ---

						err = GetLastError(); // get the error code of the modification

					}

					// ---

					if (!IsTesting())

						Sleep(tryModify*1000);

				}

				// ---

				if (err != 0)

					Alert("Billing error SL/TP: " + Market_Err_To_Str(err));

			}

			// ---

			break;

		}

		else

		{

			err = GetLastError(); //get the error code opening



			if (err == 0)

				break;

			// ---

			i++;

			// ---

			if (!IsTesting())

				Sleep(i*500); // in case of an error, pause before a new attempt.



		}

	}

	// ---

	if (err != 0)

	{

		if(signal == OP_BUY)

			LAST_BUY_BARTIME = 0;

		if(signal == OP_SELL)

			LAST_SELL_BARTIME = 0;

		Alert("Open error: "  + Market_Err_To_Str(err)); // if there is an error, we display the message

	}

}



// ---

double get_tp(int tp_value, int type, double price = 0.0, string symb = "NONE")

{

// Take Profit calculation function for orders 

	double _price = price;

	string _symb = symb;

	// ---

	if (_symb == "NONE")

		_symb = Symbol();

	int symbDigits = int(MarketInfo(_symb, MODE_DIGITS));

	// ---

	if (_price == 0)

	{

		if (type == OP_BUY)

			_price = NormalizeDouble(MarketInfo(_symb, MODE_ASK), symbDigits);

		// ---

		if (type == OP_SELL)

			_price = NormalizeDouble(MarketInfo(_symb, MODE_BID), symbDigits);

	}

	// ---

	if (tp_value > 0)

	{

		if (type == OP_BUY || type == OP_BUYLIMIT || type == OP_BUYSTOP)

			return NormalizeDouble(_price + tp_value * MarketInfo(_symb, MODE_POINT), symbDigits);

		// ---

		if (type == OP_SELL || type == OP_SELLLIMIT || type == OP_SELLSTOP)

			return NormalizeDouble(_price - tp_value *  MarketInfo(_symb, MODE_POINT), symbDigits);

	}

	// ---

	return 0.0;

}



// ---

double get_sl(int sl_value, int type, double price = 0.0, string _symb = "NONE")

{

// MQL4 | Stop Loss calculation function for orders using a fixed SL value

	if (_symb == "NONE")

		_symb = Symbol();

	int symbDigits = int(MarketInfo(_symb, MODE_DIGITS));

	double symbPoint = MarketInfo(_symb, MODE_POINT);

	// ---

	if (price == 0.0)

	{

		if (type == OP_BUY)

			price = NormalizeDouble(MarketInfo(_symb, MODE_ASK), symbDigits);

		if (type == OP_SELL)

			price = NormalizeDouble(MarketInfo(_symb, MODE_BID), symbDigits);

	}

	// ---

	if (sl_value > 0)

	{

		if (type == OP_BUY || type == OP_BUYLIMIT || type == OP_BUYSTOP)

			return NormalizeDouble(price - sl_value * symbPoint, symbDigits);

		if (type == OP_SELL || type == OP_SELLLIMIT || type == OP_SELLSTOP)

			return NormalizeDouble(price + sl_value * symbPoint, symbDigits);

	}

	// ---

	return 0.0;

}



// ---

bool close_by_ticket(const int ticket, const int slippage)

{

	/*

MQL4 | function of closing a transaction by its number (ticket) | 

When closing a market order, the level of maximum allowable slippage is taken into account (slipage)

 */

	if (!OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES)) //we choose an order by ticket

{

	   return false;

	}

	

	int err = 0;

	

	for (int i = 0; i < 5; i++)

	{

	   ResetLastError();

	   

		RefreshRates();

		

		double price = 0.0;

		

		if (OrderType() == OP_BUY)

		{

			price = NormalizeDouble(SymbolInfoDouble(OrderSymbol(), SYMBOL_BID), (int)SymbolInfoInteger(OrderSymbol(), SYMBOL_DIGITS));

		}

		if (OrderType() == OP_SELL)

		{

			price = NormalizeDouble(SymbolInfoDouble(OrderSymbol(), SYMBOL_ASK), (int)SymbolInfoInteger(OrderSymbol(), SYMBOL_DIGITS));

		}

		// if a market order is closing it; if a pending order is deleted		   

	   bool result = false;

	   

		if (OrderType() <= OP_SELL) 

		{

			result = OrderClose(OrderTicket(), OrderLots(), price, slippage * KDig.Get(), clrNONE);

	   }

		else

		{

			result = OrderDelete(OrderTicket());

		}

		

		if (result) // if closing or deleting is successful, return true and exit the loop

		{

			return (true);

		}

		

		err = GetLastError();

		

		if (err != 0)

		{

			Print("Error of close_by_ticket() #" + (string)err + ": " + Market_Err_To_Str(err)); // if there is an error, we decrypt the log

		}

		

		Sleep(300 * i);

	}

	return (false);

}



// ---

bool cbm(int magic, int slippage, int type)

{

	/*

close by magic (closing all orders of this type with this MagicNumber)

Take into account the maximum allowed slip (slipage)

The close_by_ticket function is used.

*/

	int n = 0;

	RefreshRates();

	for (int i = OrdersTotal() - 1; i >= 0; i--)

	{

		if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))

			break;

		if ((OrderType() == type) && (OrderMagicNumber() == magic) && (Symbol() == OrderSymbol()))

		{

			close_by_ticket(OrderTicket(), slippage); // closing a deal

			n++; // we increase the counter of closed transactions

		}

	}

	if (n > 0) // if closing attempts were greater than 0, the function returns true

			return (true);

	return (false);

}



double e_High1()

{

	return High[1];

}

double e_Low1()

{

	return Low[1];

}

double e_High()

{

	return High[0];

}

double e_Low()

{

	return Low[0];

}

double e_Close()

{

	return Close[0];

}

double e_Open()

{

	return Open[0];

}

// ---

bool op_buy_sig()

{

	if(((e_High() - e_Low()) > ((e_High1() - e_Low1()) * 2)) && (e_Close() > e_Open()))

		return true;

	// ---

	return false;

}

// ---

bool op_sell_sig()

{

	if(((e_High() - e_Low()) > ((e_High1() - e_Low1()) * 2)) && (e_Close() < e_Open()))

		return true;

	// ---

	return false;

}

// ---

bool cl_buy_sig()

{

	return false;

}

// ---

bool cl_sell_sig()

{

	return false;

}

// ---

void T_SL()

{

	// Trailing Stop Loss function 

// work logic is identical to the usual trailing stop loss

	if (_TrailingStop <= 0)

		return; //if trailing stop loss is disabled, then exit the function

	for (int i = 0; i < OrdersTotal(); i++)

	{

		if (!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)))

			continue;

		if (OrderSymbol() != Symbol())

			continue;

		if (OrderMagicNumber() != _MagicNumber)

			continue;

		if (OrderType() == OP_BUY)

		{

			if (NormalizeDouble(Bid - OrderOpenPrice(), Digits) > NormalizeDouble(_TrailingStop * K_DIG * Point, Digits))

			{

				if (NormalizeDouble(OrderStopLoss(), Digits) < NormalizeDouble(Bid - (_TrailingStop*K_DIG + _TrailingStep*K_DIG - 1)*Point, Digits) || OrderStopLoss() == 0)

				{

					if(OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid - _TrailingStop*K_DIG*Point, Digits), OrderTakeProfit(), OrderExpiration()))

					{

					}

				}

		   }

		}

		else if (OrderType() == OP_SELL)

		{

			if (NormalizeDouble(OrderOpenPrice() - Ask, Digits) > NormalizeDouble(_TrailingStop * K_DIG * Point, Digits))

			{

				if (NormalizeDouble(OrderStopLoss(), Digits) > NormalizeDouble(Ask + (_TrailingStop*K_DIG + _TrailingStep*K_DIG - 1)*Point, Digits) || OrderStopLoss() == 0)

				{

					if(OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + _TrailingStop*K_DIG*Point, Digits), OrderTakeProfit(), OrderExpiration()))

					{

					}

				}

			}

		}

	}

}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---