Forex Forum - EarnForex
Serving Traders Since 2005
 

Go Back   Forex Forum - EarnForex > MetaTrader > MetaTrader Expert Advisors

MetaTrader Expert Advisors Post and discuss the MetaTrader expert advisors here.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 26th July 2011, 10:52
Default Avatar
Junior Member
 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question Need HELP!!! Need TrailingStop and Break even for this Template

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()*iMaximumRi sk/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);
}
//----
Reply With Quote
  #2 (permalink)  
Old 27th July 2011, 07:54
Default Avatar
Junior Member
 
Join Date: Jul 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

here is the code in mq4
please help me
i would pay 20$ for the programmer
Attached Files
File Type: mq4 bastiEA.mq4 (3.2 KB, 7 views)

Last edited by sunnyboy; 27th July 2011 at 08:39.
Reply With Quote
  #3 (permalink)  
Old 23rd September 2011, 21:24
Default Avatar
Junior Member
 
Join Date: Sep 2011
Posts: 24
Thanks: 5
Thanked 3 Times in 2 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old 24th September 2011, 11:23
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

But if you attach some trade managing EA to a chart, you no longer can attach a normal trading EA to it, can you?
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
  #5 (permalink)  
Old 30th September 2011, 00:30
Default Avatar
Junior Member
 
Join Date: Sep 2011
Posts: 24
Thanks: 5
Thanked 3 Times in 2 Posts
Default

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/in...+trade+manager
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Euro Is Unable to Break $1.43 Level alessio09 Forex News 2 16th August 2009 08:22


All times are GMT. The time now is 03:16.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Inactive Reminders By Icora Web Design

SEO by vBSEO 3.3.2