You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
No it will not. Test it.
I have test as below:
A:
A's result of changing time frame is :
B:
B's result of changing time frame is:
So...........
Just now I have test the difference between A and B according to your points.
What you said is correct but not all, because I find that as below:
1. A has match my purpose very well, but B can't. when B has been attached to chart(suppose: extern datetime time_current=2013.11.14 0:00 in B), if I go to other pair or other time frame chart, "time_current" will be 2013.11.14 0:00 again. so i think there must be other difference between A and B.
2. So I think "extern" has only one effect which can allow us assign its variables before EA's attached.
time_current will be whatever the user sets it to until this line is executed in init() . . .
time_current = TimeCurrent();
. . . what is the point in allowing the user to set it when you then instantly change it ?
I have test as below:
Test it properly . . .
Test it properly . . .
Ok, I have copied your code to test and get the result as below:
1. This EA is loaded in M5 chart, time_begin is 2013.11.14 00:00 and then changed to 2013.11.15 01.21;
2. Chart is changed to M15 from M5, time_begin is 2013.11.14 00:00 again, so time_begin has changed after initializing.
3. If there is no "extern" before "datetime time_begin", time_begin will be never changed when chart is changed to M15 from M5.
Based on the output I agree. Changing timeframes resets externals but not globals.
Just to be clear, Changing timeframes in an EA resets externals but not globalscope/statics.
But in an indicator,Changing timeframes resets externals, globalscope and statics.
init from extern, time_begin : X
init from extern, time_beg : X
init from extern, time_begin : X
init from extern, time_beg : X
I didn't post that, so I don't understand your response, you have quoted my post and added code to it.
Are you saying that only externals are reset when changing tf in both EAs and indicators?
About below A and B, it is very clear until now : the two variables, 'isFirst' and 'time_current', can never been changed when shift time frame in A, but done in B; another difference is that we can't set the two variables' value when EA is being attached in A, but we can do it in B.
Then another question is that: how shall we do if we want to set variables' value when EA is being attached like B and the variables can never been changed when shift time frame like in A? "static" can resolve this problem?
A:
B:
I didn't post that, so I don't understand your response, you have quoted my post and added code to it.
Are you saying that only externals are reset when changing tf in both EAs and indicators?