Remote Licensing System for expert advisors

MQL4 Experts Python JavaScript

Specification

//+------------------------------------------------------------------+
//|                                                      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.

Responded

1
Developer 1
Rating
(199)
Projects
287
52%
Arbitration
0
Overdue
1
0%
Free
2
Developer 2
Rating
(193)
Projects
197
27%
Arbitration
0
Overdue
3
2%
Free
3
Developer 3
Rating
(324)
Projects
384
33%
Arbitration
2
100% / 0%
Overdue
0
Working
4
Developer 4
Rating
(58)
Projects
89
38%
Arbitration
26
4% / 77%
Overdue
39
44%
Working
5
Developer 5
Rating
(18)
Projects
25
28%
Arbitration
0
Overdue
2
8%
Free
Similar orders
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
Hello dear developer, I need you to help me with conversion of my ea file but i only have the ex4 file of the ea to but converted to DLL format, no source code is available
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
Hello freelancers here, I need an expert freelancer to help me convert an expert advisor from MT4 to MT5. I have the MT4 source code, As for now i only got $15 for this project i don't have much on me at the moment, So i need someone who can work long terms cause i still have other projects i need him to work on for me
An EA based on Fibonacci 100 - 750 USD
I am in need of 3 EA based on Fibonacci re-tracement after a high or low is made,each EA will have a hedge trade on it.the hedge trade will be at the 50 percent of the Fibonacci..this will be present on all 3 EA, all three EA will have different levels of re-tracement, while the hedge trade will be a continuation (buy/sell stop), while the re-tracement trades will be (buy/sell limit)This EA must work on timeframe

Project information

Budget
50+ USD
For the developer
45 USD
Deadline
to 10 day(s)