| New signals service! | |
|
|||||||
| 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 |
|
![]() |
|
|
LinkBack (1) | Thread Tools | Display Modes |
|
|||
|
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? |
|
||||
|
Quote:
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/ ........................................ |
|
|||
|
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. |
|
||||
|
Quote:
About zero divide just create some "if" condition before calculation.
__________________
|
|
||||
|
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 |
|
|||
|
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;
}
|
|
|||
|
just delete "void".
|
|
|||
|
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? |
|
|||
|
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? |
![]() |
| Bookmarks |
| Tags |
| CHinGsMAroonCLK, I_XO_A_H |
| Thread Tools | |
| Display Modes | |
|
|
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 |