Remote Licensing System for expert advisors

MQL4 Esperti Python JavaScript

Specifiche

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

Con risposta

1
Sviluppatore 1
Valutazioni
(199)
Progetti
287
52%
Arbitraggio
0
In ritardo
1
0%
Gratuito
2
Sviluppatore 2
Valutazioni
(194)
Progetti
198
27%
Arbitraggio
0
In ritardo
3
2%
Gratuito
3
Sviluppatore 3
Valutazioni
(324)
Progetti
384
33%
Arbitraggio
2
100% / 0%
In ritardo
0
In elaborazione
4
Sviluppatore 4
Valutazioni
(58)
Progetti
89
38%
Arbitraggio
26
4% / 77%
In ritardo
39
44%
In elaborazione
5
Sviluppatore 5
Valutazioni
(18)
Progetti
25
28%
Arbitraggio
0
In ritardo
2
8%
Gratuito
Ordini simili
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 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
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
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
Hi, Do you have an indicator or expert and would like to protect and control it? What you will get protection and control Customer control panel The number of products is unlimited. You can add any number of your own experts and consultations You can give a trial period for your product, for example a week or a month, after which the customer subscribes Monthly, annually, or for life, depending on the customer’s
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
Need a good synthetic EA 50 - 1000 USD
I don't have specifications. If you're good at building an EA with good coding, accuracy, 85% money management, good trading decision. Please apply let's discuss Bussiness. Price below is not specific we can discuss new price depending on your professionalism

Informazioni sul progetto

Budget
50+ USD
Per lo sviluppatore
45 USD
Scadenze
a 10 giorno(i)