some questions about adding text by "A" on K line chart and time counting. - page 3

 
WHRoeder:
  1. RaptorUK's added code that you were supposed to try. You hadn't. vx0532 posted the result for you. Did you bother to read and understand either post?
  2. What part of "Only externals are reset" was unclear?


What the hell is the matter with you!

You quoted my post and added code that was not mine.

I am not the OP, so why am I supposed to try Raptor's code

Yes I bothered to read and understand the posts

Nothing about "only externals are reset" is unclear

My post was

"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."

No code at all!

 

Ok, not quarrel whatever, since it benefit nobody and nothing. All of us come here to enhance our skill of using MT4 and help each other.

I don't know whether externals, globalscope and statics will be reset in an indicator when changing timeframe, but I think it deserve to confirm by some tests(I will, but now trading close, and I can't use "tester" well. so tomorrow I will test ).

In addition, now I know how to let us set variables' value when EA is being attached like B and the variables can never been changed when shift time frame like in A; and I write the code as C:

C:

bool isFirst = true;
extern datetime  time_current_0;
datetime time_current_1=time_current_0; 

A:

bool isFirst = true;
datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }

B:

extern bool isFirst = true;
extern datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }


 

GumRai:

I am not the OP, so why am I supposed to try Raptor's code

"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."

  1. I'm not going to go back 3 pages and check. I assumed, sorry.
  2. You said "Just to be clear" looked like you agreed with me, then in another paragraph (another thought) say something different looking like you disagreed. Learn to use highlighting correctly. Had you posted something like:
    Just to be clear,
    • Changing timeframes in an EA resets externals but not globalscope/statics.
    • But in an indicator,Changing timeframes resets externals, and globalscope and statics."
    It would have been clear.
 
WHRoeder:
  1. I'm not going to go back 3 pages and check. I assumed, sorry.
  2. You said "Just to be clear" looked like you agreed with me, then in another paragraph (another thought) say something different looking like you disagreed. Learn to use highlighting correctly. Had you posted something like:
    Just to be clear,
    • Changing timeframes in an EA resets externals but not globalscope/statics.
    • But in an indicator,Changing timeframes resets externals, and globalscope and statics."
    It would have been clear.


You may not realise that your sarcastic posting style, using phrases such as "What part of "Only externals are reset" was unclear?", "RTFM" and "Did you miss.....?" can get people's backs up.

You are an extremely talented and knowledgeable person and I understand that it can be irritating when so many people post nonsense. But do you really need to be so condescending?

That is a good idea about using bolding/highlighting to make a statement clearer, I will try to remember that in future, thank you.

 
#property indicator_chart_window
//--- input parameters
extern int       Count=0;
int GCount;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   
//----
   static int SCount;
   Print("SCount = ",SCount,", Count = ",Count,", GCount = ",GCount);
   SCount++;
   Count++;
   GCount++;
//----
   return(0);
  }
//+------------------------------------------------------------------+

The above code in an indicator results in

As you can see, changing tf in an indicator will reset extern, globalscope and static variables, but the same code in an EA will only reset the extern variable

 
vx0532:


In addition, now I know how to let us set variables' value when EA is being attached like B and the variables can never been changed when shift time frame like in A; and I write the code as C:


C:

bool isFirst = true;
extern datetime  time_current_0;
datetime time_current_1=time_current_0; 

A:

bool isFirst = true;
datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }

B:

extern bool isFirst = true;
extern datetime  time_current;
int init(){
   if(isFirst) 
   { isFirst = false; 
    time_current=TimeCurrent();
    }


in the fact, i just test the code "C", and it can't run and have some errors.
So the problem is still  there, How 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?
Reason: