#property version "1.00"
#property strict
extern int interval = 25; //Interval
extern double lot = 0.1; //Lot Size
extern int TP = 400; //Take Profit
extern int magic = 962231; //Magic number
extern int slippage = 2; //Slippage
extern int ExpDate = 48; //Expiration Hour Order
extern int bar1size = 900; //Bar 1 Size
double buyPrice,//define BuyStop price
buyTP, //Take Profit BuyStop
buySL, //Stop Loss BuyStop
sellPrice, //define SellStop price
sellTP, //Take Profit SellStop
sellSL; //Stop Loss SellStop
double open1,//first candle Open price
open2, //second candle Open price
close1, //first candle Close price
close2, //second candle Close price
low1, //first candle Low price
low2, //second candle Low price
high1, //first candle High price
high2; //second candle High price
datetime _ExpDate=0; // local variable to determine order's expiration time
double _bar1size; // local variable required to eliminate a flat market
datetime timeBUOVB_BEOVB; // time of a bar when pattern orders were opened, to avoid re-opening
int OnInit()
{
// код доступен только после оплаты
}
void OnDeinit(const int reason)
{
}
void OnTick()
{
// код доступен только после оплаты
}
int OrderOpenF(string OO_symbol,
int OO_cmd,
double OO_volume,
double OO_price,
int OO_slippage,
double OO_stoploss,
double OO_takeprofit,
string OO_comment,
int OO_magic,
datetime OO_expiration,
color OO_arrow_color)
{
int result = -1; //result of opening an order
int Error = 0; //error when opening an order
int attempt = 0; //amount of performed attempts
int attemptMax = 3; //maximum amount of attempts
bool exit_loop = false; //exit the loop
string lang=TerminalInfoString(TERMINAL_LANGUAGE); //trading terminal language, for defining the language of the messages
double stopllvl=NormalizeDouble(MarketInfo(OO_symbol,MODE_STOPLEVEL)*MarketInfo(OO_symbol,MODE_POINT),Digits); //minimum stop loss/ take profit level, in points
if(OO_cmd==OP_BUY || OO_cmd==OP_BUYLIMIT || OO_cmd==OP_BUYSTOP)
{
double tp = (OO_takeprofit - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
double sl = (OO_price - OO_stoploss)/MarketInfo(OO_symbol, MODE_POINT);
if(tp>0 && tp<=stopllvl)
{
OO_takeprofit=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
}
if(sl>0 && sl<=stopllvl)
{
OO_stoploss=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
}
}
if(OO_cmd==OP_SELL || OO_cmd==OP_SELLLIMIT || OO_cmd==OP_SELLSTOP)
{
double tp = (OO_price - OO_takeprofit)/MarketInfo(OO_symbol, MODE_POINT);
double sl = (OO_stoploss - OO_price)/MarketInfo(OO_symbol, MODE_POINT);
if(tp>0 && tp<=stopllvl)
{
OO_takeprofit=OO_price -(stopllvl+2*MarketInfo(OO_symbol,MODE_POINT));
}
if(sl>0 && sl<=stopllvl)
{
OO_stoploss=OO_price+stopllvl+2*MarketInfo(OO_symbol,MODE_POINT);
}
}
while(!exit_loop)
{
result=OrderSend(OO_symbol,OO_cmd,OO_volume,OO_price,OO_slippage,OO_stoploss,OO_takeprofit,OO_comment,OO_magic,OO_expiration,OO_arrow_color); //attempt to open an order using the specified parameters
if(result<0)
{
Error = GetLastError(); //assign a code to an error
switch(Error) //error enumeration
{ //order closing error enumeration and an attempt to fix them
case 2:
if(attempt<attemptMax)
{
attempt=attempt+1; //define one more attempt
Sleep(3000); //3 seconds of delay
RefreshRates();
break; //exit switch
}
if(attempt==attemptMax)
{
attempt=0; //reset the amount of attempts to zero
exit_loop = true; //exit while
break; //exit switch
}
case 3:
RefreshRates();
exit_loop = true; //exit while
break; //exit switch
case 4:
if(attempt<attemptMax)
{
attempt=attempt+1; //define one more attempt
Показано первые 50% кода (символов: 8180)
Введите ваш email и нажмите кнопку, чтобы перейти к оплате.