EA to set fixed pips SL and TP as I enter trade

 
Hi everyone, I am looking for what I feel it's a really simple EA, I basically just want to enter the trade with a fixed SL and TP as a market order. It doesn't even have to calculate the lot size for me, just set the SL and TP based on the amount of pips that I give it... I'd prefer a free one but I will consider paid ones, please help me out, all the ones I tried were so complicated for no reason and in the end did more damage than help
 
Meliora Capital:
Hi everyone, I am looking for what I feel it's a really simple EA, I basically just want to enter the trade with a fixed SL and TP as a market order. It doesn't even have to calculate the lot size for me, just set the SL and TP based on the amount of pips that I give it... I'd prefer a free one but I will consider paid ones, please help me out, all the ones I tried were so complicated for no reason and in the end did more damage than help

hi Try this

#include <Trade\Trade.mqh>
enum dir{
sell=-1,//sell
buy=1//buy
};
input dir Direction=buy;//direction
input double Lot=0.01;//lot size
input int SL_points=100;//SL points
input int TP_points=100;//TP points

bool placed=false;
CTrade trade;
int OnInit()
  {
  placed=false;
  return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
  if(!placed){
    placed=true;
    MqlTick T;
    if(SymbolInfoTick(_Symbol,T)){ResetLastError();int errors=0;
      double limit=((double)SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL))*_Point;errors+=GetLastError();ResetLastError();
      double vMax=(double)SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);errors+=GetLastError();ResetLastError();
      double vMin=(double)SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);errors+=GetLastError();ResetLastError();
      if(errors==0){
        if(Lot>=vMin&&Lot<=vMax){
          double marketPrice=T.ask,sl=0.0,tp=0.0;
          if(Direction==sell){marketPrice=T.bid;}
          if(SL_points>0){
            sl=((double)SL_points)*_Point;
            if(sl<=limit){sl=limit*1.5;}
            if(Direction==buy){sl=NormalizeDouble(marketPrice-sl,_Digits);}
            else{sl=NormalizeDouble(marketPrice+sl,_Digits);}
            }
          if(TP_points>0){
            tp=((double)TP_points)*_Point;
            if(tp<=limit){tp=limit*1.5;}
            if(Direction==buy){tp=NormalizeDouble(marketPrice+tp,_Digits);}
            else{tp=NormalizeDouble(marketPrice-tp,_Digits);}
            }
          if(Direction==buy){trade.Buy(Lot,_Symbol,marketPrice,sl,tp);}
          else{trade.Sell(Lot,_Symbol,marketPrice,sl,tp);}
          }
        }
      }
    
    ExpertRemove();
    }
  }


 

Files:
simple.ex5  24 kb