Forex
Google
New signals service!

Go Back   Forex Trading > Programming > Metatrader Programming


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 (1) Thread Tools Display Modes
  #881 (permalink)  
Old 05-08-2008, 09:42 PM
Junior Member
 
Join Date: Apr 2008
Posts: 17
denis68 is on a distinguished road
change ind in a EA

i would like to change the indicator in a EA i have,but i don't know how to do it
i am not a programmer in fact don't much about this kind kind of thing, below is the only part that relates to the indicator i want to change the DiMA to MFA(14)
i want to buy @ >60 and sell@<40

double diClose0=iClose(NULL,5,0);
double diMA1=iMA(NULL,5,7,0,MODE_SMA,PRICE_OPEN,0);
double diClose2=iClose(NULL,5,0);
double diMA3=iMA(NULL,5,6,0,MODE_SMA,PRICE_OPEN,0);

if(AccountFreeMargin()<(1000*Lots)){
Print("We have no money. Free Margin = ", AccountFreeMargin());
return(0);
}
if (!ExistPositions()){

if ((diClose0<diMA1)){
OpenBuy();
return(0);
}

if ((diClose2>diMA3)){
OpenSell();
return(0);
}
}
could someone please help me
denis
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #882 (permalink)  
Old 05-08-2008, 11:26 PM
Senior Member
 
Join Date: Oct 2007
Posts: 219
Dave137 is on a distinguished road
Question

Please post your MFA indicator. I need to see the buffers. Under what logic will you want to switch indicators?

Dave
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #883 (permalink)  
Old 05-09-2008, 08:35 PM
Junior Member
 
Join Date: Apr 2008
Posts: 17
denis68 is on a distinguished road
hi dave i can't post the MFI indicator it is not in the indicators folder you can get the indicator from the tool bar under volumes,i don't know what you mean by under what logic.
denis
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #884 (permalink)  
Old 05-09-2008, 09:08 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 2,844
Blog Entries: 34
Linuxser has disabled reputation
Quote:
Originally Posted by denis68 View Post
hi dave i can't post the MFI indicator it is not in the indicators folder you can get the indicator from the tool bar under volumes,i don't know what you mean by under what logic.
denis
This one? Market Facilitation Index
Attached Files
File Type: mq4 MFI.mq4 (2.7 KB, 7 views)
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #885 (permalink)  
Old 05-09-2008, 10:34 PM
Junior Member
 
Join Date: Apr 2008
Posts: 17
denis68 is on a distinguished road
hi linuxer i don't think thats the one but thanks anyway, the one i have is called money flow index.
denis
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #886 (permalink)  
Old 05-09-2008, 10:47 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 2,844
Blog Entries: 34
Linuxser has disabled reputation
Quote:
Originally Posted by denis68 View Post
hi linuxer i don't think thats the one but thanks anyway, the one i have is called money flow index.
denis
Sorry, I've misspelled the name, it's that one.

Money Flow Index.mq4 aka MFI.mq4
__________________
Elite Manual Trading | Portfolio | Calendar | Suggestions to improve the forum | My Blog

Remember: Signatures must have three lines as maximum
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #887 (permalink)  
Old 05-10-2008, 08:48 AM
Member
 
Join Date: Mar 2007
Posts: 32
Nordic12 is on a distinguished road
Anybody help me please

Hi

Ive tried to create an indicator and was wondering to see if someone can help me (i feel its 99.9% finished - well phase I anyway)

I just want an arrow when the CCI cross over zero line and the stoc crosses upwards (ideally the first time) - reverse for second time


//+------------------------------------------------------------------+
//| CCI_Stoc_Xover.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 SeaGreen
#property indicator_color2 Red

extern int CCI_Period = 14;
extern int Stoc_K=5;
extern int Stoc_D=3;
extern int Stoc_Slowing=3;

double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
int counted_bars=IndicatorCounted();
//---- 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;

for(i = 0; i <= limit; i++) {

counter=i;
double cci_1 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 1);
double cci_2 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 2);
double stok_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 0);
double stod_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 0);
double stok_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 1);
double stod_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 1);

if ((cci_2 <= 0 && cci_1 > 0 && stok_1 < stod_1 && stok_0 > stod_0)) {
CrossUp[i] = Low[i];
}
else if ((cci_2 >= 0 && cci_1 < 0 && stok_1 > stod_1 && stok_0 < stod_0)) {
CrossDown[i] = High[i];
}
}
return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #888 (permalink)  
Old 05-10-2008, 10:51 AM
Member
 
Join Date: Jan 2006
Posts: 56
hiachiever is on a distinguished road
One obvious thing is that you are missing a declaration for the number of indicator buffers that you are going to use.

This sits in the first part of init
eg
int init()
{
IndicatorBuffers(2);
.....
}


Give it a go and see if it fixes your problem. Note I haven't fully checked the code, I simply checked for obvious errors.

Cheers,
Hiachiever.

Quote:
Originally Posted by Nordic12 View Post
Hi

Ive tried to create an indicator and was wondering to see if someone can help me (i feel its 99.9% finished - well phase I anyway)

I just want an arrow when the CCI cross over zero line and the stoc crosses upwards (ideally the first time) - reverse for second time


//+------------------------------------------------------------------+
//| CCI_Stoc_Xover.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 SeaGreen
#property indicator_color2 Red

extern int CCI_Period = 14;
extern int Stoc_K=5;
extern int Stoc_D=3;
extern int Stoc_Slowing=3;

double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW, EMPTY,3);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW, EMPTY,3);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int limit, i, counter;
int counted_bars=IndicatorCounted();
//---- 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;

for(i = 0; i <= limit; i++) {

counter=i;
double cci_1 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 1);
double cci_2 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 2);
double stok_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 0);
double stod_0 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 0);
double stok_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_MAIN, 1);
double stod_1 = iStochastic(Symbol(), Period(), Stoc_K, Stoc_D, Stoc_Slowing, MODE_SMA, 0, MODE_SIGNAL, 1);

if ((cci_2 <= 0 && cci_1 > 0 && stok_1 < stod_1 && stok_0 > stod_0)) {
CrossUp[i] = Low[i];
}
else if ((cci_2 >= 0 && cci_1 < 0 && stok_1 > stod_1 && stok_0 < stod_0)) {
CrossDown[i] = High[i];
}
}
return(0);
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #889 (permalink)  
Old 05-10-2008, 11:05 AM
Member
 
Join Date: Mar 2007
Posts: 32
Nordic12 is on a distinguished road
.

Hi hiachiever

Thanks for that - I added the

IndicatorBuffers(2); to the init section; it complied ok but nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  1 links from elsewhere to this Post. Click to view. #890 (permalink)  
Old 05-10-2008, 11:42 AM
Member
 
Join Date: Jan 2006
Posts: 56
hiachiever is on a distinguished road
Hi,

A little further review has uncovered your problem. What you have done is not add in correct referencing of your indicators, these should have the variable 'i' as a reference not a specific bar number.

EG.
This is incorrect.
double cci_1 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 1);
double cci_2 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, 2);

It should be
double cci_1 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, i+1);
double cci_2 = iCCI(Symbol(), Period(), CCI_Period, PRICE_TYPICAL, i+2);

Cheers,
Hiachiever


Quote:
Originally Posted by hiachiever View Post
One obvious thing is that you are missing a declaration for the number of indicator buffers that you are going to use.

This sits in the first part of init
eg
int init()
{
IndicatorBuffers(2);
.....
}


Give it a go and see if it fixes your problem. Note I haven't fully checked the code, I simply checked for obvious errors.

Cheers,
Hiachiever.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

Tags
CHinGsMAroonCLK, I_XO_A_H

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/metatrader-programming/554-how-code.html
Posted By For Type Date
Need an experienced programmer? - Page 2 Post #0 Refback 09-24-2008 06:24 AM

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


All times are GMT. The time now is 03:49 AM.



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