| 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 |
|
|||
|
Need a little help refining this EA
I have this ea which is a modified version of the "GAPS EA" found elsewhere on this forum.
Anyway, attached is a copy of the code. Code:
#property link ""
//---- input parameters
extern int min_gapsize = 1;
extern double lotsize_gap = 5;
extern int MagicNumber = 10;
//----
datetime order_time = 0;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
/*
Thing to be done in future in this program to make it more efficient
and more powerful:
1. Make the dicission of the quantity of lots used according to
the scillators;
2. This program will catch the gaps.
Things to ware of:
1. the spread;
2. excuting the order not on the gap ends a little bit less.
*/
// Defining the variables to decide.
Print("order time", order_time);
double current_openprice = iOpen(Symbol(), 0, 0);
double previous_highprice = iHigh(Symbol(), 0, 1);
double previous_lowprice = iLow(Symbol(), 0, 1);
double point_gap = MarketInfo(Symbol(), MODE_POINT);
int spread_gap = MarketInfo(Symbol(), MODE_SPREAD)+1;
datetime current_time = iTime(Symbol(), 0, 0);
// catching the gap on sell upper gap
if(current_openprice > previous_highprice + (min_gapsize + spread_gap)*point_gap &&
current_time != order_time)
{
int ticket = OrderSend(Symbol(), OP_SELL, lotsize_gap, Bid, 0, 0,
previous_highprice + spread_gap,
"Gapped Up Sell " + Symbol()+ " " +Period()+ "", MagicNumber, 0, Red);
order_time = iTime(Symbol(), 0, 0);
Print("I am inside (sell) :-)", order_time);
//----
if(ticket < 0)
{
Print("OrderSend failed with error #", GetLastError());
}
}
//catching the gap on buy down gap
if(current_openprice < previous_lowprice - (min_gapsize + spread_gap)*point_gap &&
current_time != order_time)
{
ticket = OrderSend(Symbol(), OP_BUY, lotsize_gap, Ask, 0, 0,
previous_lowprice - spread_gap,
"Gapped Down Buy " + Symbol()+ " " +Period()+ "", MagicNumber, 0, Green);
order_time = iTime(Symbol(), 0, 0);
Print("I am inside (buy) :-)", order_time);
if(ticket < 0)
{
Print("OrderSend failed with error #", GetLastError());
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Whenever I put this into the strategy tester, it doesn't open trades. A quick peek at the journal tells me that there were plenty of order times made. What did I do wrong? |
|
|||
|
Help: Basic Histogram Question
This is probably really easy and I'm looking past something, but I'm out of resources and can't find an answer.
All I'm trying to do is recall the value of the previously drawn histogram bar. Any ideas? I.e. Close[1] shows the last closed bar on the chart..... So what would show the last drawn histogram bar on this separate window indicator? Thanks for any advice in advance. -dharsant |
|
||||
|
Coding Help Needed Please
I am trying to use a couple of different indicators in an ea but can't seem to work out how to implement them in to the system. What part of the indicator do I use to say buy or sell. How do I get Slope Direction Line into part of an EA.
Cheers Beno |
|
||||
|
I have probably not explained myself quite right.
I am trying to find out what I need to put into iCustom this is what I have done below. double SDL=iCustom(NULL,0,"Slope Direction Line",period,method,price) And what I need to do to generate buy and sell signal from Slope Direction Line Indicator for my EA. Below is what I have done so far, it compiles but no positions are being generated. bool Long = TML && SDL && HeikenAshiOpen < HeikenAshiClose && hasOpen < hasClose; bool Short = TMS && SDL && HeikenAshiOpen > HeikenAshiClose && hasOpen > hasClose; Any help would be great Cheers Beno |
|
||||
|
Firstly the iCustom call needs two additional arguments at the end, namely which of the indicator buffers to read from, and which index to read at.
Secondly, "SDL" is a double number, so to just put "SDL" as a condition shows some confusion; possibly it compiles as "SDL != 0", and possibly that's what is meant. |
|
||||
|
Gidday ralph.ronnquist
so should i create another sdl line something like SDLL = long SDLS = short ? I think i'm right in saying that on the SDL indi uptrend = buffer 1 & Index 1 colour Blue dntrend = buffer 2 & Index 2 Colour Red If so where would I put them. do I put them at the end of the iCustom line. double SDL=iCustom(NULL,0,"Slope Direction Line",period,method,price,1,1,shift); or am I way off track |
|
||||
|
The statement:
PHP Code:
(Note that you had a repeated ",1", which looked like a typo. In any case it should't be there) So, yes, if you want to read off both Uptrend and Dntrend, then you'll need two variables to hold the values. As you say, Uptrend is 1 and Dntrend is 2. |
|
|||
|
It sent me in the right direction- thanks man, really appreciated.
My new issue is that when my if statement is called.... It goes off the previous indicator bar's value in relation to the current bar, and sends an Alert(); that I created... about 20 times. How would I go about having it only send the once? I tried created and on/off switch using variables-- doesn't work in MQL4 unfortunately. Then I thought about Timers... if there was a timer I could create that only Alerted once over a 20 sec period that would work too.... But I'm a loss as to an idea that would actually be possible in MQL4. Any ideas? |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to code this? | iscuba11 | Metatrader 4 mql 4 - Development course | 1 | 08-03-2007 04:22 PM |