in another example the result is right,what's the reason?
//+------------------------------------------------------------------+ //| testTrigger.mq4 | //| qiuyg | //| | //+------------------------------------------------------------------+ #property copyright "qiuyg" #property link "" int curTrend = 3; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { //---- Print("curTrend: ",curTrend); curTrend = 2; //---- return(0); } //+------------------------------------------------------------------+
a part of log:
17:44:41 myFuctions EURUSD,M15: removed 17:44:41 testTrigger EURUSD,M15: loaded successfully 17:44:41 testTrigger started for testing 17:44:41 1999.11.02 01:00 testTrigger EURUSD,M15: curTrend: 3 17:44:41 1999.11.02 01:01 testTrigger EURUSD,M15: curTrend: 2 17:44:41 1999.11.02 01:02 testTrigger EURUSD,M15: curTrend: 2 17:44:41 1999.11.02 01:14 testTrigger EURUSD,M15: curTrend: 2 17:44:41 1999.11.02 01:15 testTrigger EURUSD,M15: curTrend: 2
external variables cannot be changed within expert - there are external parameters and should be changed from property page
the variable "curTrend" is not external
int curTrend=5;
not
extern int curTrend=5;
variable "curTrend" be changed to 1 in start() fucntion,but be reset to 5 before start() be trigged next time.
parameter "curTrend" value be reset to 5,how can i to avoid this? thx!
... int curTrend=5; ... //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { ... else { Print("33 curTrend: ",curTrend); int curTrend = getTrend(longestPeriod,longTrendKeepPeriod,longTrendKeepRange*Point,1); if (curTrend == TRENDBULL) { if ((isUpCross(shortestPeriod,longestPeriod,1) || isUpCross(shorterPeriod,longestPeriod,1) || isUpCross(longerPeriod,longestPeriod,1)) && (isAbove(shortestPeriod,longestPeriod,1) && isAbove(shorterPeriod,longestPeriod,1) && isAbove(longerPeriod,longestPeriod,1))) { Print("**** begin bull trend ****"); Print("44 curTrend: ",curTrend); return (0); } else { Print("55 curTrend: ",curTrend); curTrend = TRENDNO; } } } } return(0); } //+------------------------------------------------------------------+
int curTrend=5;
...
{
Print("33 curTrend: ",curTrend);
int curTrend = getTrend(longestPeriod,longTrendKeepPeriod,longTrendKeepRange*Point,1);
do not mix variables with same name but different scopes - global and local
int curTrend=5;
...
{
Print("33 curTrend: ",curTrend);
int curTrend = getTrend(longestPeriod,longTrendKeepPeriod,longTrendKeepRange*Point,1);
do not mix variables with same name but different scopes - global and local
o...,it's my stupid mistake
thank you every much Slawa

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
a part of log: