How to code? - page 15

 

Coder Needed!

To all programmer other there, i need help you to code or make for me EA for my trading. I don't have any experience on doing EA so i need you guys.

The EA :

LWMA - 5 (close)

SMA - 8 (close)

Buy - when both line cross then wait for the next bar and automatically start trigger. Same also for going short.

Stoploss - 30

Takeprofit - 30

Trailstop- 15

Please i need help.

Thanks.

 
Sinar FX:
To all programmer other there, i need help you to code or make for me EA for my trading. I don't have any experience on doing EA so i need you guys.

The EA :

LWMA - 5 (close)

SMA - 8 (close)

Buy - when both line cross then wait for the next bar and automatically start trigger. Same also for going short.

Stoploss - 30

Takeprofit - 30

Trailstop- 15

Please i need help.

Thanks.

What time frame?

 

Please, help me to understand custom indicator code

Hi. I am a newbie to MQL4. I noticed that many custom indicators contain the following lines to prepare for the bar-counting loop:

int counted_bars = IndicatorCounted();

if( counted_bars < 0 ) return(-1);

if( counted_bars > 0 ) counted_bars--;

int limit = Bars - counted_bars;

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

According to the tutorial from metatrader.info, counted_bars = IndicatorCounted() will calculate counted_bars as 0 at the first launch of the indicator. "After that it will be the count of total bars on the chart minus one". After what? After the first launch? Do I have to launch the indicator twice for it to work? The MQL4 reference manual is not much clearer either: "IndicatorCounted() returns bars count that does not changed after last indicator launch. In most cases same count of index values do not need for recalculation. Used for optimizing calculations."

Then there is Bars, which is "the number of bars on the chart." Why not simpky use the following bar-counting loop:

for(int i=1;i<=Bars;i++)

I would understand if somebody can explain in the plain english what is exactly happening in

int counted_bars = IndicatorCounted();

if( counted_bars < 0 ) return(-1);

if( counted_bars > 0 ) counted_bars--;

int limit = Bars - counted_bars;

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

and in what direction the bars are counted: forward (from the oldest bar to the newest) or backwards? Thanks in avdance!

 

See if this article helps.

https://www.mql5.com/en/articles/1497

good luck.

 

Thanks, Maji. It helped. Correct me if I am wrong:

1. IndicatorCounted is useful in charts whose bars are updated in real time. So, instead of re-calculating the indicator values for all the bars when a new bar appears, only the indicator value for this new bar is calculated.

2. "limit" is simply the number of new bars, for which the indicator has to be calculated.

3. The indicator index counts bars backwards, with i=0 indicating the new (current) bar.

I guess my confusion was based on my prior experience with Wealth-Lab, where an indicator code is written such that the indicator values are calculated for all the bars even if only the new bars need to be calculated. However, Wealth-Lab has some built-in smartness and it is possible that the indicators are automatically re-calculated for the new bars only. I am getting a feeling that MQL4 does not want make such decisions for you and leave these decisions to you by forcing you to make extra programming steps. I actually like that because I always hate when a software makes decisions for you and these decisions are not the same as yours. My only problem with MQL4 is that I wish it had better documentation.

 

fiqe,

I believe your assumptions are right. i think MT4 is right in just calculating the indicators once and WL hogs resources doing it the other way.

I maybe wrong, and I hope others more knowledgeable can correct both of us.

 
 

Nick,

Check your email. I have sent you an example there.

Let me know.

Maji

 

OK , I think U can do this like that:

First u have to point what hour are u searching - if your broker is GMT+3 then to count Pivots on GMT time u have to decerase brokers time by 3. So If u search for hour 00.00 u will search for 21.00 at your broker time.

Now, one day is 24 hours and we start to search from right part of the screen. Your broker time is +3 so we will be adding that numbet to shift value.

for(int i = 3 ; i <= 27 ; i++)

{

if(TimeHour(Time)==21)

{

//This should be your GMT midnight so u can take OHLC values from here

double open = iOpen(Symbol(),60,i);

double high = iHigh(Symbol(),60,i);

double low = iLow(Symbol(),60,i);

double close = iClose(Symbol(),60,i);

}

}

I don't know if this is a simple way, but it works.

 

Hi,

In the last version of SimpleDailyRangeBreakoutExpert you can find code for making of candle(OHLC) for any time zone.

Reason: