Remote Licensing System for expert advisors

MQL4 Experts Python JavaScript

Spécifications

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

Répondu

1
Développeur 1
Évaluation
(199)
Projets
287
52%
Arbitrage
0
En retard
1
0%
Gratuit
2
Développeur 2
Évaluation
(196)
Projets
200
28%
Arbitrage
0
En retard
3
2%
Gratuit
3
Développeur 3
Évaluation
(328)
Projets
387
33%
Arbitrage
2
100% / 0%
En retard
0
Travail
4
Développeur 4
Évaluation
(58)
Projets
89
38%
Arbitrage
26
4% / 77%
En retard
39
44%
Travail
5
Développeur 5
Évaluation
(18)
Projets
26
27%
Arbitrage
0
En retard
2
8%
Gratuit
Commandes similaires
I have two eas that open multiple trades per signal when it only open 1. I want this fixed and add sl and Tp too both eas when Tp and sl is hit I don’t want the Ea reopen trade, wait for next signal to open next trade
Starting from scratch, I need a solution to develop my own crypto trading and exchange platform. This platform should compare prices across various exchanges like Coinbase, Binance, KuCoin, and Unocoin, as well as different cryptocurrencies. The solution must identify opportunities to buy on one platform and sell on another for a profit, transferring funds to my personal wallet instantly for security. The bot should
Starting from scratch, I need a solution to develop my own crypto trading and exchange platform. This platform should compare prices across various exchanges like Coinbase, Binance, KuCoin, and Unocoin, as well as different cryptocurrencies. The solution must identify opportunities to buy on one platform and sell on another for a profit, transferring funds to my personal wallet instantly for security. The bot should
Starting from scratch, I need a solution to develop my own crypto trading and exchange platform. This platform should compare prices across various exchanges like Coinbase, Binance, KuCoin, and Unocoin, as well as different cryptocurrencies. The solution must identify opportunities to buy on one platform and sell on another for a profit, transferring funds to my personal wallet instantly for security. The bot should
Starting from scratch, I need a solution to create my own crypto trading and exchange platform. The platform should compare prices across various exchanges like Coinbase, Binance, KuCoin, and Unocoin (as examples) and different cryptocurrencies. The solution must identify opportunities to buy from one platform and sell on another for a profit, transferring the funds to my personal wallet instantly for security. The
Hello i need an expert who can help me modify an open source PineScript indicator code to add additional features. ONLY EXPERT WITH PROVE OF WORK SHOULD CONTACT FOR FURTHER DISCUSSION ON THE PROJECT
hi. I hv a strategy on tradingview need to convert to MT4/MT5 expert advisor for algo trading. would like to add some tradingview strategy setting to the EA(not included in my tradingview code): recalculate after order is filled, order size: xx% of equity
The Bot will use 2 Indicators and should follow these rules: Trade Entry: You must always enter the trade EXACTLY at the close of the current candle, with the expiry time set to the end of the next candle. It will only work if you click BUY or SELL EXACTLY in the last second of the current candle. I don't need to mention that you need a good internet connection and obviously should use the trading platform app. DO
looking for help to get my ibkr automated, i have strategies already built in composer and have JSON for them, i really just need to he setup and explanation on how to maintain it and add new strategies
1. Combination of Market Profiles on daily basis a) this should be combined if the bell curve is similar to the previous day. Rotational day (volume - standard deviation). b) If breakout, new range should be drawn Conclusion: Market profile should be combined on daily after the market is closed 2. Use Vwap indicator, with 0.5 - slow trend, 1.0 - normal trend, 1.5 fast trend. The stop loss should be under the trend

Informations sur le projet

Budget
50+ USD
Pour le développeur
45 USD
Délais
à 10 jour(s)