Go Back   Forex-TSD > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Calendar Advertising Others Help






Register
Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.

From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.

Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
  • Elite Section
    Get access to private discussions, specialized support, indicators and trading systems reported every week.
  • Advanced Elite Section
    For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
See more

Reply
 
Thread Tools Display Modes
  #1291 (permalink)  
Old 09-03-2008, 05: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, 14 views)
File Type: ex4 cross.ex4 (2.6 KB, 6 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1292 (permalink)  
Old 09-03-2008, 08:06 PM
Goen's Avatar
Member
 
Join Date: Apr 2007
Posts: 67
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 08:28 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1293 (permalink)  
Old 09-10-2008, 11:14 PM
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 12:15 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1294 (permalink)  
Old 09-11-2008, 12:18 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,117
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1295 (permalink)  
Old 09-11-2008, 12: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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1296 (permalink)  
Old 09-11-2008, 02:28 AM
Senior Member
 
Join Date: Oct 2007
Posts: 230
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1297 (permalink)  
Old 09-11-2008, 01:38 PM
Senior Member
 
Join Date: Feb 2007
Posts: 991
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
__________________
NEW - MTF-BarPower - You'll be so successful that you'll hardly believe!!!

FerruFx / www.ervent.net - Professional Coding Services (EAs/Indicators/Alerts)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1298 (permalink)  
Old 09-11-2008, 04: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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1299 (permalink)  
Old 09-11-2008, 09:27 PM
Senior Member
 
Join Date: Oct 2007
Posts: 230
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #1300 (permalink)  
Old 09-12-2008, 12:41 AM
Senior Member
 
Join Date: Jan 2006
Posts: 1,117
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!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks

Tags
forex, histogram, JMASlope, ToR 1.20, ZUP_v1.mq4


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


All times are GMT. The time now is 02:27 AM.



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