MQL4 Learning - page 52

 
myke:
hi i am new, but i am not knew to fx trading,but i hav an indicator that is doing wonders,but i want to code it into an ea,i need help

Ok, post the Indicator or PM me and I'll look at an EA for it. What are the rules for signals? and how long have you been testing it?

 

How to read MA value of different bar

Hi Guys,

Need some light here, could anybody clarify or code for me value of Moving average for the current bar, previous bar, and last 2 or 3 bars.

It does not matter method of moving average.

regards...sufian

 

CurrentBar=iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,0);

PreviousBar=iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,1);

TwoBarsAgo=iMA(NULL,0,13,0,MODE_SMMA,PRICE_MEDIAN,2);

syntax for moving average function is:

double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

symbol - Symbol the data of which should be used to calculate indicator. NULL means the current symbol.

timeframe - Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe.

period - Averaging period for calculation.

ma_shift - MA shift. Indicators line offset relate to the chart by timeframe.

ma_method - MA method. It can be any of the Moving Average method enumeration value.

applied_price - Applied price. It can be any of Applied price enumeration values.

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

 

A Question About MQL Programming Possibilities

I have searched through this forum and lots of others, used google, etc and have not been able to find answers to some questions...perhaps someone here has the answers I seek. I am not a programmer, but I am a good trader and understand the nuances of what I seek..I am not asking for any programmer to give away his craft, just info on possibilities

1...Is it possible to program an EA attached to one chart to execute directional or non directional trades in other crosses @ the same time. apply the same stop loss, etc ? eg: EUR/USD and GBP/USD

2...Is it possible to have a TS that tightens as the trade progresses? eg: start with 50 pip TS and every X time reduce 10, 15 etc pips

 

Yes both of those things are possible. If you're not a programmer it might take you some time but all the information and resources you need are right here.

Good luck

Lux

 

Void vs. Int

For a function, including start(), etc. is there any benefit or consequence to having it as an in ("int start()") versus a void ("void start()") if you never check the result of the returned result of the function?

I see many functions that are routinely defined as an int (init(), deinit(), start())but the value is never checked. I don't know if it is just wasted cycles (albeit tiny ones) in having them as int versus void.

Thanks.

 
luxinterior:
Yes both of those things are possible. If you're not a programmer it might take you some time but all the information and resources you need are right here.

Good luck

Lux

Thanks for the info. I had already taken Steve's email course and that is precisely what helped me to understand more about what I truly need. I did email him asking if he would assist but never got a response. I will try to find the answers to what I seek within these pages as you suggest. Hopefully I can understand enough to put an EA together that I want while trading.

 

does someone here have source code for sms alert for yahoo messenger? & source code for close all day trade if achieve target profit?

i already make it the source code but wont work.... thanks...

regards,

MANSTIR

 

WindowBarsPerChart() Problem

Hi there,

I have a problem with the WindowBarsPerChart() function (see attached screenshot) that I hope someone can help me with.

The screenshot shows a standard chart that I have scrolled all the way to the right so that the rightmost bar is bar 0.

I run a simple script that prints the values of WindowBarsPerChart() and WindowFirstVisibleBar(), the output of which you can see in the Experts tab of the screenshot.

WindowBarsPerChart returns a value of 39 and WindowFirstVisibleBar returns a value of 39.

If you count the bars on the screenshot right to left starting at 0 then the leftmost bar (the first visible bar) is indeed 39 which is correct which means there are 40 bars visible on the chart.

However WindowBarsPerChart() returns a value of only 39 which is incorrect since the value should be actually 40.

Can anyone offer any insight as to why WindowBarsPerChart() appears to return an incorrect value?

Regards,

Laurence.

Files:
bars.jpg  365 kb
 

To lhookway

Command WindowBarsPerChart() shows you how many whole bars could be shown in the window with your dimension. So you can see you have 39 whole bars and half. If you increase your horizontal for half bar, you will see -WindowBarsPerChart() =40

Reason: