I need add one function to this code

 
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property version   "1.00"
#property strict
#property show_inputs
enum Operation{
   buy=OP_BUY,    //BUY
   sell=OP_SELL,   //SELL
};

extern double Lots=1;           //Specify position size, this is ignored if you use the Risk %
extern double RiskPercentage=2; //%risk is 2
input Operation Command=buy;   //order type
extern int TakeProfit=60;      //Take profit is 60pips
extern int StopLoss=30;       //stop loss is 30pips
extern int Slippage=2;        //Slippage in pips
extern string Cmt="";         //Comment for the order if you want one
//Function to normalize the digits
double CalculateNormalizedDigits()
{
   if(Digits<=3){
      return(0.01);
   }
   else if(Digits>=4){
      return(0.0001);
   }
   else return(0);
}
void OnStart()
  {
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
int Cmd=Command;
   
   //Normalize the digits and calculate the position size
   double nTickValue=MarketInfo(Symbol(),MODE_TICKVALUE);
   double nDigits=CalculateNormalizedDigits();
   if(Digits==3 || Digits==5){
      Slippage=Slippage*10;
      nTickValue=nTickValue*10;
   }
   if(RiskPercentage==2){
      Lots=(AccountBalance()*RiskPercentage/100)/(StopLoss*nTickValue);
      Lots=MathRound(Lots/MarketInfo(Symbol(),MODE_LOTSTEP))*MarketInfo(Symbol(),MODE_LOTSTEP);
   }
   
   //Set the open, stop loss and take profit prices
   double OpenPrice=0;
   double TakeProfitPrice=0;
   double StopLossPrice=0;
   
   if(Cmd==OP_BUY){
      OpenPrice=NormalizeDouble(MarketInfo(Symbol(),MODE_ASK),Digits);
      if(TakeProfit!=0) TakeProfitPrice=NormalizeDouble(OpenPrice+TakeProfit*nDigits,Digits);
      if(StopLoss!=0) StopLossPrice=NormalizeDouble(OpenPrice-StopLoss*nDigits,Digits);
      
   } 
   if(Cmd==OP_SELL){
      OpenPrice=NormalizeDouble(MarketInfo(Symbol(),MODE_BID),Digits);
      if(TakeProfit!=0) TakeProfitPrice=NormalizeDouble(OpenPrice-TakeProfit*nDigits,Digits);
      if(StopLoss!=0) StopLossPrice=NormalizeDouble(OpenPrice+StopLoss*nDigits,Digits);
   } 
   
   //Print on screen the informations to see what we are submitting
   Print("Opening an Order ",Command," size ",Lots, " open price ",OpenPrice," slippage ",Slippage," SL ",StopLossPrice," TP ",TakeProfitPrice," comment ",Cmt);
   
   //Submit the order, check the it has been accepted
   int OrderNumber;
   OrderNumber=OrderSend(Symbol(),Cmd,Lots,OpenPrice,Slippage,StopLossPrice,TakeProfitPrice,Cmt);
   if(OrderNumber>0){
      Print("Order ",OrderNumber," open");
   }
   else{
      Print("Order failed with error - ",GetLastError());
   
   }
  }
   
  
//+------------------------------------------------------------------+

 I need ea or script for the following data

       Input: risk-2%

                  TP-60 pips

                  Sl-30Pips 

                  Type of order- Buy/sell

It will be executed order but i need to add "Once order is executed,After price is reached to 75% of Tp Automatically Sl should be Break Even point".

                 

                   Can anyone code it and share it here? 

                                     Thank you .

 

Forum on trading, automated trading systems and testing trading strategies



Welcome,

  • Usually people who can't code don't receive free help on this forum, though it could happen if you are lucky, be patient.
  • If you show your attempts and describe well your problem, you will most probably receive an answer from the community.
  • If you don't want to learn to code, nothing bad, you can either look at the Codebase if something free already exists, or in the Market for paid products (sometimes free also).
  • Finally, you also have the option to hire a programmer in the Freelance section.

Good luck.


 
BHANU: ,just i need to add this condition to  code
So do it! learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you. We are willing to help you when you post your attempt (using SRC) and the nature of your problem.
 
whroeder1:
So do it! learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you. We are willing to help you when you post your attempt (using SRC) and the nature of your problem.


Thank you for your information.

                            I already have a code for the above data but I need to add only one condition that is BE level after reached to tp 40 pips Sl should be BE level so can you please suggest me how to write that function ? .

                            I'm a beginner to the  programming.  

 
BHANU:


Thank you for your information.

                            I already have a code for the above data but I need to add only one condition that is BE level after reached to tp 40 pips Sl should be BE level so can you please suggest me how to write that function ? .

                            I'm a beginner to the  programming.  


Try reading up on OrderModify() 

There is an example in the documentation.

HTH

OrderModify - Trade Functions - MQL4 Reference
OrderModify - Trade Functions - MQL4 Reference
  • docs.mql4.com
OrderModify - Trade Functions - MQL4 Reference
 
Alain Verleyen:

Helo just read u r message..felt gud bro..i want a ea based on trailing..can u plz help me a bit


the ea goes this way


1.buy trade should open  5points above the moving average 20 n should trail 5 pips in profit , fr example...if the price is 10 it  has to trail to 15 as profit again frm 15 it has to takeprofit as 20,bt in case  if the 15 target is nt reached it has to open a sell order ,instantly..i hope u gt me..

the trailing should keep on trailing until the price comes below or equal to 20 moving average..n again the sell trades begin trailing..can u plz kindly help me in coding this??...

 
legendofcibola:

helo man can u plz help m in building this ea

the ea goes this way


1.buy trade should open  5points above the moving average 20 n should trail 5 pips in profit , fr example...if the price is 10 it  has to trail to 15 as profit again frm 15 it has to takeprofit as 20,bt in case  if the 15 target is nt reached it has to open a sell order ,instantly..i hope u gt me..

the trailing should keep on trailing until the price comes below or equal to 20 moving average..n again the sell trades begin trailing..can u plz kindly help me in coding this??...

Hey you can try CodeBase  there are many good ones and free too 

Search - MQL5.community
Search - MQL5.community
  • www.mql5.com
Searching is based on morphology and is insensitive to case. All letters, no matter of their case, will be processed as lowercase. By default, our search engine shows pages, that...
 
legendofcibola: helo man can u plz help m in building this ea
Help you with what? You haven't stated a problem, you stated a want. You have only four choices:
  1. Search for it. 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 yours.

  4. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum

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.04.21
 
Their profile promises big riches, but in the end they don't even want to pay a cent for coding. If you help, don't expect them to come back and say thanks.
 
lippmaje:
Their profile promises big riches, but in the end they don't even want to pay a cent for coding. If you help, don't expect them to come back and say thanks.

From my experience it can even be worst than just not saying thanks, it happened to me to be insulted (really) because I said to someone on the forum "I will check when I have time" and then had forgotten to do it !!!

Reason: