| New signals service! | |
|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Quote:
int start() if (OrdersTotal() > 0) return(0); //-----Your EA begin here--------- This is the simplest way to prevent your EA for opening more than one order at same time. You can find other advanced logics at this forum. |
|
|||
|
Alerts
I thought I could limit the number of alerts triggered by trigger using this:
extern int MaxWaiting_sec = 30; if(trigger == 1) { int StartWaitingTime = GetTickCount(); if(GetTickCount() - StartWaitingTime > MaxWaiting_sec * 1000) { if(ShowAlert == true) { Alert("Buy........... But it does not seem to work, what am I doing wrong?? ![]() |
|
|||
|
BE stop
|
|
|||
|
EA question
Hello there,
Question: I have started coding my EA. I am by no means a decent coder for MQL b/c I've never seen C++/C. Fine. My settings are as follows: There are two indicators: IND1 [indicator] and IND2. IND1 has 1 line, IND2 has 2 lines. Lines = lines on a chart. For instance, Bollinger bands indicator has 3 lines, but isn't used in this example. Both INDs have their 0.0 level shown on the chart. My logic is as follows: when IND1 crosses its 0 level the first time and goes into negative, send the SELL order. Wait for the IND2 to have its line1 cross line2 and send the BUY order, automatically closing the SELL submitted by IND1. If there's a 2nd/3rd/etc 0 level crossing by IND1 into either positive or negative before the BUY, disregard that crossing, do nothing and proceed w/ that first SELL order[otherwise there will be a 2nd/3rd/etc SELL order w/ no corresponding BUY order]. When the BUY order is executed by the IND2 [IND2's line1 has crossed line2], wait for the following crossing of 0 [into the negative] by IND1 and send the SELL order, automatically closing the BUY order submitted by IND2. I'm going to include my coding. Please take a look at it, b/c it isn't graphing anything and isn't working. Here's the code itself: Code:
#property copyright "Copyright © 2008 BDHT"
#define MAGIC 689
//do not take into consideration
//the names of the indicators
//they're fabricated
extern double lots = 0.1; // Lots
extern double TP = 140; // Take Profit
extern double SL = 30; // Stop Loss
static int prevtime = 0;
static int res = 0;
double IND2_line1, IND2_line2, IND1, IND1_prev, IND2_line1_prev;
int init() {
IND2_line1 = iIND2_line1(NULL,0,0,MODE_MAIN,0);
IND2_line2 = iIND2_line2(NULL,0,0,MODE_SIGNAL,0);
IND1= iCustom(NULL, 0, "IND1", 0, 0, 0);
IND1_prev= iCustom(NULL,0, "IND1", 0, 0, 1);
IND2_line1_prev = iCustom(NULL, 0, "IND2", 0, 0, 1);
return(0);
}
int deinit() {
return(0);
}
int start() {
//Make sure there are no open orders; if yes - stop
if (OrdersTotal() > 0)
return (0);
if (IND1< 0 && IND1 < IND1_prev && IND1_prev > 70 && IND2_line1 < 0 && IND2_line2 < 0) {
// 70 may be 10; simply means that the IND1_prev was greater than 0
res=OrderSend(Symbol(),OP_SELL,lots,Bid,3,Bid+SL*Point,Ask+TP*Point,"My EA",MAGIC,0,Blue);
return(0);
}
if (IND2_line1 > IND2_line2 && IND2_line1_prev < IND2_line1) {
res=OrderSend(Symbol(),OP_BUY,lots,Ask,3,Ask+SL*Point,Bid+TP*Point,"My EA",MAGIC,0,Blue);
return(0);
}
UPDATE: Okay, I got a little help from phy in MQL forums: he says that "code within start() executes every tick" and "code within init() is only executed one time or once per intitialization/start/restart of the EA". Am I getting this correctly: a tick is any change of price. A bar has many ticks. A M1 bar may have 60 seconds [or so] worth of ticks and a M5 bar may have 60 seconds * 5 instances/minutes worth of ticks. I do not want the code to pay attention to each and every tick there is; I just want the bar to make the difference. Last edited by bdht; 01-22-2008 at 04:11 AM. |
|
|||
|
Continuous alerting
I was wondering what code and where to add it, if I want any indicator to sound, email, alert until I shut it off. I'm away from my computer at times and use text messages and sound to alert me whether awake or asleep. One sound or text message is not always enough to get my attention.
Thank you ahead of time |
|
||||
|
Quote:
There is another good thread here and here
__________________
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MT4 (Basic) Questions | stepwise | Metatrader 4 | 6 | 09-22-2008 02:22 AM |
| Basic Indicator Question | waaustin | Metatrader Programming | 8 | 04-02-2008 02:54 PM |
| Need Help Understanding Basic MQL logic | Emerald King | Expert Advisors - Metatrader 4 | 7 | 02-27-2007 09:59 AM |
| Very basic coding help needed | camisa | Questions | 1 | 05-08-2006 05:36 PM |