Remote Licensing System for expert advisors

MQL4 전문가 Python JavaScript

명시

//+------------------------------------------------------------------+
//|                                                      Hedging.mq4 |
//|                                  Copyright 2023, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


input int consecutiveBullCandles = 4;
input int consecutiveBearCandles = 4;

input double TP                  = 60.0;
input double LotSize             = 0.01;

input int maxAllowedPositions     = 1; //Set the max Buy positions
input int maxSellAllowedPositions = 1;//Set the max Sell positions



double bTakeProfit; 
double sTakeProfit;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
  bTakeProfit = takeProfit(Symbol(), OP_BUY, TP);
  sTakeProfit = takeProfit(Symbol(), OP_SELL, TP);
  
   

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
  
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   
   if(newBar())
   {      
      OpenPosition();
      LastOpenPrice2();
   }
   CloseTradeOnTP();
   
      
  }
//+------------------------------------------------------------------+

bool CheckConsecutiveBullish()
{
    bool isConsecutiveBullish = true;
    
    for (int i = 1; i <= consecutiveBullCandles; i++)
    {
        if (Close[i] <= Open[i])
        {
            isConsecutiveBullish = false;
            break;
        }
        
    }

    return isConsecutiveBullish;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
bool CheckConsecutiveBearish()
{
   bool isConsecutiveBearish = true;
   
   for (int i = 1; i<= consecutiveBearCandles; i++)
   {
      if (Close[i] >= Open[i])
      {
         isConsecutiveBearish = false;
         break;
      }
   }
   
   return isConsecutiveBearish;
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double stopLoss(string symbol, ENUM_ORDER_TYPE type, double slPips)
{
   
   if(slPips>0)
     {
         if(type==OP_BUY)
           {
              return (Ask - (slPips*SymbolInfoDouble(Symbol(), SYMBOL_POINT)*10));
           }
           
         else
           {
              return (Bid + (slPips*SymbolInfoDouble(Symbol(), SYMBOL_POINT)*10));
           }
     }
   else  return 0;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

double takeProfit(string symbol, ENUM_ORDER_TYPE type, double tpPips)
{
   
   if(tpPips>0)
     {
         if(type==OP_BUY)
           {
              return (Ask + (tpPips*SymbolInfoDouble(Symbol(), SYMBOL_POINT)*10));
           }
           
         else
           {
              return (Bid - (tpPips*SymbolInfoDouble(Symbol(), SYMBOL_POINT)*10));
           }
     }
   else  return 0;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int MaxBuyOpenPositions(int maxAllowed)
{
   int totalPositions = OrdersTotal(); // Get the total number of open positions
   
   if (totalPositions >= maxAllowed)
   {
      Print("Maximum number of open positions reached!");
      return maxAllowed;
   }
   
   return totalPositions;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int MaxSellOpenPositions(int maxAllowed)
{
   int totalSellPositions = OrdersTotal(); // Get the total number of open positions
   
   if (totalSellPositions >= maxAllowed)
   {
      Print("Maximum number of open positions reached!");
      return maxAllowed;
   }
   
   return totalSellPositions;
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


void OpenPosition()
{
   int totalPositions = MaxBuyOpenPositions(maxAllowedPositions);
   int totalSellPositions = MaxSellOpenPositions(maxSellAllowedPositions);
    
   if (CheckConsecutiveBullish() && totalPositions < maxAllowedPositions)
   {
      int Buy = OrderSend(NULL, OP_BUY, LotSize, Ask, 10, 0, bTakeProfit,NULL);
   }
   
   if (CheckConsecutiveBearish() && totalSellPositions < maxSellAllowedPositions)
   {
      int Sell = OrderSend(NULL, OP_SELL, LotSize, Bid, 10, 0, sTakeProfit,NULL);
   }
   
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

void CloseBuyOrder()
{
   for(int i=0; i<OrdersTotal(); i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if(OrderType()==OP_BUY)
         {
            int CloseBuy = OrderClose(OrderTicket(), OrderLots(), MarketInfo(Symbol(),MODE_BID),Red);
            if(CloseBuy < 0) Print("Close Buy Error: " + string(GetLastError()));
         }
      }
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CloseSellOrder()
{
   for(int i=0; i<OrdersTotal(); i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if(OrderType()==OP_SELL)
         {
            int CloseSell = OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_ASK), Red);
            if(CloseSell < 0) Print("Close Sell Error: " + string(GetLastError()));
         }
      }
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ClosePendingOrder()
{
   for(int i=0; i<OrdersTotal(); i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
      {
         if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)
         {
            int Delete = OrderDelete(OrderTicket());
            if(Delete < 0) Print("Delete Error: " + string(GetLastError()));
         }
      }
   }
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

void CloseTradeOnTP()
{
   
   for(int i=0; i<OrdersHistoryTotal(); i++)
   {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
      {
         if(OrderTakeProfit()==OrderClosePrice())
         if(TimeCurrent() - OrderCloseTime() <= 5)
         {
            CloseBuyOrder();
            CloseSellOrder();
            ClosePendingOrder();
         }
      }
   }
   
}
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

bool newBar()
{
   datetime          currentTime =  iTime(Symbol(), Period(), 0);
   static datetime   priorTime   =  currentTime;
   bool              result      =  (currentTime!=priorTime);
   priorTime                     =  currentTime;
   
   return result;
}



//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
/*double GetLastOpenPositionLotSize()
{
    int totalOrders = OrdersTotal();
    
    if (totalOrders > 0)
    {
        int lastPositionIndex = totalOrders - 1;
        
        if (OrderSelect(lastPositionIndex, SELECT_BY_POS, MODE_TRADES))
        {
            double lastPositionLotSize = OrderLots();
            return lastPositionLotSize;
        }
    }
    
    // If no open positions found, return 0.0
    return 0.0;
}*/

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double orderLotsize()
{
   if(OrdersTotal()>0)
   {
      for(int i=0; i<OrdersTotal(); i++)
      {
         if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && (OrderType()<=1))
         {
            double Lotsize = OrderLots() * 2;
            return Lotsize;
         }
      }
   }
   return 0.0;
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

bool CheckPendingOrderLimit2(int maxOrders)
{
    int totalPendingOrders = 0;
    

    for (int i = 0; i < OrdersTotal(); i++)
    {
        if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
            if (OrderType() == OP_BUYSTOP || OrderType() == OP_SELLSTOP)
            {
                totalPendingOrders++;
                if (totalPendingOrders >= maxOrders)
                    return false; // Maximum limit reached
            }
        }
    }

    return true; // Within the limit
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void LastOpenPrice2()
{
   double previousStopPrice = 0;
   
   int maxPendingOrders = 2; // Maximum allowed number of pending orders

   // Check if the number of pending orders is within the limit
   if (!CheckPendingOrderLimit2(maxPendingOrders))
   {
       Print("Pending order limit reached. Cannot open new pending order.");
       return;
   }

   for(int i = 0; i < OrdersTotal(); i++)
   {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
      {
         if(OrderType() == OP_BUY || OrderType() == OP_SELL)
         {
            double openPrice = OrderOpenPrice();
            string symbol = OrderSymbol();

            if(previousStopPrice == 0)
            {
               if(OrderType() == OP_BUY)
               {
                  double stopPrice = openPrice - (30 * SymbolInfoDouble(symbol, SYMBOL_POINT) * 10);
                  int sellStop = OrderSend(symbol, OP_SELLSTOP, orderLotsize(), stopPrice, 10, 0, sTakeProfit);
                  if(sellStop > 0)
                  {
                     previousStopPrice = stopPrice;
                  }
               }
               else if(OrderType() == OP_SELL)
               {
                  double stopPrice = openPrice + (30 * SymbolInfoDouble(symbol, SYMBOL_POINT) * 10);
                  int buyStop = OrderSend(symbol, OP_BUYSTOP, orderLotsize(), stopPrice, 10, 0, bTakeProfit);
                  if(buyStop < 0)
                  {
                     Print("Error: " + string(GetLastError()));
                  }
                  if(buyStop > 0)
                  {
                     previousStopPrice = stopPrice;
                  }
               }
            }
         }
      }
   }
}

Hi developers.

I'm interested in creating an online licensing system for my expert advisors.  This will allow me control the EA remotely. 

When the user places the EA on the chart, it automatically synchronises with the expiry date and account number to know whether the user is a valid user or not.

응답함

1
개발자 1
등급
(199)
프로젝트
287
52%
중재
0
기한 초과
1
0%
무료
2
개발자 2
등급
(194)
프로젝트
198
27%
중재
0
기한 초과
3
2%
무료
3
개발자 3
등급
(324)
프로젝트
384
33%
중재
2
100% / 0%
기한 초과
0
작업중
4
개발자 4
등급
(58)
프로젝트
89
38%
중재
26
4% / 77%
기한 초과
39
44%
작업중
5
개발자 5
등급
(18)
프로젝트
25
28%
중재
0
기한 초과
2
8%
무료
비슷한 주문
Hi I need a software like Mirror trade copier ( https://www.antonnel.net/mirror/ ) which directly connect to the Accounts over api with out MT4 terminal and copies trades from mater to client. I want the same and possible improvement like can be accessed over a url and dashboard for some basic metrics (optional)
Hello Greetings. I have a custom tradingview strategy I would like to convert to Metatrader 5 ( mt5 ) . I have the source code a and with me. Kindly bid if it is what you can do for me and let discuss about the project. Thanks
Hello there, I need a mql4 EA based on pine script custom indicator. You need to do pine script indicator convert into mt4 advisor. If you are able to do please contact. Thanks
I need a AI signal generating bot for forex trading. The bot should operate such that when i put it in a chart it will analyse the market, after several minutes it will display whether the trade is buying or selling. It should display the one minute, five minute,15minute, 30 minute, one hour, 4 hours and daily time frame whether they are buying or selling. If it is buying the arrow should be green and if it is
Using Bollinger Band only. When price closes above upper BB, open Buy. If the length of the candle body that closed above the upper BB is more than Y pips, then do not Buy and remove the EA. Otherwise, continue to open Buy if crosses and close above upper BB and the number of positions is not more than Max No of Positions. The user will choose either Buy or Sell only. When price closes below the lower BB, close all
Modify an existing Python bot to trade bollinger bands, with iqoption api Currently the bot strategy is wrong, I am limited in my knowledge here and hope to fix this Hope to work with more experience people out there in relation to iqoption api and python
I want to have my existing EA adjusted by adding the following risk parameters: - hedge order when closed in loss - hedge order when loss is reached (immediately)- loss in money - loss in % - Grid trade when closed in loss - grid trade when loss is reached (immediately) - max number of grids - distance of grids - grids TP money - grids TP % - hedge after money loss (when grids) - hedge after % loss (when grids)
Hello freelancers here, I need an expert to help me with coding my script which is already working in pinescript, Moreover, i want a system whereby i can sell my trading bot and can give access with a license, I need an expert that can help me with this
Необходимо конвертировать индикатор в Mql5. Индикатор должен индентично работать иметь тот же функционал. Ссылка на индикатор . Я планирую конвертировать 5 индикаторов в общей сложности. Надеюсь на долгосрочное сотрудничество
Hello freelancers here, I need an expert to help me with coding my script which is already working in pinescript, Moreover, i want a system whereby i can sell my trading bot and can give access with a license, I need an expert that can help me with this, and my budget is $20, Thank you

프로젝트 정보

예산
50+ USD
개발자에게
45 USD
기한
 10 일