Need HELP!!! Need TrailingStop and Break even for this Template

sunnyboy

Trader
Jul 26, 2011
2
0
17
Hello,


i need a TrailingStop and a Break even in this Template.
both can be simple. and please dont touch the other code (buy and sell strategy) to much
that i could work easly with it in future
Thanks for Help

++++++++++++++++++++++++++++++++++++++++++
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Sebastian Meissner"


extern string Expert_Name = "Trading Basti";
extern double iLots=0.1;
extern double iMaximumRisk= 0.02;
extern int iStopLoss=650;
extern int iTakeProfit=50;
extern int iSlippage=3;
extern int iMaxTrades=1;
extern int iMagicNumber=336699;

double stochg,stochr;

int iTotalTrades;
int iOrderOpenStatus;
int iErrorNumber;

string strErrorMessage;

double LotsOptimized()
{
double lot=iLots;
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*iMaximumRisk/1000.0,1);
//---- return lot size
if(lot<0.1) lot=0.1;
if(lot>50.0) lot=50.0;
return(lot);
}

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{



//----
return(0);
}

//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}

//+------------------------------------------------------------------+
//| The functions from this point to the start function are where |
//| changes are made to test other systems or strategies. |
//|+-----------------------------------------------------------------+

//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{

stochg = iCustom (NULL,0,"Stochastic",8,3,3,MODE_SMA,0,MODE_MAIN,0);
stochr = iCustom (NULL,0,"Stochastic",8,3,3,MODE_SMA,0,MODE_SIGNAL,0);
double willd = 81;
double willu = 19;
double will1 = 80;
double will2 = 20;
//Buy-Logik


//Sell-Logik


// Buy-Order ausführen

iTotalTrades=OrdersTotal();

if (( stochg > will2) && (stochg > stochr) && (stochr < will2) && (stochr > willu) && (iTotalTrades < iMaxTrades))

{
double dBuyStopLoss=Ask-(iStopLoss*Point);
double dBuyTakeProfit=Ask+(iTakeProfit*Point);

iOrderOpenStatus=OrderSend (Symbol(), OP_BUY,LotsOptimized(), Ask, iSlippage, dBuyStopLoss, dBuyTakeProfit, "Trading Basti",iMagicNumber,0,Green);
if (iOrderOpenStatus<0)
{
iErrorNumber=GetLastError();
Print ("Order fehlgeschlagen!: ", iErrorNumber);
return;
}
}

// Sell-Order ausführen

iTotalTrades=OrdersTotal();

if (( stochg < will1) && (stochg < stochr) && (stochr > will1) && (stochr < willd) && (iTotalTrades < iMaxTrades))

{
double dSellStopLoss=Bid+(iStopLoss*Point);
double dSellTakeProfit=Bid-(iTakeProfit*Point);


iOrderOpenStatus=OrderSend (Symbol(), OP_SELL,LotsOptimized(), Bid, iSlippage, dSellStopLoss, dSellTakeProfit, "Trading Basti",iMagicNumber,0,Red);
if (iOrderOpenStatus<0)
{
iErrorNumber=GetLastError();
Print ("Order fehlgeschlagen!: ", iErrorNumber);
return;
}
}
return(0);
}
//----
 

sunnyboy

Trader
Jul 26, 2011
2
0
17
here is the code in mq4
please help me
i would pay 20$ for the programmer
 

Attachments

  • bastiEA.mq4
    3.2 KB · Views: 21
Last edited:

ForexNewbie51

Active Trader
Sep 22, 2011
31
5
44
Hello. If you have not got this programming done, why not consider a Trade Manager EA? There are several about in the public arena. Some are attached to the same pair chart but others are for any open trades. If you google Trade+Manager+MT4 you'll get several hits. Ones that come to mind include Swiss Army Knife, ManageTP2V4, Toolkit of Semi-Automated 11_EA's.

Hope this helps
 

ForexNewbie51

Active Trader
Sep 22, 2011
31
5
44
Yes, some Trade Manage EA's would require a separate chart. But there are some that can be on one chart and manage all / any by symbol, Magic Number or even Comment. If you do a search on trade+manage+by+[symbol] or [magic number] or [comment] you will find them. I have a proprietary one where I can select any so can't share it. They are "out there" though. I just did a search and got several hits - this one looks like it might suit your need. I hope it does.

http://www.allforexindicators.com/indidetail.aspx?name=Multi+purpose+trade+manager