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
  #1291 (permalink)  
Old 09-03-2008, 06:27 AM
Junior Member
 
Join Date: Apr 2008
Posts: 1
yarksiew is on a distinguished road
how to add alert to tis indicator?

i hv got an MA crossover indicator which work really well, but it doesn't hv the sound alert support tat make me miss a lot of trade, can u please teach me how to add alert to tis indicator as I know nothing about the meta code thing....thanks...

here is the code for the indicator together wif the indicator itself, thanks...


/*[[
Name := EMA Cross
Author := Hapsa
Link := http://www.metaquotes.net/
Separate Window := No
Separate Window := No
First Color := Red
First Draw Type := Symbol
First Symbol := 108
Use Second Data := Yes
Second Color := DarkOliveGreen
Second Draw Type := Symbol
Second Symbol := 108
]]*/


#property copyright "Hapsa"
#property link ""
extern int SlowPeriod=20;
extern int FastPeriod=5;

#property indicator_buffers 3
#property indicator_chart_window
#property indicator_color1 Red
#property indicator_color2 Green
double L20[];
double L50[];
double shift=0,val1=0,val2=0;

int init()
{

IndicatorBuffers(3);
SetIndexStyle(0,DRAW_ARROW);
SetIndexStyle(1,DRAW_ARROW);

SetIndexArrow(0, 108);
SetIndexArrow(1, 108);

SetIndexBuffer(0,L20);
SetIndexBuffer(1,L50);




//---- indicators
//----
return(0);
}





int start()
{


int counted_bars=IndicatorCounted();
//----
int i = Bars - counted_bars - 1;
while (i>=0)
{

val1=0;
val2=0;

double iMaSlowPrevious = iMA(NULL,0,SlowPeriod,0,MODE_EMA, PRICE_CLOSE, i-1);
double iMaSlowCurrent = iMA(NULL,0,SlowPeriod,0,MODE_EMA, PRICE_CLOSE, i);
double iMaFastPrevious = iMA(NULL,0,FastPeriod,0,MODE_EMA, PRICE_CLOSE, i-1);
double iMaFastCurrent = iMA(NULL,0,FastPeriod,0,MODE_EMA, PRICE_CLOSE, i);

if (iMaFastPrevious<iMaSlowPrevious && iMaFastCurrent>iMaSlowCurrent ) val1=High[i];
if (iMaFastPrevious>iMaSlowPrevious && iMaFastCurrent<iMaSlowCurrent ) val2=Low[i];
L20[i]=val1+5*Point;
L50[i]=val2-5*Point;
i--;
}

//----
return(0);
}
Attached Files
File Type: mq4 cross.mq4 (1.6 KB, 6 views)
File Type: ex4 cross.ex4 (2.6 KB, 1 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1292 (permalink)  
Old 09-03-2008, 09:06 PM
Goen's Avatar
Member
 
Join Date: Apr 2007
Posts: 64
Goen is on a distinguished road
Quote:
Originally Posted by forexarchitect View Post
thanks for answering..

what do I need to change here? appreciate your help

double GetMaxLot(int type1, int type2)
{
double max_lot = 0.0;

int cnt = OrdersTotal();
for (int i=0; i < cnt; i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderType() != type1 && OrderType() != type2) continue;

if (max_lot == 0 || OrderLots() >= max_lot)
{
max_lot = OrderLots();
}
}

return (max_lot);
}
Yes, you can use GetMaxLot(OP_BUY,OP_BUY); to get the maxlot for buy open trade only, and GetMaxLot(OP_SELL,OP_SELL); to get the maxlot for sell open trade only.

You can make simplify this code "if (max_lot == 0 || OrderLots() >= max_lot)" with "if (OrderLots() > max_lot)"
Coz if max_lot = 0 automatically it will be lower than any lot of the open trades. And sign ">=" change with ">" coz if it have same value, no need to update max_lot with the same value, useless effort. It will update only if the new value greater than max_lot.
By changing that code, it could make your process faster.

Goen

Last edited by Goen; 09-03-2008 at 09:28 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1293 (permalink)  
Old 09-11-2008, 12:14 AM
Junior Member
 
Join Date: Sep 2008
Posts: 2
azertyken2 is on a distinguished road
stoploss issue

Hello,

I'm new to all this forex/metatrading but am trying to understand how it all works.

Now I am trying to write an EA and I'm afraid I'm missing something fundamental.
If, in my code, I replace
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",MAGIC, 0,Red);
with
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+Point*10, 0,"",MAGIC,0,Red);
And test this new version out in the strategy tester, I get LESS orders. How can adding a stoploss diminish the number of order entries? I can imagine that the number rises in the case that adding a stop order causes orders to exit more early and thus new orders can be added more quickly, but LESS orders...?

Any idea?

Thanks

Last edited by azertyken2; 09-11-2008 at 01:15 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1294 (permalink)  
Old 09-11-2008, 01:18 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
Quote:
Originally Posted by azertyken2 View Post
Hello,

I'm new to all this forex/metatrading but am trying to understand how it all works.

Now I am trying to write an EA and I'm afraid I'm missing something fundamental.
If, in my code, I replace
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,0,0,"",orderc ount,0,Red);
with
OrderSend(Symbol(),OP_SELL,0.1,Bid,3,Ask+Point*10, 0,"",ordercount,0,Red);
And test this new version out in the strategy tester, I get LESS orders. How can adding a stoploss diminish the number of order entries? I can imagine that the number rises in the case that adding a stop order causes orders to exit more early and thus new orders can be added more quickly, but LESS orders...?

Any idea?

Thanks
10 pips may be too close to the broker-imposed stops limit (varies between brokers) - meaning if it's a minimium of 10 pips and price happens to swing 1 pip inside this as the order is being placed, the order will be rejected...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1295 (permalink)  
Old 09-11-2008, 01:41 AM
Junior Member
 
Join Date: Sep 2008
Posts: 2
azertyken2 is on a distinguished road
Omelette, you are right, increasing the stoploss fixed it, thanks! :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1296 (permalink)  
Old 09-11-2008, 03:28 AM
Senior Member
 
Join Date: Oct 2007
Posts: 223
Dave137 is on a distinguished road
Smile

PHP Code:
#property indicator_color1 Magenta
#property indicator_color2 Yellow


extern bool TrendDirectionUp=true;

string Color1;
string Color2;

int init()  {

if(
TrendDirectionUp==true)//Conditionj 1
{
Color1=Yellow;
Color2=CLR_NONE;
}

if(
TrendDirectionUp==false)//Condition2
{
Color1=CLR_NONE;
Color2=Magenta;
}

   
SetIndexStyle(0,DRAW_ARROW,0,star_size,Color1);
   
SetIndexStyle(1,DRAW_ARROW,0,star_size,Color2);
   
SetIndexArrow(0,172);//333
   
SetIndexArrow(1,172);//334
   
SetIndexBuffer(0,b1);
   
SetIndexBuffer(1,b2);

   return(
0);



Right now, both Color(s) 1 & 2 show 'black' on the graph!!

Can any expert Guru help me solve this issue???

Thanks in Advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1297 (permalink)  
Old 09-11-2008, 02:38 PM
Senior Member
 
Join Date: Feb 2007
Posts: 947
FerruFx is on a distinguished road
Quote:
Originally Posted by Dave137 View Post


Right now, both Color(s) 1 & 2 show 'black' on the graph!!

Can any expert Guru help me solve this issue???

Thanks in Advance!
color Color1;
color Color2;

FerruFx
__________________
THE HEART of FOREX & THE PROBABILITY METER - Trade with 100% confidence and ... Stress Less!!!
Coding services: Experts Advisors, indicators, alerts, etc ... more info by PM
NEW: video presentation of the Probability Meter ... 24hrs action on the website
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1298 (permalink)  
Old 09-11-2008, 05:59 PM
Junior Member
 
Join Date: Aug 2008
Posts: 5
xerof123 is on a distinguished road
Please can someone explain to me how can I get rid of an "OrderModify error 1" problem. I been looking and it seams I need to NormalizeDouble(), but I've normalized everything from here to the moon and still I'm getting the error.

Once I understand it I think I'll be able to figure it out, please can someone help. thanks.

I'm also getting an "unmatched data error(volume limit 31 at 2008.04.16 07:30 exceeded)" if any one knows what that's all about I'd appreciate the help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1299 (permalink)  
Old 09-11-2008, 10:27 PM
Senior Member
 
Join Date: Oct 2007
Posts: 223
Dave137 is on a distinguished road
Cool

Quote:
Originally Posted by FerruFx View Post
color Color1;
color Color2;

FerruFx
SetIndexStyle(0,DRAW_ARROW,0,star_size,color Color1);
SetIndexStyle(1,DRAW_ARROW,0,star_size,color Color2);

I tried inserting color all over the place, one step and trial at a time, and either I get an error for the above two statements - ')' - comma or semicolon expected or no error, but then everything shows black.

This really confuses me - Any more suggestions??

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #1300 (permalink)  
Old 09-12-2008, 01:41 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,119
omelette is on a distinguished road
@xerof123 - this error occurs when you try to modify an order with the same values the open order already has. The other problem is price mis-matches between the different timeframes - to get rid of them, delete and regenerate all tick data via the History Center menu.

@Dave137 - where to begin, you have color1, color2 defined as type string, whereas these are of type color. Note that 'color1' keyword in the 'properties' definition is just assigning a value, so when you later define color1, color2, they could just as easily be called c1,c2. Further note that you do not need to use 'properties color1' to begin with as you are setting them manually in the init() function anyway. Also, check other indicators on how to use of '#property indicator buffers x' and 'indicatorbuffers(x)'...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
histogram, forex, ZUP_v1.mq4

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 Off
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 10:53 PM
Forex SRDC Sidus Sibkis EA MT4 Forum OTCSmart This thread Refback 12-08-2007 12:46 PM


All times are GMT. The time now is 04:21 AM.



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