MQL4 Learning - page 86

 
Stiffler:
I am new to programming, i've spent a lot of time trying to figure out how to make this work. Can anyone code an ex.4 so that the moving averages on the file I have attached will show up on one graph for different TF's? Any help would be greatly appreciated.

I have not seen your attachment,

but all you have to do is drag the moving average indicator onto your chart as many times as you have moving averages to depict and specify time frames. It would be in terms of bars. So on a 15 min chart, the hourly ma would requre you to specify 4. On the same 15 min chart, a 4 hourly line would require a specification of 16 etc.

If you want the 5ma of the hourly period to be shown on the 15 min chart, specify 20 (5*4) and so on..

Is that what you wanted to know?

kind regards,

Jim

 

I must apologize, I have no idea what you directed me to do. I've attached two indicator ex's to help explain what I'm trying to do. I can't seem to only get the MA's bars to show up on the grid instead of the blue boxes and red and green verticle lines.

Files:
 

Need help to understand this coding

hi guys!

i need help from you guys to guide me, what is this mean :

for (order = 0; order < OrdersTotal()-1; order++)

what I don't understand is, what is the purpose of OrdersTotal()-1?

why orderstotal minus 1?

your help is much appreciated.

thanks in advance!

 

Trailing SL and TP Together?

Hi, Will it be a train smash if you trail your Take Profit together with your SL, meaning say you enter a trade EURUSD at 1.455 and you set youre TP = 20 pips and youre SL = 30.

If the market goes against you youre Sl trails as normal, but, if the market goes with you both youre TP and SL moves with the marker, if then the market turnes again yore SL may be above youre Purchaced prize and you would have a sure win.

Just a Thought?

Frans

 

The OrdersTotal() function returns the number of orders currently open and pending. Lets assume there are 5.

In mathematical notation the first element of an array is generally element 1, but some programming languages, including MQL use zero-based arrays. So for example if your trying to select the first order using the OrderSelect function, this isnt stored in array element 1 as you might expect, but in array element 0, the 2nd order is in array element 1, the third order is array element 2 etc

Therefore you need to loop from 0 to 4

Hope that helps

 
zupcon:
The OrdersTotal() function returns the number of orders currently open and pending. Lets assume there are 5.

In mathematical notation the first element of an array is generally element 1, but some programming languages, including MQL use zero-based arrays. So for example if your trying to select the first order using the OrderSelect function, this isnt stored in array element 1 as you might expect, but in array element 0, the 2nd order is in array element 1, the third order is array element 2 etc

Therefore you need to loop from 0 to 4

Hope that helps

thanks!!

 

How to normalize indicator?

I have an indicator that has dynamic range (min changes from -100 to -30; max changes from 0 to 12-15).

How to normalize it? I want indicator to have min=0 and max=1. I tried to use WPR principle but can't complete it.

Please, help.

 

...

Why don't you use a simple stochastic oscillator "way" :
(value-minimalValue) / (maximalValue-minimalValue)

where minimalValue and maximalValue are minimum and maximum over some period

If you take a look at "normalizing ways", this one is almost always there somewhere (since it does work as it should - unlike some "ways" that are forgetting the basic principle of normalizing : the known minimum and maximum) They might not call it that way, but if you look at what are they proposing, that is it

______________________________________

PS: also take a look at this post - https://www.mql5.com/en/forum/178276/page30 ( especially the part about ways to standardize the target variables )

CanisLC:
I have an indicator that has dynamic range (min changes from -100 to -30; max changes from 0 to 12-15).

How to normalize it? I want indicator to have min=0 and max=1. I tried to use WPR principle but can't complete it.

Please, help.
 

Help Needed in this code

hi,

I'm trying to get the open time for current order by using this code :

int orders, total, j;

datetime Open_Time;

orders = 0;

total = OrdersTotal ();

for (j = 0; j < total; j++)

{

OrderSelect (j, SELECT_BY_POS, MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderSymbol() == Symbol()) {

orders++;

Open_Time = OrderOpenTime(); }

}

the value I got for the Open_Time = 1258340974

my question :

1) is the code I used is correct?

2) what does it mean with the value I got and how to translate to correct date and time value?

your help is much appreciated!

 
mynes:
hi,

I'm trying to get the open time for current order by using this code :

int orders, total, j;

datetime Open_Time;

orders = 0;

total = OrdersTotal ();

for (j = 0; j < total; j++)

{

OrderSelect (j, SELECT_BY_POS, MODE_TRADES);

if (OrderMagicNumber() == Magic && OrderSymbol() == Symbol()) {

orders++;

Open_Time = OrderOpenTime(); }

}

the value I got for the Open_Time = 1258340974

my question :

1) is the code I used is correct?

2) what does it mean with the value I got and how to translate to correct date and time value?

your help is much appreciated!

1) Yes, The value represents the amount of seconds elapse from 00:00 Jan 1, 1970.

2) use the TimeToString() function

Reason: