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
  #801 (permalink)  
Old 04-09-2008, 08:36 AM
Junior Member
 
Join Date: Mar 2008
Location: Singapore
Posts: 2
meokoken is on a distinguished road
Programatically attach an EA to chart

Hi,

is it possible to attach an EA to a chart programmatically? Say I am currently running EA1 and I want it to attach EA2 to another chart on fulfillment of certain criteria. Is that possible?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #802 (permalink)  
Old 04-09-2008, 08:51 AM
Kalenzo's Avatar
Senior Member
 
Join Date: Dec 2005
Location: Bydgoszcz - Poland
Posts: 696
Kalenzo is on a distinguished road
Quote:
Originally Posted by meokoken View Post
Hi,

I will like to scan through some of the pairs, and some of the time frames of the pairs to detect the current environment (trending, range bound etc) using indicators such as ADX. This is to help me select the best pair/timeframe to trade on base on my set of criteria.

The lousy way out is to attach an environment detecting EA to ALL the charts, have them write the results to a file and then do my own comparison on the file. However this will be too tedious and manual!

Is it possible to attach my EA to just 1 chart, and have that EA get the data from all the pairs and timeframe using Time Series functions such as iClose, iOpen etc, and then feeding the price to my indicators?

Does anyone foresee any problem with the 2nd method? Too much CPU processing involve? Time taken to run check will be too long etc? I do not require time frame finer than 5 min.

I am new to EA and thus do not know the performance of it. Any help will be greatly appreciated. Cheers!!
You can use the symbol function for this. Eg. if you wish to check the value of moving average and close price on 10 charts eg 10 crosses from different timeframes but at current bar then it will look like this:

double eurudMa = iMa("EURUSD", blablabla,PERIOD_X,0);
double eurusdClose = iClose("EURUSD",PERIOD_X);
and compare those values if you wish.
The same with other indicators. If you wish to get the bid and ask price of specified cross, use MarketInfo function in the same way.

Regards
Kale
__________________
You need proffesional mql coder? Contact me! I will help you!
........................................
http://www.fxservice.eu/
........................................
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #803 (permalink)  
Old 04-09-2008, 01:53 PM
kat kat is offline
Member
 
Join Date: Apr 2006
Posts: 46
kat is on a distinguished road
OsMA with signal line

Coders, I need your help. Can someone add a signal line to the attached OsMA indicator? Thank you very much!
Attached Files
File Type: mq4 OsMA.mq4 (2.5 KB, 2 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #804 (permalink)  
Old 04-09-2008, 02:22 PM
Junior Member
 
Join Date: Feb 2008
Posts: 15
SolomonZhang is on a distinguished road
How to Create Digital Version of This?

Hi guys,

I'm a beginner here.

Wolfe had been kindly enough to create a template for a code below, which I've modified. It runs perfectly well, and do what I want it to do.

But now,

I'm thinking to create the digital version of this, similar to the DIGISTOCH indicator.

What I want to know is:
- How to "clear" or "flush" buffers? I can't seem to be able to "erase" the link of buffers and create new ones.
- How to modify this to NOT include buffers? I think it will save some memory right? I've tried to erase the SetIndexBuffer but then when loaded in MT4 it gives "zero divide" error at the expert terminal window.
- Both label below display only 1 value, the H1 value. It suppose to display the number from H1 and H4 number. So it's not working here.
- I basically want this to display the Ratio number from different time frames (from M1 to MN1) in one screen, just like DIGIStoch indicator.

Any help would be appreciated.

Regards,

Code:
//+------------------------------------------------------------------+
//|                                                      2MA_RSI.mq4 |
//+------------------------------------------------------------------+
#property copyright "Wolfe"
#property link "xxxxwolfe@gmail.com"

#property indicator_separate_window
#property indicator_level1  100
#property indicator_level2  80
#property indicator_level3  50
#property indicator_level4  20
#property indicator_buffers 4
#property indicator_color1 Black    //RSI
#property indicator_color2 Blue     //MA1
#property indicator_color3 Red      //MA2
#property indicator_color4 Green    //Ratio

int  RSI_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc...
int  RSI_Period = 10;
int  RSI_Applied_Price = 0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4
int  MA1_Period = 10;
int  MA1_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA
int  MA2_Period = 30;
int  MA2_Method = 1;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA

double RSI[],MA1_Array[],MA2_Array[],MR_Ratio[];
double _RSI[],_MA1_Array[],_MA2_Array[],_MR_Ratio[];
string ShortName="MoR";

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators setting
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); //RSI
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1); //EMA10
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1); //EMA30
SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2); //Ratio

SetIndexBuffer(0,RSI);
SetIndexLabel(0,"RSI");

SetIndexBuffer(1,MA1_Array);
SetIndexLabel(1,"MA1");

SetIndexBuffer(2,MA2_Array);
SetIndexLabel(2,"MA2");

SetIndexBuffer(3,MR_Ratio);
SetIndexLabel(3,"Ratio");

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
IndicatorShortName(ShortName);

return(0);
}

int start()
{
   int i,limit = Bars - IndicatorCounted() - 1;
   for(i=limit; i>=0; i--){
      RSI[i]= iRSI(NULL,60,RSI_Period,RSI_Applied_Price,i);
   }
   for(i=limit; i>=0; i--){ 
      MA1_Array[i] = iMAOnArray(RSI,0,MA1_Period,0,MA1_Method,i);
      MA2_Array[i] = iMAOnArray(RSI,0,MA2_Period,0,MA2_Method,i);
   }
   for (i=0; i<=limit; i++){
      MR_Ratio[i] = MA1_Array[i] / MA2_Array[i] * 100;
   }
   double tmp1=MR_Ratio[0];
   SetText("Label1",DoubleToStr(tmp1,1),Black,55,20);
   
   //+------------------------------------------------------------------+
   //| Trying to set new buffers                                        |
   //+------------------------------------------------------------------+
   IndicatorBuffers(4);
   SetIndexBuffer(0,_RSI);
   SetIndexBuffer(1,_MA1_Array);
   SetIndexBuffer(2,_MA2_Array);
   SetIndexBuffer(3,_MR_Ratio);
   for(i=limit; i>=0; i--){
      _RSI[i]= iRSI(NULL,240,RSI_Period,RSI_Applied_Price,i);
   }
   for(i=limit; i>=0; i--){
      _MA1_Array[i] = iMAOnArray(_RSI,0,MA1_Period,0,MA1_Method,i);
      _MA2_Array[i] = iMAOnArray(_RSI,0,MA2_Period,0,MA2_Method,i);
   }
   for (i=0; i<=limit; i++){
     _MR_Ratio[i] = _MA1_Array[i] / _MA2_Array[i] * 100;
   }
   double tmp2=_MR_Ratio[0];
   SetText("Label2",DoubleToStr(tmp2,1),Black,95,20);
   //----
   return(0);
}

void SetText(string ObjName,string ObjText,color clr,int xpos,int ypos){
   ObjectCreate(ObjName,OBJ_LABEL,WindowFind(ShortName),0,0);
   ObjectSetText(ObjName,ObjText,9,"Arial Bold",clr);
   ObjectSet(ObjName,OBJPROP_CORNER,0);
   ObjectSet(ObjName,OBJPROP_XDISTANCE,xpos);
   ObjectSet(ObjName,OBJPROP_YDISTANCE,ypos);
}

Last edited by SolomonZhang; 04-09-2008 at 02:26 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #805 (permalink)  
Old 04-09-2008, 06:45 PM
Linuxser's Avatar
Moderator
 
Join Date: May 2006
Location: Helliconia (Spring)
Posts: 2,753
Blog Entries: 30
Linuxser has disabled reputation
Quote:
Originally Posted by SolomonZhang View Post
Hi guys,

I'm a beginner here.

Wolfe had been kindly enough to create a template for a code below, which I've modified. It runs perfectly well, and do what I want it to do.

But now,

I'm thinking to create the digital version of this, similar to the DIGISTOCH indicator.

What I want to know is:
- How to "clear" or "flush" buffers? I can't seem to be able to "erase" the link of buffers and create new ones.
- How to modify this to NOT include buffers? I think it will save some memory right? I've tried to erase the SetIndexBuffer but then when loaded in MT4 it gives "zero divide" error at the expert terminal window.
- Both label below display only 1 value, the H1 value. It suppose to display the number from H1 and H4 number. So it's not working here.
- I basically want this to display the Ratio number from different time frames (from M1 to MN1) in one screen, just like DIGIStoch indicator.

Any help would be appreciated.

Regards,
Just define an empty value for buffers after the init for every loop.

About zero divide just create some "if" condition before calculation.
__________________
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
  #806 (permalink)  
Old 04-10-2008, 06:04 AM
moisyed's Avatar
Junior Member
 
Join Date: Mar 2007
Posts: 7
moisyed is on a distinguished road
Multi time signal code

Hi Programmers

I am a newbie learning how to program and have created a basic EA and appreciate if someone kind enough to help me with following:

Idea is to basically look for higher TF signal and wait for retracement in lower TF and then execute order such as :

if 4 HR generates a signal on following:

if(MacdCurrent<0 && MacdCurrent>SignalCurrent)MacdPrevious<SignalPrevi ous)=LongSignalActivated

how to hold above signal and wait for 1 HR (or any other time frame) retracement such as

if (MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious) Order=SignalBuy
OR
Any other strategy..

I already have all indicators defined in variables for different time frame...
I can send EA if someone is willing to lend hand ... also if any experienced programmer is willing to work with me my strategy, I am willing to compensate (unfortunately can't afford to pay much)..

Appreciate any help
Mo Syed
email: moi.syed@gmail.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #807 (permalink)  
Old 04-10-2008, 06:35 PM
Junior Member
 
Join Date: Dec 2007
Posts: 7
alimjan is on a distinguished road
Question 'void' - parameter definition expected!

Code:
string OpenTrades(string mySymbol,double LotSize, double OpenPrice,int Type, double StopLoss, double TakeProfit, string ticketComment, void string MagicNum)
{
   // bu funksiye birilgen melumatqa asasen mal alidu we zakaz numurini qayturidu.
   
   switch(Type)
   {
      case OP_BUY:      if(OpenPrice > MarketInfo(mySymbol,MODE_ASK) return(EMPTY);
      case OP_BUYLIMIT:
      case OP_BUYSTOP:
            OrderSend(mySymbol,Type,LotSize,OpenPrice,0,OpenPrice-Point*StopLoss,OpenPrice+Point*TakeProfit,ticketComment,MagicNum);
            break;
      case OP_SELL:     if(OpenPrice < MarketInfo(mySymbol,MODE_BID) return(EMPTY);
      case OP_SELLLIMIT:
      case OP_SELLSTOP:
            OrderSend(mySymbol,Type,LotSize,OpenPrice,0,OpenPrice+Point*StopLoss,OpenPrice-Point*TakeProfit,ticketComment,MagicNum);
            break;
    }
compiler error on : 'void' - parameter definition expected! ?????????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #808 (permalink)  
Old 04-10-2008, 09:38 PM
Senior Member
 
Join Date: Feb 2006
Posts: 519
Michel is on a distinguished road
Quote:
Originally Posted by alimjan View Post
Code:
string OpenTrades(string mySymbol,double LotSize, double OpenPrice,int Type, double StopLoss, double TakeProfit,
 string ticketComment, void string MagicNum)
...
compiler error on : 'void' - parameter definition expected! ?????????
just delete "void".
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #809 (permalink)  
Old 04-12-2008, 01:05 AM
Junior Member
 
Join Date: May 2007
Posts: 2
hopokuk is on a distinguished road
Trailing stop, initial stop

void ModifyOrder(double buyTS, sellTS) {
if (Bid - OrderOpenPrice() > buyTS * Point)
if (OrderStopLoss() < Bid - buyTS * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Bid - buyTS * Point, OrderTakeProfit(), 0);
if (OrderOpenPrice() - Ask > sellTS * Point)
if (OrderStopLoss() > Ask + sellTS * Point) OrderModify(OrderTicket(), OrderOpenPrice(), Ask + sellTS * Point, OrderTakeProfit(), 0);
}



If the Trailing Stop is 40, the initial stop will be zero (orderopenprice)

I would like the initial stop to be 10 -

help please?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #810 (permalink)  
Old 04-12-2008, 09:41 PM
Junior Member
 
Join Date: Feb 2008
Posts: 1
kian is on a distinguished road
Cross Overs

DOES ANYONE KNOW HOW DO YOU WRITE WHEN TWO LINES CROSS OVER EACH OTHER
LETS SAY SAY IF 10 EMA IS ABOVE 20 EMA CONDTION 1
IF THAT CONDITION 1 IS THERE ....THEN TAKE A LONG WHEN STOCASTICS
D CROSSES ABOVE k
FOR D ABOVE K WE CAN USE D > K
WHAT DO YOU USE FOR D CROSS ABOVE k WHILE THE EMA CONDITION 1 IS IN PLACE?
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 10:40 PM.



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