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
Hello, I have indicators for tradestation written in easylanguage and I need them in tradingview pinescript. So I need someone to convert these tradestation indicators to tradingview. Do you think you can help me with that
Excellent trade 30 - 50 USD
I need an expert robot developer that will create a robot using 4 indicators to generate signal for the robot to execute,it should be solely based on candle stick period analysis and the robot will be made to allow indicators parameters adjustment and user input example "parameters optimization" or "hyperparameter optimization as the terminology might be, please I need it urgently, the interested developer should
Hello, I need a professional programmer to help me design an EA that can be able to take trades towards a market direction with accurate prediction. This EA should be able to identify the market trend direction and take multiple trades towards the direction and also able to close the trades together when market wants to reverse at the best profit level. The input at the beginning will be for the EA to be input with a
Hello, i am looking for a very skilled developer, who is an Expert in object orientated programming in MQL5. I have some indicators (MQL4 and MQL5), which i like to translate them into separate classes. Then all classes should be included into an Expert Adivsor. I have developed a comprehensive and complex strategy, which i would like to have as an EA. Therefore you should have deeper knowledge in OOP-MQL5 and have a
hey friends, I am looking to build a smart trading robot, for the capital market. He knew how to trade in all the different types of trade. Example - in shares, currencies, index, indices, ETFs, funds, commodities, options, futures and so on. Suitable for trading on all stock exchanges in the world. It will be possible to install the trading robot in the MetaTrader 5 trading software. But it will also be possible to
I am seeking a skilled developer to create a web application that monitors and displays statistics for MT4/MT5 trading accounts, similar to Myfxbook. The application will collect account and trade data from MT4/MT5 platforms, process and analyze this data, and present it through a user-friendly interface
i Want to convert this Trading View Code to Mt4 Indicator indicator("NEOM Smart Money Concepts ", "NEOM Smart Money Concepts " , overlay = true , max_labels_count = 500 , max_lines_count = 500 , max_boxes_count = 500 , max_bars_back = 500) //-----------------------------------------------------------------------------{ //Constants //-----------------------------------------------------------------------------{ color
Hello Amazing developer am looking for profitable EA for mt4 and made for some past year and i will be looking forward for your bid if you have mt4 EA let Negotiate in the contact box best regards
Hello Amazing developer am looking for profitable EA for mt4 and made for some past year and i will be looking forward for your bid if you have mt4 EA let negotitate in the contact box best regartds
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)

Project information

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