The trend is my friend? The world casino is my friend!
Plz help, indicator doesn't work with new MT4 update 5 replies
HELP: Expert Advisor doesn't work on my computer 3 replies
My EA doesn't work, please Help 0 replies
Please help: My indicator doesn't update 0 replies
How longs these trading system will work??? Please help fellow trader..... 2 replies
DislikedI have no idea what the Magic Number is all about. The EA simply didn't execute when it should of at a certain price and time last night.Ignored
DislikedI tried to have it execute a short on EURUSD at 1.3200 after 5 am mountain standard time. Nothing happened.Ignored
extern int MagicNumber = 16384; extern double TakeProfit = 50; extern double StopLoss = 50; extern double Lots = 0.1; extern int OpenTradeTime = 1100; // Open Trade time extern bool OpenBuy = true; extern bool OpenSell = false; extern int NumBuys = 1; extern int NumSells = 1; extern int Slippage = 3;
DislikedCyber1, i noticed you didn't include a value for the "mPrice" in your data table. Was there a reason for leaving mPrice out? What is the "mPrice" for?Ignored
//+------------------------------------------------------------------+ //| MACD Sample.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net/ | //+------------------------------------------------------------------+ extern int MagicNumber = 16384; extern double TakeProfit = 50; extern double StopLoss = 50; extern double Lots = 0.1; extern int OpenTradeTime = 1100; // Open Trade time extern bool OpenBuy = true; extern bool OpenSell = false; extern int NumBuys = 1; extern int NumSells = 1; extern int Slippage = 3; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int start() { int cnt, ticket, total; int ct; // initial data checks // it is important to make sure that the expert works with a normal // chart and the user did not make any mistakes setting external // variables (Lots, StopLoss, TakeProfit, // TrailingStop) in our case, we check TakeProfit // on a chart of less than 100 bars if(Bars<100) { Print("bars less than 100"); return(0); } if(TakeProfit<10) { Print("TakeProfit less than 10"); return(0); // check TakeProfit } ct = Hour() * 100 + Minute(); total=OrdersTotal(); if(total<1) { // no opened orders identified if(AccountFreeMargin()<(1000*Lots)) { Print("We have no money. Free Margin = ", AccountFreeMargin()); return(0); } // check for long position (BUY) possibility if(ct == OpenTradeTime && OpenBuy) { for ( cnt = 0; cnt < NumBuys; cnt++) { ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Bid - StopLoss * Point,Ask+TakeProfit*Point,"",MagicNumber,0,Green); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice()); } else Print("Error opening BUY order : ",GetLastError()); } return(0); } // check for short position (SELL) possibility if(ct == OpenTradeTime && OpenSell) { for ( cnt = 0; cnt < NumSells; cnt++) { ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask + StopLoss * Point,Bid-TakeProfit*Point,"",MagicNumber,0,Red); if(ticket>0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice()); } else Print("Error opening SELL order : ",GetLastError()); } return(0); } } return(0); } // the end.
DislikedNubcake, you mentioned the issue of not having enough volume to initiate a trade at the specified price but all i want is a market order when the pair crosses a certain price and has stayed on that side of the price after a certain time. My understanding was this EA would do that. E.G. i setup a short after 5am if EUR/USD crosses below 1.3200 but nothing happened. I didn't receive any error messages.Ignored
//written by nubcake extern int MagicNumber = 16384; extern double TakeProfit = 50; extern double StopLoss = 50; extern double Lots = 0.01; extern datetime OpenTradeTime = D'2012.01.01 00:00'; extern int OpenTradeTimeSlippageMinutes = 0; extern double mPrice = 1.5000; extern int NumBuys = 0; extern int NumSells = 0; extern int Slippage = 3; extern color InfoColor = White; #define objinfolabel "EACapPRInfoLabel" #define objtimerlabel "EACapPrTimerLabel" #define objpricelevel "EACapPRPrice" datetime setopentime; string infostring, triggeredmessage; bool isok, hastriggered; void addbadmsg(string s) { if (infostring != "") s = " " + s; infostring = infostring + s; isok = false; } int init() { hastriggered = false; return(0); } int deinit() { ObjectDelete(objinfolabel); ObjectDelete(objtimerlabel); ObjectDelete(objpricelevel); return(0); } int start() { int ticket; int i; double d; string s, s2; datetime dt, dthour, dtmin; isok = true; infostring = ""; if ((NumBuys == 0) && (NumBuys == 0)) addbadmsg("No buy or sell set to open!"); dt = OpenTradeTime + (60 * OpenTradeTimeSlippageMinutes); if (Time[0] < OpenTradeTime) addbadmsg("Currently before set open time."); if (Time[0] > dt) addbadmsg("Past set open time + time slippage."); if (Lots < MarketInfo(Symbol(), MODE_MINLOT)) addbadmsg("Lots too small!"); if (TakeProfit < MarketInfo(Symbol(), MODE_STOPLEVEL)) addbadmsg("TP too small!"); if (StopLoss < MarketInfo(Symbol(), MODE_STOPLEVEL)) addbadmsg("SL too small!"); d = Lots * MarketInfo(Symbol(), MODE_MARGINREQUIRED); if (AccountFreeMargin() < d) addbadmsg("Margin too low!"); if (OrdersTotal() > 0) addbadmsg("Orders currently open!"); if (hastriggered) isok = false; if (isok) { triggeredmessage = ""; hastriggered = true; if (NumBuys > 0) { if (Ask < mPrice) { triggeredmessage = "Tried to buy but Ask < mPrice! "; } else { triggeredmessage = "Buy/s attempted! "; for (i = 0; i < NumBuys; i++) { ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Bid - StopLoss * Point, Ask + TakeProfit * Point, "", MagicNumber,0,Green); if (ticket < 0) { Print("Buy error = " + GetLastError()); } else { OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES); Print("Buy opened @ " + OrderOpenPrice()); } } } } if (NumSells > 0) { if (Bid > mPrice) { triggeredmessage = triggeredmessage + "Tried to sell but Bid > mPrice"; } else { triggeredmessage = triggeredmessage + "Sell/s attempted!"; for (i = 0; i < NumSells; i++) { ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask + StopLoss * Point, Bid - TakeProfit * Point, "", MagicNumber,0,Red); if (ticket < 0) { Print("Sell error = " + GetLastError()); } else { OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES); Print("Sell opened @ " + OrderOpenPrice()); } } } } } if (hastriggered) infostring = triggeredmessage; s = objinfolabel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_LABEL, 0, 0,0); ObjectSet(s, OBJPROP_CORNER, 0); ObjectSet(s, OBJPROP_XDISTANCE, 20); ObjectSet(s, OBJPROP_YDISTANCE, 20); } ObjectSetText(s, infostring, 10, "Courier New", InfoColor); s = objtimerlabel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_LABEL, 0, 0,0); ObjectSet(s, OBJPROP_CORNER, 0); ObjectSet(s, OBJPROP_XDISTANCE, 20); ObjectSet(s, OBJPROP_YDISTANCE, 40); } if ((Time[0] >= OpenTradeTime) && (Time[0] <= dt)) { s2 = "NOW!"; } else { if (Time[0] < OpenTradeTime) dt = OpenTradeTime - Time[0]; else dt = dt - Time[0]; dthour = 0; dtmin = 0; while (dt > (59 * 60)) { dthour++; dt -= 60 * 60; } while (dt < (-59 * 60)) { dthour--; dt += 60 * 60; } dtmin = dt / 60; s2 = dthour + " hours " + dtmin + " mins"; } ObjectSetText(s, "Time Until Open: " + s2, 10, "Courier New", InfoColor); s = objpricelevel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_HLINE, 0, 0,0); ObjectSet(s, OBJPROP_WIDTH, 1); ObjectSet(s, OBJPROP_COLOR, InfoColor); ObjectSet(s, OBJPROP_STYLE, STYLE_DOT); ObjectSetText(s, "EA Price Level"); } ObjectSet(s, OBJPROP_PRICE1, mPrice); return(0); }
//written by nubcake extern int MagicNumber = 16384; extern double TakeProfit = 50; extern double StopLoss = 50; extern double Lots = 0.01; extern datetime OpenTradeTime = D'2012.01.01 00:00'; extern int OpenTradeTimeSlippageMinutes = 0; extern double mPrice = 1.5000; extern int NumBuys = 0; extern int NumSells = 0; extern int Slippage = 3; extern color InfoColor = White; #define objinfolabel "EACapPRInfoLabel" #define objtimerlabel "EACapPrTimerLabel" #define objpricelevel "EACapPRPrice" string infostring, triggeredmessage; bool isok, hastriggered; void addbadmsg(string s) { if (infostring != "") s = " " + s; infostring = infostring + s; isok = false; } int init() { hastriggered = false; return(0); } int deinit() { ObjectDelete(objinfolabel); ObjectDelete(objtimerlabel); ObjectDelete(objpricelevel); return(0); } int start() { int ticket; int i; double d; string s, s2; datetime dt, dthour, dtmin; isok = true; infostring = ""; if ((NumBuys == 0) && (NumSells == 0)) addbadmsg("No buy or sell set to open!"); dt = OpenTradeTime + (60 * OpenTradeTimeSlippageMinutes); if (Time[0] < OpenTradeTime) addbadmsg("Currently before set open time."); if (Time[0] > dt) addbadmsg("Past set open time + time slippage."); if (Lots < MarketInfo(Symbol(), MODE_MINLOT)) addbadmsg("Lots too small!"); if (TakeProfit < MarketInfo(Symbol(), MODE_STOPLEVEL)) addbadmsg("TP too small!"); if (StopLoss < MarketInfo(Symbol(), MODE_STOPLEVEL)) addbadmsg("SL too small!"); d = Lots * MarketInfo(Symbol(), MODE_MARGINREQUIRED); if (AccountFreeMargin() < d) addbadmsg("Margin too low!"); if (OrdersTotal() > 0) addbadmsg("Orders currently open!"); if (hastriggered) isok = false; if (isok) { triggeredmessage = ""; hastriggered = true; if (NumBuys > 0) { if (Bid < mPrice) { triggeredmessage = "Tried to buy but Bid < mPrice! "; } else { triggeredmessage = "Buy/s attempted! "; for (i = 0; i < NumBuys; i++) { ticket = OrderSend(Symbol(), OP_BUY, Lots, Ask, Slippage, Bid - StopLoss * Point, Ask + TakeProfit * Point, "", MagicNumber,0,Green); if (ticket < 0) { Print("Buy error = " + GetLastError()); } else { OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES); Print("Buy " + ticket + " opened @ " + OrderOpenPrice()); } } } } if (NumSells > 0) { if (Ask > mPrice) { triggeredmessage = triggeredmessage + "Tried to sell but Ask > mPrice"; } else { triggeredmessage = triggeredmessage + "Sell/s attempted!"; for (i = 0; i < NumSells; i++) { ticket = OrderSend(Symbol(), OP_SELL, Lots, Bid, Slippage, Ask + StopLoss * Point, Bid - TakeProfit * Point, "", MagicNumber,0,Red); if (ticket < 0) { Print("Sell error = " + GetLastError()); } else { OrderSelect(ticket, SELECT_BY_TICKET, MODE_TRADES); Print("Sell " + ticket + " opened @ " + OrderOpenPrice()); } } } } } if (hastriggered) infostring = triggeredmessage; s = objinfolabel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_LABEL, 0, 0,0); ObjectSet(s, OBJPROP_CORNER, 0); ObjectSet(s, OBJPROP_XDISTANCE, 20); ObjectSet(s, OBJPROP_YDISTANCE, 20); } ObjectSetText(s, infostring, 10, "Courier New", InfoColor); s = objtimerlabel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_LABEL, 0, 0,0); ObjectSet(s, OBJPROP_CORNER, 0); ObjectSet(s, OBJPROP_XDISTANCE, 20); ObjectSet(s, OBJPROP_YDISTANCE, 40); } if ((Time[0] >= OpenTradeTime) && (Time[0] <= dt)) { s2 = "NOW!"; } else { if (Time[0] < OpenTradeTime) dt = OpenTradeTime - Time[0]; else dt = dt - Time[0]; dthour = 0; dtmin = 0; while (dt > (59 * 60)) { dthour++; dt -= 60 * 60; } while (dt < (-59 * 60)) { dthour--; dt += 60 * 60; } dtmin = dt / 60; s2 = dthour + " hours " + dtmin + " mins"; } ObjectSetText(s, "Time Until Open: " + s2, 10, "Courier New", InfoColor); s = objpricelevel; if (ObjectFind(s) < 0) { ObjectCreate(s, OBJ_HLINE, 0, 0,0); ObjectSet(s, OBJPROP_WIDTH, 1); ObjectSet(s, OBJPROP_COLOR, InfoColor); ObjectSet(s, OBJPROP_STYLE, STYLE_DOT); ObjectSetText(s, "EA Price Level"); } ObjectSet(s, OBJPROP_PRICE1, mPrice); return(0); }