How to code? - page 81

 

Help Needed

Hello all coders,

Please tell me the code how can I check the price according to candles. I mean how can I check that the current candle touches the MA line or not? and how Can I code that the current candle has open, high, low and close below the MA line. You help will be much appreciated.

Best Regards.......!

 
arsenic786:
Hello all coders,

Please tell me the code how can I check the price according to candles. I mean how can I check that the current candle touches the MA line or not? and how Can I code that the current candle has open, high, low and close below the MA line. You help will be much appreciated.

Best Regards.......!

Well to check the cross you have to compare prior close price, current close and moving average value (so iMa, Close[1], and Close[0]).

But to check if the candle is bellow or under the moving average you need to compare LOW and HIGH price and iMa value.

 

Tick Time Indicator

I'd like to build an indicator, one element of which is the time between ticks. Can anyone advise me if this function will be possible to incorporate ?

Thanks

 

Scanning through pairs/timeframe

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!!

 

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?

 
meokoken:
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

 

OsMA with signal line

Coders, I need your help. Can someone add a signal line to the attached OsMA indicator? Thank you very much!

Files:
osma.mq4  3 kb
 

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,

//+------------------------------------------------------------------+

//| 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= iRSI(NULL,60,RSI_Period,RSI_Applied_Price,i);

}

for(i=limit; i>=0; i--){

MA1_Array = iMAOnArray(RSI,0,MA1_Period,0,MA1_Method,i);

MA2_Array = iMAOnArray(RSI,0,MA2_Period,0,MA2_Method,i);

}

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

MR_Ratio = MA1_Array / MA2_Array * 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= iRSI(NULL,240,RSI_Period,RSI_Applied_Price,i);

}

for(i=limit; i>=0; i--){

_MA1_Array = iMAOnArray(_RSI,0,MA1_Period,0,MA1_Method,i);

_MA2_Array = iMAOnArray(_RSI,0,MA2_Period,0,MA2_Method,i);

}

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

_MR_Ratio = _MA1_Array / _MA2_Array * 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);

}

 
SolomonZhang:
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.

 

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(MacdCurrentSignalCurrent)MacdPrevious<SignalPrevious)=LongSignalActivated

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

if (MacdCurrentSignalCurrent && 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

Reason: