Trigger with horizontal or diagonal line

MQL4 Experts C++

Job finished

Execution time 23 hours
Feedback from customer
Good programmer, great job, thank you :)
Feedback from employee
Good Customer Thank you !

Specification

Hello,
I would like my order to trigger on a line I trace.

Example:

When the  moving average to 1 touches my red line
 then my order this triggers as on the photo ...


eurusd

















//+------------------------------------------------------------------+
//|                                                       test35.mq4 |
//|                                                              xxx |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "xxx"
#property link      "http://www.mql5.com"
#property version   "1.00"
#property strict
extern double  lots1          = 0.01;
extern double  lots2          = 0.03;
extern double  lots3          = 0.06;


input int      TakeProfit1     =   10;
input int      StopLoss1       =   10;
input int      TakeProfit2     =   10;
input int      StopLoss2       =   10;
input int      TakeProfit3     =   10;
input int      StopLoss3       =   10;


input int period=14;
input int period1=14; 
input int period2=14; 
input int period3=14; 
input int period4=14;


input int OverBought=51; // Over bought level
input int OverSold=49; // Over sold level
input int OverBought1=51; // Over bought level
input int OverSold1=49; // Over sold level
input int OverBought2=51; // Over bought level
input int OverSold2=49; // Over sold level
input int OverBought3=51; // Over bought level
input int OverSold3=49; // Over sold level
input int OverBought4=51; // Over bought level
input int OverSold4  =49;
//extern int     MovingPeriod         = 2;
//extern int     MovingShift          = 1;
//extern int Period_PCh = 20;
extern int     magic=321569;
extern double  Level          = 1.3923;
extern double  MaxDeviation   = 9;         // Max Deviation, points

bool RunOnce=false;
int last_order_check=false;
datetime EaStartTime=TimeCurrent();
double takeprofit1=TakeProfit1;
double stoploss1=StopLoss1;
double takeprofit2=TakeProfit2;
double stoploss2=StopLoss2;
double takeprofit3=TakeProfit3;
double stoploss3=StopLoss3;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()

  {
   MathSrand(GetTickCount());
   if(Digits==5 || Digits==3)
     {
      takeprofit1  =TakeProfit1*10;
      stoploss1    =StopLoss1*10;
      takeprofit2  =TakeProfit2*10;
      stoploss2    =StopLoss2*10;
      takeprofit3  =TakeProfit3*10;
      stoploss3    =StopLoss3*10;
      
     }
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnTimer()
  {
   OnTick();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  
  {
   if (RunOnce)// ExpertRemove();
   if(IsLastOrderClose())
     {
      OnInit();
      Print("Ea Closed Manually ");
      EaStartTime=TimeCurrent();
     }
        int ticet;
   int t=MathRand();
     
      if(CountVsego()==0)
     {
      //if(t>16383)
      //  {
        // if(Counts()==0) //  && (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0))
          //if(Volume[0]>1) return;
              
             if(Counts()==0)//  &&    MA_Fast1>MA_Low1 && rsi>OverBought && Close[0] > High[4] && Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)
             
           {
            ticet=OrderSend(Symbol(),OP_BUY,lots1,Ask,3,Bid-stoploss1*Point,Ask+takeprofit2*Point,"1",magic,0,clrGreen);
           }
       
      // Partie 1 
      // else if(t<16383)rsi>OverBought1if( Close[0] > High[1] )  Break1();[4]))
     // else if( Close[0] < Low[1] )  Break2();
  
       //  {
         if(Counts()==0 )//  &&  MA_Fast1<MA_Low1  && rsi<OverSold && Close[0] < Low[4] && Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)
          
           {
            ticet=OrderSend(Symbol(),OP_SELL,lots1,Bid,3,Ask+stoploss1*Point,Bid-takeprofit2*Point,"1",magic,0,clrRed);
           }
        
      // Partie 1 
      // else if(t<16383)
         
         //if(Counts()==0//  && (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0))
   
        
        
        
     // if(t>0)
     //   {
         if(Counts()==1)// && (MA_Fast1>MA_Low1 && rsi>OverBought && Close[0] > High[4]))// && (RunOnce || (Ask >=Level && Ask<=Level+(MaxDeviation*_Point) && Level !=0)))
          {
            ticet=OrderSend(Symbol(),OP_BUY,lots2,Ask,3,Bid-stoploss2*Point,Ask+takeprofit2*Point,"2",magic,0,clrGreen);
           }        
         //if (getLastOrderCloseType() == 1) ticet=OrderSend(Symbol(),OP_BUY,lots2,Ask,3,Bid-stoploss2*Point,Ask+takeprofit2*Point,"4",magic,0,clrGreen);
         //  if (getLastOrderCloseType() == 0) ticet=OrderSend(Symbol(),OP_SELL,lots2,Bid,3,Ask+stoploss2*Point,Bid-takeprofit2*Point,"3",magic,0,clrRed);
        
       // }
      // Partie 2 
     // else if(t<16383)
      //  {
         if(Counts()==1)// && (MA_Fast1<MA_Low1  && rsi<OverSold && Close[0] < Low[4]))// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
          {
            ticet=OrderSend(Symbol(),OP_SELL,lots2,Bid,3,Ask+stoploss2*Point,Bid-takeprofit2*Point,"2",magic,0,clrRed);
           }
           
           
           
      //  }
     // if(t>16383)
     //   {
         if(Counts()==2)// &&  (MA_Fast1>MA_Low1 && rsi>OverBought && Close[0] > High[4]))
           {
            ticet=OrderSend(Symbol(),OP_BUY,lots3,Ask,3,Bid-stoploss3*Point,Ask+takeprofit3*Point,"3",magic,0,clrGreen);
           }
         // if (getLastOrderCloseType() == 1) ticet=OrderSend(Symbol(),OP_BUY,lots3,Ask,3,Bid-stoploss3*Point,Ask+takeprofit3*Point,"4",magic,0,clrGreen);
         //if (getLastOrderCloseType() == 0) ticet=OrderSend(Symbol(),OP_SELL,lots3,Bid,3,Ask+stoploss3*Point,Bid-takeprofit3*Point,"3",magic,0,clrRed);
        
     // } //(rsi<OverSold))
      //Partie 3 
     // else if(t<16383)rsi>OverBought2))
     //   {
        if(Counts()==2)// &&  (MA_Fast1<MA_Low1  && rsi<OverSold && Close[0] < Low[4]))// && (RunOnce || (Bid <=Level && Bid >= Level-(MaxDeviation*_Point) && Level !=0)))
           {
          ticet=OrderSend(Symbol(),OP_SELL,lots3,Bid,3,Ask+stoploss3*Point,Bid-takeprofit3*Point,"3",magic,0,clrRed);
           }
           
           
           
     
        
     }
  }
   int getLastOrderCloseType ()
   {
   datetime t = 0;
   int tick = -1;
   
   int i,total=OrdersHistoryTotal();
   for(i=0; i<total; i++) {
      if (OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic)
         {
            if (t < OrderCloseTime()){
               t = OrderCloseTime();
               tick = OrderTicket();
            }
         }
      }
   }
   
   for(i=0; i<total; i++) {
      if (OrderSelect(tick,SELECT_BY_TICKET)) {
         return OrderType();
      }
   }
   
   return tick;
}  
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountSELL()
  {
   int count=0;
   int i;
   for(i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL)
            count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountBUY()
  {
   int count=0;
   int i;
   for(i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY)
            count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
int Counts()
  {
   int count=0,i;

   for(i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderOpenTime()>=EaStartTime)
           {
            if(OrderProfit()>0)
              {
               if(count==0)
                 {
                  OnInit();
                  EaStartTime=TimeCurrent();
                  RunOnce = true;
                  return(count);
                                              
                }
              }
            else
              {
               count++;
              }
           }
         if(count> 2 )
            {
               OnInit();
               EaStartTime=TimeCurrent();
               RunOnce = true;
              return(count);
            }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountVsego()
  {
   int Vsego;
   Vsego=CountBUY()+CountSELL();

   return(Vsego);
  }
//+------------------------------------------------------------------+
bool IsLastOrderClose()
  {
   bool signal=false;
   for(int i=OrdersHistoryTotal()-1;i>=0;i--)
     {
      bool select=OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
      if(select && OrderSymbol()==_Symbol && OrderMagicNumber()==magic)
        {
         if(OrderType()==OP_BUY && OrderOpenTime()>=EaStartTime)
           {
            if(OrderClosePrice()>OrderStopLoss() && OrderClosePrice()<OrderTakeProfit())
              {
               signal=true;
              }
            break;
           }
         else if(OrderType()==OP_SELL && OrderOpenTime()>=EaStartTime)
           {
            if(OrderClosePrice()<OrderStopLoss() && OrderClosePrice()>OrderTakeProfit())
              {
               signal=true;
              }
            break;
           }
        }
     }
   return(signal);
  }
//+------------------------------------------------------------------+


Responded

1
Developer 1
Rating
(8)
Projects
14
29%
Arbitration
1
0% / 0%
Overdue
7
50%
Free
2
Developer 2
Rating
(22)
Projects
28
29%
Arbitration
3
0% / 67%
Overdue
7
25%
Free
Similar orders
300 usd offered - I want a developer to convert x3 pinscript indicators to Mt4 and then to Forext tester 2 which is very similar. yesterday, 16:46 MQL4 Indicators Converting Description Comments Specification I'm looking for a quote from a developer who can compile this source code as DLL file so that it works on Forex Tester 5 They are all open source trading view indicators that need to be converted to MT4 then
Build this Expert Advisor (EA) 1. Risk Management Risk per Trade : The EA will calculate the lot size based on the risk percentage (1-2% of the account balance). This will be a customizable input. Stop Loss & Trailing Stop : The EA will place a stop loss at a defined level (based on strategy parameters like ATR, recent support/resistance, etc.) and will implement a trailing stop to lock in profits as the trade moves
Hello, I have a physically trading keyboard and i want to connect it with tradelocker, mt4,mt5 and ctrader. People need to be able to open and close a position with the keyboard really fast. i need it on macos, windows and linux. (desktop) My competition is: www.magickeys.trade My goal is to be the number 1 to sell the keyboards + software. When people order a tradingkeyboard they will get a mail after the purchase
Job Title: Expert Advisor (EA) Developer for Forex Trading Job Description: I am seeking an experienced Expert Advisor (EA) developer to create a customized trading bot for the MetaTrader 4/5 platform. The bot will be designed to execute a sophisticated trading strategy that incorporates daily range calculations, cost averaging, and hedging with precise pip management. The successful candidate should have strong
I need an expert advisor based on MACD and MA signals. It must have check and handling of trade operations errors. The main criteria for opening and closing positions: ◇Both Main and Signal direction must be shown by Arrows which is going to be for buy and sell positions
I need an expert to help me with adding more features to my existing mt4 EA I think the addition I want added to this EA is fairly simple--but I don't really understand how programming works, Contact me for a long term work, This is not the only project, I will explain the features in the inbox, Let me know if you can do it
**Project Title:** Development of a Complex High-Performance EA for Step Index **Project Overview:** I need an advanced Expert Advisor (EA) for trading the Step Index on MetaTrader 5. The EA should use multiple indicators and advanced risk management techniques to enhance profitability and manage risks effectively. **Trading Strategy Details:** Indicators: - 50-period EMA - 200-period EMA - RSI with 14 periods - MACD
Hft live account 30 - 200 USD
i need a high frequency trading (hft) expert advisor, that can be used to trade on demo and live accounts icmarket and 8cap. The EA has to be highly profitable, giving daily profit. If a test version is available, please send, to foster a faster transaction. like the ones that pass prop firm and demo but adjustment where it work on live with low latency
Lihle's trades 30+ USD
``` //+------------------------------------------------------------------+ //| Hello World Expert Advisor | //| | //| This is a basic EA that buys and sells based on a simple | //| moving average crossover strategy. | //+------------------------------------------------------------------+ #property version "0.01" #property strict input int FastMA
Indicator in use: Bollinger Bands Mechanism (See diagrams provided for help) Sells: 1. Trigger candle: When candle low is above the top Bollinger band - accurate to the lowest point scale (e.g. On EURUSD if candle low is 1.07915 and the value of top bollinger is 1.07914 - this is a sell signal; or if on Futures if the increment is .25 or .10 then this is used) 2. Enter sell ONLY on the next candle if price breaks

Project information

Budget
30+ USD
VAT (20%): 6 USD
Total: 36 USD
For the developer
27 USD
Deadline
to 1 day(s)