Forex
Google
New signals service!

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course > Questions


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

Reply
 
LinkBack (2) Thread Tools Display Modes
  #71 (permalink)  
Old 02-16-2006, 03:31 PM
Fxfix's Avatar
Junior Member
 
Join Date: Sep 2005
Posts: 26
Fxfix is on a distinguished road
Quote:
Originally Posted by codersguru
Hi folks,

I've got a lot of private messages asking me for helping with some pieces of code.

Here you can post your questions related to MQL4, and I'll do my best to answer them.


Hi Coder.
Is it possible to have an alert sound only once per 5 Minute bar?

Is it possible for an alert to sound only once when the condition is met?
Then switch off.
Then on the opening of the next bar to refresh the indicator ready to sound again.
Then switch off once again until the condition of 0.0005 is met again.
Then switch on again and so on......

The indicator below can sound many alerts per bar when Triggered.

See Below.

//+------------------------------------------------------------------+
//| Juice.mq4 |
//| Perky_z |
//| http://fxovereasy.atspace.com/index |
//+------------------------------------------------------------------+
#property copyright "perky"
#property link "http://fxovereasy.atspace.com/index"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 FireBrick
//---- indicator parameters
extern bool DoAlerts = false;
extern int AlertFromPips = 5;
extern int Periyod=7;
extern double Level=5;
extern bool JuiceLevelsVisible = true;
extern int JuiceStartPips = 5;
extern int JuiceStepPips = 5;
extern int JuiceLevelsNumber = 4;
extern color JuiceLevelColor = Silver;

//---- indicator buffers
double OsMAUpBuffer[];
double OsMADownBuffer[];
double OsMAValue;
double currentJuiceLevel;


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(2);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1);
SetIndexDrawBegin(0,Level);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+2 );
//---- 2 indicator buffers mapping
if(!SetIndexBuffer(0,OsMAUpBuffer) &&
!SetIndexBuffer(1,OsMADownBuffer))
Print("cannot set indicator buffers!");
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("Juice("+Periyod+","+Level+")") ;

//---- initialization done
return(0);
}

int SetLevelLines()
{
string levelLabel;
if(JuiceLevelsVisible)
{
SetLevelStyle(STYLE_DASH,1,JuiceLevelColor);
for(int i=1; i<= JuiceLevelsNumber; i++)
{

currentJuiceLevel = (JuiceStartPips + (i-1)*JuiceStepPips)*Point;
SetLevelValue(i,currentJuiceLevel);
levelLabel = "Level "+i+": "+currentJuiceLevel;
SetIndexLabel(i,levelLabel);
}
}else
{
for(i=1; i<= JuiceLevelsNumber; i++)
{

SetLevelValue(i,0.0);

}
}
}

//+------------------------------------------------------------------+
//| Moving Average of Oscillator |
//+------------------------------------------------------------------+
int start()
{
//if ( Period != 15) Alert ("Juice Is Recommended for 15 Min Chart only!!");
int limit,i;
int counted_bars=IndicatorCounted();
double Juice;
bool TurnOnAlert = true;

//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
Level = Level*Point;

if (Period()==5 ) Level=Level/2;

SetLevelLines();

//---- main loop
for(i=0; i<limit; i++)
{
Juice=iStdDev (NULL,0,Periyod,MODE_EMA,0,PRICE_CLOSE,i)-Level;
if(Juice>0){
OsMAUpBuffer[i]=Juice;
OsMADownBuffer[i]=0;
}else if(Juice<0){
OsMADownBuffer[i]=Juice;
OsMAUpBuffer[i]=0;
}else{
OsMAUpBuffer[i]=0;
OsMADownBuffer[i]=0;
}
}

if (DoAlerts)
{
if (Juice > AlertFromPips*Point && Period() == 5)
{
if (TurnOnAlert)
{
Alert("Juice above ",AlertFromPips*Point," for ", Symbol());
PlaySound("Tick.wav");
TurnOnAlert = false;
}
}
else
{
TurnOnAlert = true;
}
}

//---- done
return(0);
}
//+------------------------------------------------------------------+


Your help would be greatly appreciated.
Many Thanks.
Leigh.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #72 (permalink)  
Old 03-03-2006, 01:14 PM
Member
 
Join Date: Jan 2006
Posts: 73
kucinx is on a distinguished road
hi coders,
is it possible to create the EA for Triggerlines as i see on history, it did a great job but it's a bit hard to babysit it all the times.
ussualy i combined it with trend manager, so when the triggerlines crossing up and change the color to blue and TM has blue buy signal, if you can create an ea that can combined both indicators, it would be so helpfull .thx a lot
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #73 (permalink)  
Old 03-14-2006, 08:31 PM
Junior Member
 
Join Date: Mar 2006
Posts: 1
byrnewebb is on a distinguished road
ema cross

Hi codersguru,

I have been trying to get some help with an EA similar to yours because I am not a programmer by any means. I, however, can not drum up any interest so I thought, since yours is so close maybe it can be adjusted for what I am trying to do. Below is an easy explanation of the 3 variables:

If EMA 9 crosses above EMA 30 and Momentum(21) crosses 100 a buy signal is created. A buy exit would be generated when EMA 9 crosses below EMA 30 no matter what the momentum line is doing.

If EMA 9 crosses below EMA 30 and Momentum(21) crosses below 100 a sell signal is created. A sell exit would be generated when EMA 9 crosses above EMA 30 no matter what the momentum line is doing.

What do you think? Is it something that can be adjusted or is it even a feasible EA? Any help would be appreciated!

BW
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #74 (permalink)  
Old 03-15-2006, 02:27 AM
Member
 
Join Date: Feb 2006
Posts: 81
laserjet is on a distinguished road
IndicatorCounted

Hi Codegru,

First I want to thank you for doing such a remarkable work, for MT4 lessons. A week ago MT4 was like very hard, but now I start leaning.

I am trying to convert a indicator into EA. Indicator is using "int counted_bars = IndicatorCounted()", for counting bars, in EA I think I can't use this since it related to indicator.

How could I fix this problem.

Thanks a lot....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #75 (permalink)  
Old 04-09-2006, 04:00 AM
Junior Member
 
Join Date: Mar 2006
Posts: 3
jargall is on a distinguished road
ADX system

Hi Coder's Guru,

I just read the MQL4 guide this last weekend and designed my first EA.

BTW, thanks so much for your guide. I wasn't able to find anything on the Net that made learning the language such a breeze. You really built on each lesson at the right gradient.

Anyways, here's my first EA: I don't know if it's a profitable system or not, but the results of my EA back-test don't match up with some manual back-testing I did. I know there are two filters I wasn't able to figure out how to program but I'll get to that after I explain everything. (I attached a text file with the code in it).

Here's the basis of my system:

Initial setup:
15m time period
If it's between 200 and 1400 EST.
If ADX is greater than 20.
If last bar's [1] range is less than the previos bar's [2] range. (Inside Period).
If last bar's [1] range is less than 7 pips.

Conditional setup A:
If 20-period EMA is up.
If Bid is greater than last bar's high [1] (I'm assuming the charts show Bid only... is that right?)
Buy at ask price with stop loss at one tick below last period's low.

Conditional setup B:
If 20-period EMA is down.
If Bid is less than last bar's low [1].
Sell as Bid with stop loss one tick above last bar's high+ask.

I want to set the take profit at a certain Risk:Reward rate. In my back-testing I found that when the Inside period's bar is less that 5, a 3:1 reward ratio is good. (a 30 pip limit order (5(range) + 3(spread) + 2(SL and entry))*3=30).... I don't think I programmed that correctly in my code though.

First question:

Am I using the right code to initiate the trades? Did I correctly use the highs, asks, etc.?

Second question:

My time filter doesn't seem to work. Am I doing this correctly?

Third question:

I only want the trades initiated ONE PIP above last bar's High+ask. I think my current code will initiate trades if prices gap above this price. How do I fix this?

fourth question:

I think this is the biggest error in my code: I don't have a filter for when the 20-EMA reverses but the ADX is still over 20. I would ALSO like to see how this system works if the 20-EMA reverses, the ADX goes down (but not lower than 20) and then goes back up, so MAYBE we could filter out trades when the ADX is down-trending, but then again this might filter out many profitable trades). If I could get some help on the coding, I would be fine experimenting on these different factors.

From my manual back-testing I think I may have a profitable system here, so any help would be appreciated.

Thanks in advance!

Jason
Attached Files
File Type: txt IPADXEMA.txt (4.9 KB, 47 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #76 (permalink)  
Old 04-09-2006, 05:49 AM
Junior Member
 
Join Date: Jan 2006
Posts: 2
valnie is on a distinguished road
Help in programming

Hi codersguru,

I need help in creating EA. Can you help, if so what are your fees?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #77 (permalink)  
Old 04-17-2006, 02:57 PM
pete7's Avatar
Member
 
Join Date: Jan 2006
Posts: 92
pete7 is on a distinguished road
Hi Codersguru,
it would be great if you would find some time to take a look at my problem:Consolidation Lines // Not working

Best Regards
Peter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #78 (permalink)  
Old 04-17-2006, 03:14 PM
Member
 
Join Date: Apr 2006
Posts: 61
gordon is on a distinguished road
Newbie question

Can you help, just starting
Can you tell me how to change the default colours on heiken ashi candles?
I can change colours on chart but they revert to default of red and white if I chage times or currencies.

thanks
Gordon
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #79 (permalink)  
Old 04-17-2006, 03:23 PM
firedave's Avatar
Senior Member
 
Join Date: Nov 2005
Location: Jakarta, Indonesia
Posts: 416
firedave is on a distinguished road
Quote:
Originally Posted by gordon
Can you help, just starting
Can you tell me how to change the default colours on heiken ashi candles?
I can change colours on chart but they revert to default of red and white if I chage times or currencies.

thanks
Gordon
Hi Gordon, could you post the MQ4 file here, then we could together help you. Hope this help
__________________
David Michael H
"Trader helps traders with sincerity, honesty and integrity"
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #80 (permalink)  
Old 04-17-2006, 03:30 PM
Member
 
Join Date: Apr 2006
Posts: 61
gordon is on a distinguished road
thanks Dave,


#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, Red);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, White);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, Red);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, White);
SetIndexBuffer(3, ExtMapBuffer4);
//----
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
SetIndexDrawBegin(2,10);
SetIndexDrawBegin(3,10);
//---- indicator buffers mapping
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexBuffer(3,ExtMapBuffer4);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double haOpen, haHigh, haLow, haClose;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
//---- check for possible errors
if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
int pos=Bars-ExtCountedBars-1;
while(pos>=0)
{
haOpen=(ExtMapBuffer3[pos+1]+ExtMapBuffer4[pos+1])/2;
haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
haLow=MathMin(Low[pos], MathMin(haOpen, haClose));
if (haOpen<haClose)
{
ExtMapBuffer1[pos]=haLow;
ExtMapBuffer2[pos]=haHigh;
}
else
{
ExtMapBuffer1[pos]=haHigh;
ExtMapBuffer2[pos]=haLow;
}
ExtMapBuffer3[pos]=haOpen;
ExtMapBuffer4[pos]=haClose;
pos--;
}
//----
return(0);
}
//+---------------------------
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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
Forum Jump

LinkBacks (?)
LinkBack to this Thread: http://www.forex-tsd.com/questions/270-ask.html
Posted By For Type Date
OzFx System:) - Page 639 This thread Refback 06-21-2008 09:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 11:46 AM


All times are GMT. The time now is 12:29 AM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.