why parameters' value be reset while start() function be trigged everytime?

 
parameter "curTrend" value be reset to 5,how can i to avoid this? thx!
//+------------------------------------------------------------------+
//|                                                  FOLLOWTREND.mq4 |
//|                      Copyright ?2005, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "qiuyg fx."
#property link      ""
#include <stdlib.mqh>
#import "myFuctions.ex4"
    //---- messages
    int getTrend(int maPeriod,int keepPeriod,double keepRange,int shiftBars);
    /**
     *shiftBars&#21608;&#26399;&#21069;maPeriod&#30340;&#22343;&#32447;&#19978;&#25296;
     */
    bool isTurningPointUp(int maPeriod,int shiftBars);
    /**
     *shiftBars&#21608;&#26399;&#21069;maPeriod&#30340;&#22343;&#32447;&#19979;&#25296;
     */
    bool isTurningPointDown(int maPeriod,int shiftBars);
    /**
     *&#21028;&#26029;shiftBars&#21608;&#26399;&#21069;maPeriod&#30340;&#22343;&#32447;&#24050;&#32463;&#36830;&#32493;&#20445;&#25345;keepPeriod&#21608;&#26399;&#36716;&#29275;&#65292;&#24182;&#19988;&#32047;&#35745;&#24133;&#24230;&#36798;&#21040;keepRange&#65292;&#21542;&#21017;&#20026;&#26080;&#26126;&#26174;&#36235;&#21183;
     *keepRange&#21487;&#20026;&#36127;&#25968;&#65292;&#34920;&#31034;&#36300;&#21183;&#36235;&#32531;
     */
    bool beBuller(int maPeriod,int keepPeriod,double keepRange,int shiftBars);
    /**
    *&#21028;&#26029;shiftBars&#21608;&#26399;&#21069;maPeriod&#30340;&#22343;&#32447;&#24050;&#32463;&#36830;&#32493;&#20445;&#25345;keepPeriod&#21608;&#26399;&#36716;&#29066;&#65292;&#24182;&#19988;&#32047;&#35745;&#24133;&#24230;&#36798;&#21040;keepRange&#65292;&#21542;&#21017;&#20026;&#26080;&#26126;&#26174;&#36235;&#21183;
    *keepRange&#21487;&#20026;&#27491;&#25968;&#65292;&#34920;&#31034;&#28072;&#21183;&#36235;&#32531;
    */
   bool beBearer(int maPeriod,int keepPeriod,double keepRange,int shiftBars);
    /**
     *shiftBars&#21608;&#26399;&#21069;period1&#30340;&#22343;&#32447;&#19978;&#31359;period2&#30340;&#22343;&#32447;
     */
    bool isUpCross(int period1,int period2,int shiftBars);
    /**
     *shiftBars&#21608;&#26399;&#21069;period1&#30340;&#22343;&#32447;&#22312;period2&#30340;&#22343;&#32447;&#19978;&#26041;
     */
    bool isAbove(int period1,int period2,int shiftBars);
#import
//---- input parameters
extern double defaultTakeProfit = 80;
extern double defaultTrailingStop = 40;
extern double shortestPeriod = 3;
extern double shorterPeriod = 21;
extern double longerPeriod = 84;
extern double longestPeriod =336;
extern int beginCaculateTime = 197001;
extern int endCaculateTime = 200812;
extern int backPoint_Buy = 5,backPoint_Sell = 5;	//&#30495;&#27491;&#30340;&#19979;&#36300;&#21453;&#25277;&#24635;&#26159;&#29305;&#21035;&#23567;
extern int distanceFromMa = 50;                     //&#22238;&#35843;&#33267;&#22343;&#32447;&#21487;&#20171;&#20837;&#30340;&#33539;&#22260;
extern int slippage = 0;
extern bool tradeAllTime = false;
extern bool buySwitch = true;
extern bool sellSwitch = true;

double lastDealBars = 0,lastTradeBars;
int longTrendKeepPeriod = 8;          //&#38271;&#26399;&#36235;&#21183;&#20445;&#25345;&#26368;&#30701;&#26102;&#38388;
double longTrendKeepRange = 0.5;       //&#38271;&#26399;&#36235;&#21183;&#20445;&#25345;&#26368;&#23567;&#24133;&#24230;
bool isBeyondCaculateTime = false;     //&#26159;&#21542;&#36229;&#36807;&#20102;&#32479;&#35745;&#35745;&#31639;&#30340;&#26102;&#38388;
bool isBarsCountEnough = false;        //&#26159;&#21542;&#22815;&#24050;&#32463;&#22810;&#30340;&#35745;&#31639;&#21608;&#26399;
bool isActiveTime = false;
color dealTypeColor;
color UPCOLOR = Blue,DOWNCOLOR = Red;
color manualCloseColor = Black,modifyColor = Yellow;
double dealPrice,stopPrice,profitPrice;									//&#22996;&#25176;&#20215;&#26684;
int ticket,errId;
int curTrend=5;
int MyLots = 1;
int lastTradeType;
int expirationSec = 1800;               //&#36234;&#30028;&#31186;&#25968;


//&#23450;&#20041;&#34920;&#31034;&#36235;&#21183;&#24120;&#37327;
int TRENDBULL = 1;      //&#29275;&#24066;
int TRENDBEAR = -1;     //&#29066;&#24066;
int TRENDNO = 0;        //&#30424;&#25972;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
{
//---- TODO: Add your code here.

//----
    return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: Add your code here.

//----
    return(0);
}
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{
//---- TODO: Add your code here.
//----

    double MacdCurrent=0, MacdPrevious=0, SignalCurrent=0;
    double SignalPrevious=0, MaCurrent=0, MaPrevious=0;
    int cnt=0, total;

    //&#27599;&#20010;&#21608;&#26399;&#21482;&#26159;&#22788;&#29702;&#19968;&#27425;
    if(lastDealBars == Bars ) return(0);
    lastDealBars = Bars;

    Print("11 curTrend: ",curTrend);

    //&#26159;&#21542;&#22815;&#24050;&#32463;&#22810;&#30340;&#35745;&#31639;&#21608;&#26399;
    if (!isBarsCountEnough){
        if(Bars<(longestPeriod+longTrendKeepPeriod)) 
            return(0);
        else
            isBarsCountEnough = true;
    }

    if (OrdersTotal()<1)
    {
        Print("22 curTrend: ",curTrend);

        if(curTrend == TRENDBULL)
        {
            if(isAbove(shortestPeriod,longestPeriod,1) && isAbove(shorterPeriod,longestPeriod,1) && isAbove(longerPeriod,longestPeriod,1))
            {
                Print(" &#29275;&#24066;&#32487;&#32493; ");   
                return (0);
            }
            else
            {
                Print(" &#29275;&#24066;&#32467;&#26463; ");   
                curTrend = TRENDNO;
            }
        }
        else
        {
            Print("33 curTrend: ",curTrend);
            int curTrend = getTrend(longestPeriod,longTrendKeepPeriod,longTrendKeepRange*Point,1);
            
            //&#29275;&#24066;
            if (curTrend == TRENDBULL)
            {
                //&#33267;&#23569;&#26377;&#19968;&#26465;&#22343;&#32447;&#21521;&#19978;&#31359;&#36234;&#65292;&#24182;&#19988;&#25152;&#20197;&#22343;&#32447;&#22343;&#22788;&#20110;&#19978;&#26041;
                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);
}
//+------------------------------------------------------------------+



a part of log:

17:32:16 1999.11.10 12:15  FOLLOWTREND EURUSD,M15: 11 curTrend: 5
17:32:16 1999.11.10 12:15  FOLLOWTREND EURUSD,M15: 22 curTrend: 5
17:32:16 1999.11.10 12:15  FOLLOWTREND EURUSD,M15: 33 curTrend: 5
17:32:16 1999.11.10 12:15  FOLLOWTREND EURUSD,M15: **** begin bull trend ****
17:32:16 1999.11.10 12:15  FOLLOWTREND EURUSD,M15: 44 curTrend: 1
17:32:16 1999.11.10 12:30  FOLLOWTREND EURUSD,M15: 11 curTrend: 5
17:32:16 1999.11.10 12:30  FOLLOWTREND EURUSD,M15: 22 curTrend: 5
17:32:16 1999.11.10 12:30  FOLLOWTREND EURUSD,M15: 33 curTrend: 5
 
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
 
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
Reason: