← К каталогу
Исходный код · ID 3861

GENIUSv101-ecn

geniusv101-ecn.mq4

Похожие материалы по тегам

market crusher ea guidlines.txtMQL · 3 общих тегов#1.mtf_collider_h4_close_13_v18bar.mq4MQL4 / MetaTrader 4 · 2 общих теговea robofibo source v.11.2.mq4MQL4 / MetaTrader 4 · 2 общих теговindicatorgoldy.pineTradingView · 2 общих тегов2 to 1 strategy with signals.pineTradingView · 2 общих теговfresh algo signals & overlays v25_6334471093901859175.pineTradingView · 2 общих тегов
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

GENIUSv101-ecn — торговый советник для MetaTrader 4. Программа автоматизирует открытие и закрытие ордеров на валютном рынке, используя индикатор Боллинджера для определения уровней входа в позицию. Советник поддерживает ручную и автоматическую настройку размера лота, а также гибкое управление временем торговли с учётом часового пояса.

Продукт включает систему управления рисками: стоп-лосс, тейк-профит, проверка уровня заморозки цен, ограничение по максимальной просадке и контроль безопасного спреда. Доступна функция повторного закрытия ордеров при возникновении ошибок, а также модификация ордеров после открытия.

Советник способен передавать торговые команды между терминалами через файловый обмен CSV-файлами, что позволяет реализовать распределённую торговлю. На графике отображается информационная панель с данными о текущих ордерах, спреде, балансе, эквити и просадке.

Настройки программы

НастройкаОписание
OrderOptions Настройки ордеров — Текстовый параметр, задающий группу настроек ордеров
Lots Размер лота — Фиксированный размер лота для торговли; при значении 0 лот рассчитывается автоматически на основе процента от маржи
LotsPercent Процент от маржи — Процент от свободной маржи, используемый для расчёта размера лота при Lots = 0
UseAutosettings Автоматические настройки — Включает автоматическую подстройку параметров советника на основе брокера и торгового инструмента
TakeProfit Тейк-профит — Значение тейк-профита в пунктах
TryTakeProfit Попытка закрытия по тейк-профиту — Включает или отключает попытку закрытия ордера по тейк-профиту при достижении минимальной прибыли
StopLoss Стоп-лосс — Значение стоп-лосса в пунктах
CheckFreezLevel Проверка уровня заморозки — Включает или отключает проверку уровня заморозки цен перед закрытием ордеров
SafeSpread Безопасный спред — Максимально допустимый спред в пунктах для открытия позиции
Slippage Проскальзывание — Допустимое проскальзывание цены при выполнении ордеров
MagicNumber Магический номер — Уникальный идентификатор ордеров, принадлежащих данному советнику
TimeOptions Настройки времени — Текстовый параметр, задающий группу настроек времени торговли
EachDayHourSettings Ежедневная настройка часов торговли — Включает ежедневную подстройку торговых часов с учётом дня недели
TradeTimeChoise Режим торговых часов — Выбор режима торговых часов (определяет набор предустановленных временных интервалов)
TradeDayOfWeek День недели торговли — День недели, в который разрешена торговля (0 — без ограничений по дню)
OpenHour1 Час открытия сессии 1 — Час открытия первой торговой сессии
CloseHour1 Час закрытия сессии 1 — Час закрытия первой торговой сессии
OpenHour2 Час открытия сессии 2 — Час открытия второй торговой сессии
CloseHour2 Час закрытия сессии 2 — Час закрытия второй торговой сессии
GMToffset Смещение часового пояса — Смещение часового пояса сервера относительно GMT
Получить полный код

Поиск по коду файла

string VersionNumber = "GENIUSv101-ecn";

#define EA "Genius"
#define VER "1_01"
#define OP_CLOSEBY   96
#define OP_MODIFY    97
#define OP_CLOSE     98
#define OP_NONE      99
#define OH1          0
#define CH1          1
#define OH2          2
#define CH2          3

#include <stdlib.mqh>

extern string OrderOptions=    "--------   Orders options  --------";
extern double Lots = 0;
extern int    LotsPercent = 30;
int    MaxDrawDown = 30;
extern bool   UseAutosettings = true;
extern int    TakeProfit = 30;
extern bool   TryTakeProfit = true;
extern int    StopLoss =35;
extern bool   CheckFreezLevel = true;
extern double SafeSpread=3.0;
extern int    Slippage=3;
extern int    MagicNumber=887;
int    TrailingStop = 50;
int    MinProfitValue = 5;
string TradeOptions=    "--------   Trade  options  --------";
int    ChannelBars = 10;
int    SellCorrection = 0;
int    BuyCorrection = 0;
bool   CheckTimeBar = false;
bool   EqualBars = true;

string TransmiteOptions="--------Transmite options--------";
bool   TradeTransferIn=false;
bool   TradeTransferOut=false;
bool   CheckDeleteFile=false;
int    TimeOutDeleteFile=10;
bool   CheckSetOrder=true;
int    TimeOutSetOrder=10;
bool   DeleteFileAfterChecking=false;
int    NumberRepeatCloseOrder = 0;

extern string TimeOptions=     "--------   Time   options  --------";
extern bool   EachDayHourSettings=false;
extern int    TradeTimeChoise = 1;
extern int    TradeDayOfWeek=0;
extern int    OpenHour1=21;
extern int    CloseHour1=4;
extern int    OpenHour2=22;
extern int    CloseHour2=24;
extern int    GMToffset=0;

string OtherOptions=    "--------   Other  options  --------";
bool   ShowComment=true;
bool   ShowSettings=true;
int    TimeOutComment=3;
bool   ShowPrint=true;
bool   ShowTime=true;
bool   ShowNameID=false;
bool   ShowMagicNumber=false;

int    BarSlippage=2;
int    BBPeriod=20;
int    BBShift=0;
double BBDeviations=2.5;
int    BBChannelValue = 50;
bool   ReversTrades = false;
bool   LackTrades = false;
bool   OneTradesToDirection = true;
bool   HideIndicators = false;
bool Result;

double lots, Equity, Drawdown, WorstDrawdown;
double ChartProfit;
double SmallestSpread=1000,Spread,LargestSpread=0;
double LocalPoint;

int TickRotate, TickNumber, Trend;
int LotDigit;
int SellOpenOrders, BuyOpenOrders, BuyPendingOrders, SellPendingOrders;

string Margin = "                          "; //
string _text1, _text2, _text3, _text4, _text5,  DisplayText, TickDisplay, CrLf = "\n";

int    pipp;
double pip;
string NameID, InitString;
double LotsForTrade;
double HighestBarsValue, LowestBarsValue;
color  ReversOrderColor = Black;
color  BuyOrderColor = Blue;
color  SellOrderColor = Red;
int    LastOrderBar, LastOrderTicket, CurrentOrderTicket, CurrentOrderProfitPoint, CurrentOrderTrailingStop;
bool   TradeLimit;
int    opposite_id = 1;
double LastOrderTime=0;
double CurrentOrderProfit;
double BuyOrderPrice;
bool   GoSell=false, GoBuy=false;
double MaxProfit=0, MaxLoss=0;
double UPmaxProfit=0, UPmaxLoss=0;
double UPminProfit=50, UPminLoss=50;
double DOWNmaxProfit=0,DOWNmaxLoss=0;
double DOWNminProfit=50, DOWNminLoss=50;
int    ReadOperationCounter, SaveOperationCounter;
int    CurrentDirection=OP_NONE, LastDirection=OP_NONE, CurrentMode=1,FileCounterMaxValue=10, CounterRepeatClose;
int    RB_Counter=0, RB_TimeBar=0, RB_Operation=1, RB_Ticket=2, RB_Price=3, RB_StopLoss=4, RB_TakeProfit=5; 
int    CB_Counter=0, CB_TimeBar=0, CB_Operation=1, CB_RecTicket=2, CB_OurTicket=3, CB_OpenPrice=4, CB_ClosePrice=5, CB_StopLoss=6, CB_TakeProfit=7; 
bool   fTime=true, StopTradesByMargin, LastisOrderSell, LastisOrderBuy, TryRepeatCloseOrder;
int    LastOpenHour1, LastCloseHour1, LastOpenHour2, LastCloseHour2;
bool   RepeatCloseOrder, FirstComment=false;
string ErrorArray[4207];
int    TradeTimeBuffer[5][4];
double ReceiveBuffer[1][6];
double CommandBuffer[1][8];
string CommentBuffer[20][2];

int init()
{
      // код доступен только после оплаты
   }

int deinit()
{
   ClearBuffer("ReceiveBuffer",RB_Counter);
   ClearBuffer("CommandBuffer",CB_Counter);
   ClearBuffer("CommentBuffer",0);
   Comment("");
return(0);}

int start()
  {
      // код доступен только после оплаты
   }

bool StopByMaxDrawDown(){
   bool result=false;
   double CurrentMaxDrawDown;
   if (MaxDrawDown==0 || (OpenHour1==0 && CloseHour1==12 && OpenHour2==12 && CloseHour2==24)) return(result);
   if (!isTimetoTrade(OpenHour1, CloseHour1) && !isTimetoTrade(OpenHour2, CloseHour2))
      {

      StopTradesByMargin=false;
      GlobalVariableSet("MaxAccountValue",AccountBalance());
      result=false;
      return(result);
      }
   if (StopTradesByMargin)
      {
      result=true;
      return(result);
      }
   if (GlobalVariableGet("MaxAccountValue")-AccountBalance()<0) GlobalVariableSet("MaxAccountValue",AccountBalance());
   CurrentMaxDrawDown=GlobalVariableGet("MaxAccountValue")-GlobalVariableGet("MaxAccountValue")*MaxDrawDown/100;
/*   Comment(
            "CurrentMaxDrawDown= ",CurrentMaxDrawDown,"\n",
            "MaxAccountValue= ",GlobalVariableGet("MaxAccountValue"),"\n",
            "AccountBalance()= ",AccountBalance(),"\n",
            "AccountEquity()= ",AccountEquity(),"\n"
            );*/
   if (CurrentMaxDrawDown-AccountEquity()>0)
      {
      while (isOrderBuy()) CloseBuyOrder();
      while (isOrderSell()) CloseSellOrder();

      StopTradesByMargin=true;
      result=true;
      return(result);
      }
return(result);}

void ResultTrades()
{
   if (OrderType()==OP_BUY)
      {
      if (UPmaxProfit<MaxProfit) UPmaxProfit=MaxProfit;
      if (UPmaxLoss<MaxLoss) UPmaxLoss=MaxLoss;
      }
   if (OrderType()==OP_SELL)
      {
      if (DOWNmaxProfit<MaxProfit) DOWNmaxProfit=MaxProfit;
      if (DOWNmaxLoss<MaxLoss) DOWNmaxLoss=MaxLoss;
      }
   MaxProfit=0;
   MaxLoss=0;
}

void CalculateTrades()
{
   if (OrderType()==OP_BUY)
      {
      if ((Bid-OrderOpenPrice())>MaxProfit) MaxProfit=Bid-OrderOpenPrice();
      if ((OrderOpenPrice()-Bid)>MaxLoss) MaxLoss=OrderOpenPrice()-Bid;
      }
   if (OrderType()==OP_SELL)
      {
      if ((OrderOpenPrice()-Ask)>MaxProfit) MaxProfit=OrderOpenPrice()-Ask;
      if ((Ask-OrderOpenPrice())>MaxLoss) MaxLoss=Ask-OrderOpenPrice();
      }
}

bool TimeCurrentBar(){
   bool result=false;
   if (CheckTimeBar && Time[0]==LastOrderTime) result=true;
return(result);}

bool isOrderSell(){
   bool result=false;
   int cnt=0, ticket, total;
   total=OrdersTotal();
   for (cnt=0;cnt<total;cnt++)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol()==Symbol() && OrderType()==OP_SELL)
         {
         if (!TradeTransferOut && OrderMagicNumber()!=MagicNumber) continue;
         result=true;
         CurrentOrderProfit = OrderProfit();
         CurrentOrderProfitPoint = (OrderOpenPrice()-Ask)/pip;
         break;
         }
      }
   if (LastisOrderSell && !result)
      {
      if (OrderStopLoss()!=0 || OrderTakeProfit()!=0) LastOrderTime=Time[0];
      }
   LastisOrderSell=result;
return(result);}

bool isOrderBuy(){
   bool result=false;
   int cnt=0, ticket, total;
   total=OrdersTotal();
   for (cnt=0;cnt<total;cnt++)
      {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol()==Symbol() && OrderType()==OP_BUY)
         {
         if (!TradeTransferOut && OrderMagicNumber()!=MagicNumber) continue;
         result=true;
         CurrentOrderProfit = OrderProfit();
         CurrentOrderProfitPoint = (Bid-OrderOpenPrice())/pip;
         break;
         }
      }
   if (LastisOrderBuy && !result)
      {
      if (OrderStopLoss()!=0 || OrderTakeProfit()!=0) LastOrderTime=Time[0];
      }
   LastisOrderBuy=result;
return(result);}

bool OrderRevers(){
   bool result=false;
   int cnt=0, ticket, total;
   total=OrdersTotal();
   for (cnt=0;cnt<total;cnt++)
   {
      ticket = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      ticket = OrderTicket();
      if (OrderSymbol()==Symbol() &&  OrderMagicNumber()==MagicNumber && OrderType()<=OP_SELL)
         {
         RefreshRates();
         if (OrderCloseBy(OrderTicket(),ticket,ReversOrderColor))
            {

            opposite_id=opposite_id+1;
            result=true;
            LastOrderTime=Time[0];

            if (TradeTransferOut) SaveFileOrder(Time[0], OP_CLOSEBY, ticket, OrderLots(), Bid, 0, 0);
            }
         else
            {

            }
         }
   }
return(result);}

bool CloseBuyOrder(){
   bool result=false;
   int cnt=0, ticket, total;
   total=OrdersTotal();
   for (cnt=0;cnt<total;cnt++)
      {
      ticket = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol()==Symbol() && OrderType()==OP_BUY)
         {
         if (isFreezLevel()) continue;
         if (!TradeTransferOut &&  OrderMagicNumber()==MagicNumber)
            {
            RefreshRates();
            if (OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,BuyOrderColor))
               {

               result=true;
               LastOrderTime=Time[0];
               LastDirection=OP_BUY;
               RepeatCloseOrder=false;

               }
            else
               {
               Print ("Error close Buy order: "+ErrorDescription(GetLastError()));
               RepeatCloseOrder=true;
               }
            }
         else
            {
            if (SaveFileOrder(Time[0], OP_CLOSE, OrderTicket(), OrderLots(), Bid, 0, 0))
               {

               result=true;
               LastOrderTime=Time[0];
               LastDirection=OP_BUY;
               RepeatCloseOrder=false;
               }
            else
               {
               Print ("Error transmite Close Buy order "+ErrorDescription(GetLastError()));
               RepeatCloseOrder=true;
               }
            }
         }
      }
return(result);}

bool CloseSellOrder(){
   bool result=false;
   int cnt=0, ticket, total;
   total=OrdersTotal();
   for (cnt=0;cnt<total;cnt++)
      {
      ticket = OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if (OrderSymbol()==Symbol() && OrderType()==OP_SELL)
         {
         if (isFreezLevel()) continue;
         if (!TradeTransferOut &&  OrderMagicNumber()==MagicNumber)
            {
            RefreshRates();
            if (OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,SellOrderColor))
               {

               result=true;
               LastOrderTime=Time[0];
               LastDirection=OP_SELL;
               RepeatCloseOrder=false;

               }
            else
               {
              Print("Error close Sell order: "+ErrorDescription(GetLastError()));
               RepeatCloseOrder=true;
               }
            }
         else
            {
            if (SaveFileOrder(Time[0], OP_CLOSE, OrderTicket(), OrderLots(), Ask, 0, 0))
               {

               result=true;
               LastOrderTime=Time[0];
               LastDirection=OP_SELL;
               RepeatCloseOrder=false;
               }
            else
               {
              Print("Error transmite Close Sell order "+ErrorDescription(GetLastError()));
               RepeatCloseOrder=true;
               }
            }
         }
      }
return(result);}

bool TryToCloseAgain(){
   bool result=false;
   if (!RepeatCloseOrder)
      {
      CounterRepeatClose=NumberRepeatCloseOrder;
      }
   else
      {
      CounterRepeatClose=CounterRepeatClose-1;
      if (CounterRepeatClose>0)
         {
         result=true;
         }
      else
         {
         RepeatCloseOrder=false;
         Print("TryToCloseAgain(): Error after repeat Close order "+ErrorDescription(GetLastError()));
         }
      }
return(result);}

bool isFreezLevel()
{
   bool result=false;
   double Price, FreezLevelValue, CurrentSlippage;
   if (CheckFreezLevel)
      {
      if (OrderStopLoss()!=0 || OrderTakeProfit()!=0)
         {
         if (OrderType()==OP_BUY) Price=Bid;
         if (OrderType()==OP_SELL) Price=Ask;
         FreezLevelValue=MarketInfo(Symbol(),MODE_FREEZELEVEL)*Point;
         if (  OrderStopLoss()!=0 && FreezLevelValue>(MathAbs(Price-OrderStopLoss()  ))) result=true;
         if (OrderTakeProfit()!=0 && FreezLevelValue>(MathAbs(Price-OrderTakeProfit()))) result=true;
         }
      }
return(result);}

bool SendBuyOrder(double SBO_StopLoss, double SBO_TakeProfit)
{
int ticket=0;
   RepeatCloseOrder=false;
   RefreshRates();
   if (SBO_StopLoss!=0)
      {
      if (SBO_StopLoss < MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp) SBO_StopLoss = MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp;
      SBO_StopLoss = NormalizeDouble(Bid - SBO_StopLoss*pip,Digits);
      }
   if (SBO_TakeProfit!=0)
      {
      if (SBO_TakeProfit < MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp) SBO_TakeProfit = MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp;
      SBO_TakeProfit = NormalizeDouble(Ask + SBO_TakeProfit*pip,Digits);
      }
   if (!TradeTransferOut)
      {
      RefreshRates();
      ticket=OrderSend(Symbol(),OP_BUY,LotsForTrade,Ask,Slippage,0,0, NameID,MagicNumber,0,BuyOrderColor);
      if(ticket>0)
         {
         if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
            {

             Result = OrderModify(ticket, OrderOpenPrice(), SBO_StopLoss, SBO_TakeProfit, 0, CLR_NONE);
             if (!Result) Print("Error modifying BUY order : ", ErrorDescription(GetLastError()));

            LastOrderTime=Time[0];
            LastOrderBar=Bars;
            CurrentOrderTicket=ticket;
            CurrentOrderTrailingStop=0;

            }
         }
      else 
         {
         Print("Error open Buy order: "+ErrorDescription(GetLastError()));
         return(false);
         }
      }
   else
      {
      if (SaveFileOrder(Time[0], OP_BUY, ticket, LotsForTrade, Ask, SBO_StopLoss, SBO_TakeProfit))
         {

         LastOrderTime=Time[0];
         LastOrderBar=Bars;
         CurrentOrderTrailingStop=0;
         }
      else 
         {
         Print("Error transmite open Buy order "+ErrorDescription(GetLastError()));
         return(false);
         }
      }
return(true);}

bool SendSellOrder(double SSO_StopLoss, double SSO_TakeProfit)
{
int ticket=0;
   RepeatCloseOrder=false;
   RefreshRates();
   if (SSO_StopLoss!=0)
      {
      if (SSO_StopLoss < MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp) SSO_StopLoss = MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp;
      SSO_StopLoss = NormalizeDouble(Ask + SSO_StopLoss*pip,Digits);
      }
   if (SSO_TakeProfit!=0)
      {
      if (SSO_TakeProfit < MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp) SSO_TakeProfit = MarketInfo(Symbol(),MODE_STOPLEVEL)/pipp;
      SSO_TakeProfit = NormalizeDouble(Bid - SSO_TakeProfit*pip,Digits);
      }
   if (!TradeTransferOut)
      {
      RefreshRates();
      ticket=OrderSend(Symbol(),OP_SELL,LotsForTrade,Bid,Slippage,0,0, NameID,MagicNumber,0,SellOrderColor);
      if(ticket>0)
         {
         if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
            {

             Result = OrderModify(ticket, OrderOpenPrice(), SSO_StopLoss, SSO_TakeProfit, 0, CLR_NONE);
             if (!Result) Print("Error modifying Sell order : ", ErrorDescription(GetLastError()));

            LastOrderTime=Time[0];
            LastOrderBar=Bars;
            CurrentOrderTicket=ticket;
            CurrentOrderTrailingStop=0;

            }
         }
      else 
         {
         Print("Error open Sell order: "+ErrorDescription(GetLastError()));
         return(false);
         }
      }
   else
      {
      if (SaveFileOrder(Time[0], OP_SELL, ticket, LotsForTrade, Bid, SSO_StopLoss, SSO_TakeProfit))
         {

         LastOrderTime=Time[0];
         LastOrderBar=Bars;
         CurrentOrderTrailingStop=0;
         }
      else 
         {
         Print("Error transmite open Sell order "+ErrorDescription(GetLastError()));
         return(false);
         }
      }
return(true);}

bool StartRulls()
{
   double LotsStep, LotsMin, LotsMax;
   int LotsDigit;
   if (EachDayHourSettings && DayOfWeek()>0)
      {
      OpenHour1 =TradeTimeBuffer[DayOfWeek()-1][OH1];
      CloseHour1=TradeTimeBuffer[DayOfWeek()-1][CH1];
      OpenHour2 =TradeTimeBuffer[DayOfWeek()-1][OH2];
      CloseHour2=TradeTimeBuffer[DayOfWeek()-1][CH2];
      }
   if (!FirstComment)
      {
      FirstComment=true;
      }
   else
      {
      if (LastOpenHour1!=OpenHour1 || LastCloseHour1!=CloseHour1 || LastOpenHour2!=OpenHour2 || LastCloseHour2!=CloseHour2)
         {
         LastOpenHour1=OpenHour1; LastCloseHour1=CloseHour1; LastOpenHour2=OpenHour2; LastCloseHour2=CloseHour2;

         }
      }

   if (IsOptimization())
      {
      if (OpenHour1>12) return(false);
      if (CloseHour1>12) return(false);
      if (OpenHour2<12) return(false);
      if (CloseHour2<12) return(false);
      if (OpenHour1>CloseHour1 || OpenHour2>CloseHour2) return(false);
      }
   if(Bars<100)
     {

      return(false);  
     }
   if (IsTesting() || IsOptimization())
      {
      TradeTransferIn=false;
      TradeTransferOut=false;
      }
   if (TradeTransferIn && TradeTransferOut)
      {

      return(false);
      }
   LotsStep = NormalizeDouble(MarketInfo(Symbol(), MODE_LOTSTEP),2);
   LotsMin=NormalizeDouble(MarketInfo(Symbol(),MODE_MINLOT),2);
   LotsMax=NormalizeDouble(MarketInfo(Symbol(), MODE_MAXLOT),2);
   if (LotsStep==0.01) LotsDigit=2; else LotsDigit=1;

   if (Lots==0) LotsForTrade=NormalizeDouble(AccountFreeMargin()*LotsPercent/100000,LotsDigit);
   else LotsForTrade=Lots;
   if (LotsForTrade>LotsMax) LotsForTrade=LotsMax;
   if (LotsForTrade<LotsMin) LotsForTrade=LotsMin;
return(true);}

bool isBBtoBuy(){
   bool result=false;
   if ((iBBHigh(0)-iBBLow(0))/pip<=BBChannelValue && Bid<iBBMidle(0))
       result=true;
return(result);}

bool isBBtoSell(){
   bool result=false;
   if ((iBBHigh(0)-iBBLow(0))/pip<=BBChannelValue && Bid>iBBMidle(0))
       result=true;
return(result);}

bool isMinProfittoClose(){
   bool result=false;
   if (CurrentOrderProfitPoint>0 && CurrentOrderProfitPoint>=MinProfitValue && MinProfitValue!=0)
      {
      result=true;
      }
return(result);}

bool isTrailingStop(){
   bool result=false;
   int OrderTrailingStop;
   if (CurrentOrderProfitPoint>MinProfitValue)
      {
      OrderTrailingStop=MathCeil(CurrentOrderProfitPoint*TrailingStop/100);
      if (OrderTrailingStop<1) OrderTrailingStop=1;
      if (CurrentOrderTrailingStop<OrderTrailingStop) CurrentOrderTrailingStop=OrderTrailingStop;
      }
   if (CurrentOrderTrailingStop!=0 && CurrentOrderProfitPoint<=CurrentOrderTrailingStop) result=true;
return(result);}

bool isTradeLimit(){
   bool result=false;
   if (CurrentOrderTicket!=LastOrderTicket)
      {
      CurrentOrderTicket=LastOrderTicket;
      TradeLimit=false;
      }
   if (TradeLimit) return(result);
   if (OrderProfit()>0) return(result);
   TradeLimit=true;
return(result);}

bool isGroDtoBuy(bool checkspread=false){
   bool result=false;
   if (checkspread) if (Ask-Bid>SafeSpread*pip) return(false);
   if (!ReversTrades)
      {
      if (Bid < (LowestBarsValue-pip*BuyCorrection) || (EqualBars && Bid <= (LowestBarsValue-pip*BuyCorrection))) result=true;
      }
   else
      {
      if (Bid > HighestBarsValue || (EqualBars && Bid >= HighestBarsValue)) result=true;
      }
return(result);}

bool isGroDtoSell(bool checkspread=false){
   bool result=false;
   if (checkspread) if (Ask-Bid>SafeSpread*pip) return(false);
   if (!ReversTrades)
      {
      if (Bid > (HighestBarsValue+pip*SellCorrection) || (EqualBars && Bid >= (HighestBarsValue+pip*SellCorrection))) result=true;
      }
   else
      {
      if (Bid < LowestBarsValue || (EqualBars && Bid <= LowestBarsValue)) result=true;
      }
return(result);}

bool isTimetoTrade(int OpenHour, int CloseHour)
{
   bool result = false;
   int CurrentHour=Hour();
   if (OpenHour > 23 || OpenHour < 0 ) OpenHour = 0;
   if (CloseHour > 23 || CloseHour < 0 ) CloseHour = 0;
   if (OpenHour<CloseHour && (Hour()>=OpenHour && Hour()<CloseHour)) result=true;
   if (OpenHour>CloseHour && (Hour()>=OpenHour || Hour()<CloseHour)) result=true;
   if (DayOfWeek()!=TradeDayOfWeek && TradeDayOfWeek!=0) result = false;
return(result);}

bool SaveFileOrder( int FileOrderTimeBar,int FileOrderOperation, int FileOrderTicket, double FileOrderLots, double FileOrderPrice, double FileOrderStopLoss, double FileOrderTakeProfit)
{
   int handle;
   bool result = false;
   string FileName = Symbol() + ".csv" ;
   handle=FileOpen(FileName,FILE_CSV|FILE_WRITE,';');
   if(handle<1)
      {
    Print ("SaveFileOrder(): File "+FileName+" creation error :" +ErrorDescription(GetLastError()));
      return(result);
      }
   FileWrite(handle,

         FileOrderOperation,
         FileOrderLots,
         FileOrderTicket,
         FileOrderPrice,
         DoubleToStr(FileOrderStopLoss,Digits),
         DoubleToStr(FileOrderTakeProfit,Digits));
   FileClose(handle);

   result=true;

   SaveOperationCounter =SaveOperationCounter + 1;
   if (SaveOperationCounter>FileCounterMaxValue) SaveOperationCounter=0;

   datetime TimeSaveFile=TimeLocal();
   if (CheckDeleteFile)
      {

      result=false;
      while (TimeLocal()-TimeSaveFile < TimeOutDeleteFile)
         {
         if (!isFile())
            {
            result=true;
            break;
            }
         Sleep(25);
         }
      if (!result)
         {
         if (DeleteFileAfterChecking)
            {
            if (FileErase(FileName))
               {

               }
            else
               {

               }
 

Показано первые 50% кода (символов: 37171)

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
3 717,10₽ ≈ $45.44