Thanks Charles, I have the EA now
Charles Wilkes <cfw123 (AT) gmail (DOT) com> wrote: I had it set on 30 minutes. Sometimes this affects EAs I have seen, and sometimes they do their own thing and ignore the time frame you have chosen to look at the pair with. I don't kow which way this one is.
Another member has written that this EA was in fact written by one of our members, which makes me feel better about posting it here.
Charles Wilkes, San Jose, Calif.
On Mon, Mar 3, 2008 at 9:58 AM, Shivanand <shivanund (AT) yahoo (DOT) com> wrote:
Thanks Charles, what time frame did you set the EA on?
Charles Wilkes <cfw123 (AT) gmail (DOT) com> wrote:
I know that the S%T EA was not from one of our members I think, but I also know that everyone is interested in EAs which earn good profits. So take a look at
http://www.forex-tsd.com/expert-advi...r-gbp-usd.html
Yesterday I wasn't getting any transactions from S&T when I ran the earlier version with 12 currency pairs. So I decided to do something different. First of all, I was able to get the ver 3.31 to finally work -- they really had put up a new version of it, and I will attach it to this note. I had identified it from the previous two versions I had which didn't work as "b" so it now carries a ver. of 3.31b but it was me who added the b suffix.
Another thing I did was to get rid of all currency pairs except one. I notice that the name says GBPUSD, but for some reason I used GBPJPY instead, since I know that one to be more volatile than the other one. But I don't know if that helped or not.
Last night when I went to bed, I had a profit of $583.72 from one single transaction. Then this morning it had added a new transaction overnot with a profit of W$223.15, for a total profit so far of $806.42 -- not bad from my point of view. At this moment there are no transactions pending. Since I have no documentation on the INPUT screen parameters, I ran it with the defaults only.
I don't know why -- just what. But it makes me really anxious to find out why as well. Maybe someone here can figure it out.
Charles Wilkes, San Jose, Calif.
//+-----------------------------------------------------------------------------+
//| Straddle&Trail GBPUSD.mq4 |
//| Copyright © 2006, Yannis |
//| CREATED BY: jsfero (AT) otenet (DOT) gr |
//+-----------------------------------------------------------------------------+
//+ v3.30 OPTIMIZED FOR GBP/USD by zmahal08 (AT) gmail (DOT) com +
//+-----------------------------------------------------------------------------+
/////////////////////////////////////////////////////////////////////////////////
//////////////////////////// READ ME CAREFULLY //////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// TRY IT FIRST ON A DEMO ACCOUNT UNTIL YOU FULLY UNDERSTAND HOW IT WORKS AND //
// VERIFY YOURSELF THAT IT WORKS CORRECTLY BEFORE PUTTING REAL MONEY IN IT. //
// THE AUTHOR (that's me :-)) CANNOT BE HELD RESPONSIBLE FOR ANY DAMAGE OR LOSS /
// *** USE IT AT YOUR OWN RISK *** //
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// The ea can manage at the same time manually entered trades at any time (they have a magic number of 0)
// AND/OR a straddle (Long and Short pending positions - Stop orders) that is placed for a news event
// at a specific time of the day by the ea. If you want to use only it as a Trailing expert for your manual
// entries i would suggest to set the "Enable.News.Trading" parameter to False (it is by default).
//
// The manual trades are checked against Symbol() and MagicNumber=0 so if you have other experts running
// on the same pair assuming they assign a magic number > 0 to the trades, you won't have any problems between
// the manual trades and those from your expert.
//
// The trades entered by the expert are checked against Symbol() Period() and an automatically given Magic Number
// so here also absolutely no problem if you have other experts running.
//
// The positions are tracked through the PosCounter() procedure
// which checks for : b.ticket / s.ticket ==> Ticket # from Orders actually triggered BY THE EA, if any, otherwise = 0.
// b.ticketP / s.ticketP ==> Ticket # from Pending Stop Orders NOT TRIGGERED (the straddle).
// b.ticketM / s.ticketM ==> Ticket # from Orders entered Manually.
// The manually entered positions are tracked as far as SL, TP, BE, partial exits and Trail are concerned,
// and are totally unaffected by the straddle.
//
/////////////////////////////////////////////////////////////////////////////////
////////////////// BASIS SETTINGS AND HOW TO USE IT ////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
// IF YOU WANT TO USE THE EXPERT FOR NEWS EVENTS, MAKE USRE TO SET "Enable.News.Trading" TO TRUE
// AND "Place.Straddle.Immediately" TO FALSE. IN THAT CASE, ONCE A POSITION IS TRIGGERED, THE EA
// WILL NOT PLACE ANOTHER STRADDLE AGAIN UNTIL YOU INITIALIZE IT (BY CHANGING TIME FRAME OR
// DISABLING AND ENABLING THE EA AGAIN.
//
// IF YOU WANT TO USE THE EXPERT FOR STRADDLING A NARROW RANGE BREAKOUT, UNRELATED TO NEWS,
// MAKE SURE TO SET "Enable.News.Trading" TO FALSE AND "Place.Straddle.Immediately" TO TRUE.
// IN THAT CASE, ONCE A POSITION IS TRIGGERED AND CLOSED AT ANY POINT, THE EA WILL PUT A
// NEW STRADDLE AGAIN.
//
// IF YOU WANT THE EXPERT TO SIMPLY TAKE CARE OF YOUR MANUAL POSITION AND TOTALLY DISABLE ANY OTHER STRADDLE
// FEATURES, MAKE SURE TO SET "Enable.News.Trading" TO FALSE AND "Place.Straddle.Immediately" TO FALSE.
/////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
//
//
// The Stop Orders entered before the news release, either immediately if "Pre.Event.Entry.Minutes"=0 or
// xx minutes before the event and they are tracked and adjusted ONCE EVERY MINUTE, from the moment
// they are entered by the ea until a few minutes before the event (specified by "Stop.Adjusting.Min.Before.Event" parameter)
// modifying their entry price, stop loss and take profit, according to current Bid and Ask, if "Adjust.Pending.Orders"=True.
// Once one of them is triggered, the opposite one is removed if "Remove.Opposite.Order" = True.
//
// Another way of entering a straddle is by setting the "Place.Straddle.Immediately" to True. In that case,
// The time event settings will be ignored and the long and short pending orders that will be entered immediately
// will not be adjusted according to price like they are when this parameter is set to false and we use the ea for
// news release. This is to be used as a narrow range, low volume breakout strategy like for instance during a ranging
// Asian period.
//
// The "ShutDown.NOW" parameter will shut down all the trades specified by "ShutDown.What" parameter.
// On the ea's input tab you can see the possible values but here they are again as a reference.
// ShutDown.What ==> 0=Everything, 1=All Triggered Positions, 2=Triggered Long
// 3=Triggered Short, 4=All Pending Positions, 5=Pending Long, 6=Pending Short
// If "ShutDown.Current.Pair.Only" then the ea will close all trades for the pair on which this parameter was set to true
// otherwise it will close ALL the trades on ALL the pairs.
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Note 2 //////////////////////////////////////////
// The ea will check the minimum distance allowed from the broker
// against the trail, stop loss and take profit values specified by the user
// in the expert parameters tab. If these values are below the allowed distance
// they will be automatically adjusted to that minimum value
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Note 3 //////////////////////////////////////////
// Scaling Out.
// Assuming we have a position triggered with 3 lots, either manually or through the Straddle.
// If we set the "Take.Out.Lots" parameter to 1, then each time the position will be in
// profit by the number of pips specified by "Trail.Pips" parameter, the expert will close
// 1 lot. Another "Trail.Pips" profit later, it will close another lot etc...
// The Trail.Pips parameter is used in this case as steps for each lot to be taken out
// So if we use 3 lots and "Trail.Pips" is set to 15, then if all goes well, we will have
// 1 lot closed at +15, the second at +30 and the 3rd at +45. All this can be combined
// with the other trailing parameters below.
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Note 4 //////////////////////////////////////////
// How to use the ea so it takes over manually entered trades.
// As soon as a position is manually initiated, the expert will check a few things.
// 1. if your position has no SL or TP, it will modify the position and use the StopLoss.Pips
// and the TakeProfit.Pips to place SL and TP.
// 2. Assuming you want to trail a position at 15 pips distance, all you have to do is
// set the "Trail.Pips" parameter to 15 or to any other value you see fit.
// 3. You will find also 3 other parameters which are related to how the trail will behave
// a) "Trail.Starts.After.BreakEven" If set to true, then your trailing will only start
// after breakeven is accomplished. This parameter is independent from next 2.
// b) "Move.To.BreakEven.at.pips" You specify here the amount of pips which once your
// trade is xx pips in profit the ea will move your SL to breakeven. This means
// that if you set it to 10, the ea will move to B/E once you are at +10.
// c) "Move.To.BreakEven.Lock.pips" Amount of pips to secure once B/E is reached.
// If you set it to 1, then with the previous parameter set to 10, this means
// the expert will move your SL at +1 once your trade is at +10
//
// So let's see some scenarios:
// Assuming we want to simply trail a position by 20 pips we can set:
// Trail.Pips=20
// Trail.Starts.After.BreakEven=False
// Move.To.BreakEven.Lock.pips= ANYTHING it isn't needed
// Move.To.BreakEven.at.pips = ANYTHING it isn't needed
//
// Assuming we want to trail a position by 15 pips and just securing 1 pip
// once 10 pips of profit are made:
// Trail.Pips=15
// Trail.Starts.After.BreakEven=False
// Move.To.BreakEven.Lock.pips=1
// Move.To.BreakEven.at.pips =10
//
// Assuming we want to trail a position by 15 pips but only after
// price moves 20 pips in our favor. We also want to at that point
// to secure 5 pips:
// Trail.Pips=15
// Trail.Starts.After.BreakEven=True
// Move.To.BreakEven.Lock.pips=5
// Move.To.BreakEven.at.pips =20
//
// I guess you've go the idea
/////////////////////////////////////////////////////////////////////////////////////
#include
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// EA PARAMETERS / USER INPUTS /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
extern bool ShutDown.NOW=False; // If true ALL POSITIONS (open and/or pending) will be closed/deleted
// based on "ShutDown.What" flag below
// This parameter is the first on the list so the user can access it
// as quickly as possible.
extern string sStr00=" 0=Everything ";
extern string sStr01=" 1=All Triggered Positions ";
extern string sStr02=" 2=Triggered Long ";
extern string sStr03=" 3=Triggered Short ";
extern string sStr04=" 4=All Pending Positions ";
extern string sStr05=" 5=Pending Long ";
extern string sStr06=" 6=Pending Short ";
extern int ShutDown.What=0;
extern bool ShutDown.Current.Pair.Only=True; // If true, ALL trades for CURRENT pair will be shutdown (no matter what time frame).
// If False, ALL trades on ALL pairs will be shutdown.
extern string sStr1="=== POSITION DETAILS ===";
extern double Lots = 1;
extern double Take.Out.Lots = 0; // When Target is reached, ea will close this amount of lots
// extending next target by 'Trail.Pips'
extern int Slippage=3;
extern int StopLoss.Pips=30; // Initial stop loss.
extern int TakeProfit.Pips=60; // Initial take profit.
extern int Trail.Pips=15; // Trail.
extern bool Trail.Starts.After.BreakEven=false; // if true trailing will start after a profit of "Move.To.BreakEven.at.pips" is made
extern int Move.To.BreakEven.Lock.pips=5; // Pips amount to lock once trade is in profit
// by the number of pips specified with "Move.To.BreakEven.at.pips"
// Unused if Trail.Starts.After.BreakEven=False
extern int Move.To.BreakEven.at.pips=15; // trades in profit will move to entry price + Move.To.BreakEven.Lock.pips as soon as trade
// is at entry price + Move.To.BreakEven.at.pips
// i.e. Entry price on a long order is @ 1.2100
// when price reaches 1.2110 (Entry price + "Move.To.BreakEven.at.pips")
// the ea will lock 1 pip moving sl
// at 1.2101 (Entry price+ "Move.To.BreakEven.Lock.pips=1")
extern string sStr2="=== NEWS EVENT ===";
extern bool Enable.News.Trading=true; // If set to False, the ea works only as a 'trailer' on manual trades.
extern int Distance.From.Price=35; // Initial distance from price for the 2 pending orders.
extern int Event.Start.Hour=7; // Event start time = Hour. Broker's time.
extern int Event.Start.Minutes=1; // Event start time = Minutes. Broker's time.
// IF YOU WANT TO DISABLE THE "NEWS" FEATURE (the straddle)
// SET BOTH PARAMETERS TO 0.
extern int Pre.Event.Entry.Minutes=1; // Number of minutes before event where the ea will place the straddle.
// If set to 0, the ea will place the straddle immediately when activated,
// otherwise xx minutes specified here before above Event start time.
extern int Stop.Adjusting.Min.Before.Event=2; // Minutes before the event where the EA will stop adjusting
// the pending orders. The smallest value is 1 min.
extern bool Remove.Opposite.Order=false; // if true, once the 1st of the 2 pending orders is triggered,
// the opposite pending one is removed otherwise left as is.
extern bool Adjust.Pending.Orders=false; // if true, once the pending orders are placed at
// "Pre.Event.Start.Minutes" minutes before the event's time,
// the ea will try to adjust the orders ONCE EVERY MINUTE until
// "Stop.Adjusting.Min.Before.Event" minutes before the release where
// it will stay put.
extern bool Place.Straddle.Immediately=False; // if true, the straddle will be placed immediately once the
// expert is activated. This overrides previous 'News Events'
// settings for placing the long and short pending orders and
// in that case, the positions WILL NOT BE ADJUSTED.
// The "Enable.News.Trading" parameter is also bypassed.
// This is to be used as a "quiet" range breakout, for example if we
// want to play a "regular" breakout during Asian Session for example
// or at any other time of the day where the market is rangebound
extern bool MoneyManagement=false;
extern int Risk =5;
extern string EOD ="0000";
/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////// EA PARAMETERS / USER INPUTS /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////
int EODHour;
int EODMinute;
bool CloseAllComplete=false;
int iMinimum,Last.Ticket,b.ticket,s.ticket,b.ticketP,s .ticketP,b.ticketM,s.ticketM,Magic,OpenTrades,Actu alPipsProfit,ActualPipsProfitM,tr;
int Retry,HourNow,MinutesNow,LastMin,MyErr,OpenPositio ns,OpenLongM,OpenShortM,OpenLong,OpenShort,OpenLon gP,OpenShortP;
string comment=" Straddle&Trail GBPUSD",ScreenComment="Straddle&Trail v3.30 GBPUSD",NewsLabel="",sHour,sMin;
bool SupplyMagicNumber=True,IsOK=False,TradeInitiated;
double LongEntryLevel,ShortEntryLevel,SL,TP,NextTargetM, NextTarget;
int init()
{ comments();
if ((Event.Start.Hour>=0) && (Event.Start.Hour<=9)) sHour="0";
else sHour="";
if ((Event.Start.Minutes>=0) && (Event.Start.Minutes<=9)) sMin="0";
else sMin="";
if (!Enable.News.Trading) NewsLabel=ServerTime()+" No News Event Scheduled";
else NewsLabel=(ServerTime()+" NEWS SCHEDULED FOR ("+sHour+Event.Start.Hour+":"+sMin+Event.Start.Min utes+")");
ObjectDelete("Yannis");
YannisCustomText( "Yannis", 15, 15,1);
ObjectSetText( "Yannis", "zmahal08 (AT) gmail (DOT) com" , 10, "Times New Roman", Yellow );
ObjectDelete("Yannis2");
YannisCustomText( "Yannis2", 15, 15,3);
ObjectSetText( "Yannis2", NewsLabel , 10, "Tahoma", Yellow );
TradeInitiated=False;
return(0);
}
int deinit()
{ ObjectDelete("Yannis");
ObjectDelete("Yannis2");
return(0);
}
int start()
{
//----------- Money Management feature, added by Azmel
if (MoneyManagement)
{
if (Risk<1 || Risk>100)
{
Comment("Invalid Risk Value.");
return(0);
}
else
{
Lots=MathFloor((AccountFreeMargin()*AccountLeverag e()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo( Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_M INLOT);
}
}
//----------- end of Money Management subroutine.
//----------- Close Trade on EOD time.
if (StringLen(EOD)==4)
{
EODHour=StrToInteger(StringSubstr(EOD,0,2));
EODMinute=StrToInteger(StringSubstr(EOD,2,2));
if (EODHour<0 || EODHour>23 || EODMinute<0 || EODMinute>59)
{
Comment("EOD Time Error.");
return(0);
}
else
{
if (Hour()==EODHour && Minute()>=EODMinute)
{
if (CloseAllComplete==false)
{
if (TotalOrders()==0)
{
CloseAllComplete=true;
}
else
{
CloseAllOrders();
return(0);
}
}
}
else
{
CloseAllComplete=false;
}
}
}
//----------- end of Close Trade on EOD time subroutine.
iMinimum=MarketInfo(Symbol(),MODE_STOPLEVEL); // check the minimum pip distance allowed from broker for sl and tp
int EventAboutToStart=IsItEventTime();
if ((Event.Start.Hour>=0) && (Event.Start.Hour<=9)) sHour="0";
else sHour="";
if ((Event.Start.Minutes>=0) && (Event.Start.Minutes<=9)) sMin="0";
else sMin="";
if (!Enable.News.Trading) NewsLabel=ServerTime()+" No News Event Scheduled";
else NewsLabel=(ServerTime()+" NEWS SCHEDULED FOR ("+sHour+Event.Start.Hour+":"+sMin+Event.Start.Min utes+")");
Magic=CalcMagic (Symbol(),Period());
if (StopLoss.Pips if (TakeProfit.Pips if (Trail.Pips
PosCounter(); // check for open positions. Sets b.ticket, s.ticket, b.ticketP, s.ticketP, b.ticketM, s.ticketM
// b.ticketM / s.ticketM = Ticket Number for Manual Trades
// (b.ticketM=Long position s.ticketM=Short position, if any, otherwise = 0)
// b.ticketP / s.ticketP = Ticket Number for Pending Trades (Straddle) from EA
// b.ticket / s.ticket = Ticket Number for Triggered Trades (Straddle) from EA
if ((ShutDown.NOW) && (OpenTrades>0)) ShutDownAllTrades(ShutDown.What);
PosCounter();
CheckInitialSLTP(); // If a position is entered without initial SL / TP then place the initial stops
// If no open or pending positions, AND the event start hour and minute is not 0, place the 2 pending orders
// If Pre.Event.Entry.Minutes=0 (immediately) or
// else Pre event minutes before event time
if ( ((IsTimeToPlaceEntries()) && (Enable.News.Trading) && (!TradeInitiated)) || (Place.Straddle.Immediately))
=== message truncated ===
Warm Regards
Shiva
http://www.nyfx.org http://www.dubaitradeguide.com http://www.tradeguide.cn
--