simple buy and sell code

 

greeting to all

please i want very simple code 

when price go up for 5 points place a buy order take profit after 20 points and stop after 15 points

when price go down for 5 points place a sell order  take profit after 20 points and stop after 15 points  

without  indicator

***

 
This is community forum. You can hire a freelancer on this site to make an EA.
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2021.04.13
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Nor Azman Bin Ramli #:
This is community forum. You can hire a freelancer on this site to make an EA.

you could have just kept quiet... you not helping

 
Sphelele Sphesihle Lubanyana #:

you could have just kept quiet... you not helping

Why? His answer is correct and he wasn't disrespectful.
 
Khalid Amin: please i want very simple code

You haven't stated a problem, you stated a want.

You have only four choices:

  1. Search for it (CodeBase or Market). Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.

    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2019)

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help (2017)

 
Why you think you get it for free?
 
Khalid Amin:

greeting to all

please i want very simple code 

when price go up for 5 points place a buy order take profit after 20 points and stop after 15 points

when price go down for 5 points place a sell order  take profit after 20 points and stop after 15 points  

without  indicator

***

You really need to make an attempt or pay someone to have it completely coded start to finish.

   datetime             last_position_time         = 0;
   double               last_position_price_open   = 0.0;
   ENUM_POSITION_TYPE   last_position_type         = -1;

   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
           if(m_position.Time()> last_position_time)
              {
               last_position_time         = m_position.Time();
               last_position_price_open   = m_position.PriceOpen();               l
               last_position_type         = m_position.PositionType();
               }

      if(last_position_type==POSITION_TYPE_BUY )                     
      if (last_position_price_open + 5*_Point < m_symbol.Ask()  )
        {m_trade.Buy(0.01,m_symbol.Name(),Ask,0,(Ask+ 20*_Point),NULL);      
         return;}

      if(last_position_type==POSITION_TYPE_BUY )                     
      if(last_position_price_open - 5*_Point > m_symbol.Bid()  )
        {m_trade.Sell(0.01,m_symbol.Name(),Bid,0,Bid-20*_Point,NULL);    
         return;} 

      if(PositionsTotal()==0)
       {
        double Ask=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_ASK),_Digits);
        double Bid=NormalizeDouble (SymbolInfoDouble (_Symbol,SYMBOL_BID),_Digits);     
        m_trade.Sell(0.01,m_symbol.Name(),Bid,0,0,NULL);                 
        m_trade.Buy(0.01,m_symbol.Name(),Ask,0,0,NULL);      
        return;
         }