forced to reload indicator to update - program flow trouble?

 

 Having trouble with this - it works - just doesn't update unless I kick it.

I hollowed out everything to show the flow - there was no special sauce, just if's and for's & assignments

and cannot show it but sure hope this layout will tip off the right person to what may be the trouble. 

 

I have to reload or recompile my custom indicator (or change timeframe) to show valid results.

The prints of dependant resulting variables show that after a new Get Global Variable on which

they depend for calculations they are not changing - even with new ticks coming in.

 

I have tried a test of new GV to call start() and WindowRedraw all over the place. 

Only doing one of those updating actions like reload indicator will show everything with the correct results

(in prints and in Labels on chart).

#property indicator_chart_window
#include <WinUser32.mqh>
#include <stdlib.mqh>
int init()
{
  Comment("");
  CheckBars = Bars-1;
  reinit(); // must be before spec_functionD();
  return(0);
}

void reinit()
{
  if(GlobalVariableGet("SM "+Symbol())==0) GlobalVariableSet("SM "+Symbol(), 1.0);
  SpM = GlobalVariableGet("SM "+Symbol());
  
  if(SpM == SpMLast) NewGlobalVariable = false; 
  else NewGlobalVariable = true; 
  SpMLast = SpM;

  if(SpM < sm_range_lo) {SpM = sm_range_lo;}
  else if(SpM > sm_range_hi) {SpM = sm_range_hi;} 

  spec_functionD();

}
//+-----------------------------------------------------------------------------------------------+
//+-----------------------------------------------------------------------------------------------+ +---+
//| EXPERT START spec_function                                                                    | | S |
//+-----------------------------------------------------------------------------------------------+ +---+
//+-----------------------------------------------------------------------------------------------+
int start()
{
  reinit();
  spec_functionE(); 
  CreateObjects(); 
  return(0);
}
//-------------------------------------------------------------------------------------------------
//  spec_functionD
//-------------------------------------------------------------------------------------------------
void spec_functionD()
{
  spec_functionA();
  spec_functionB();
  spec_functionC();
  ObjectDelete("str");
  ObjectCreate("str", ;
  ObjectSet("str",;
....
}
//-------------------------------------------------------------------------------------------------
//  spec_functionA - called only by spec_functionD()
//-------------------------------------------------------------------------------------------------
void spec_functionA()
{
.....
}
//-------------------------------------------------------------------------------------------------
//  spec_functionB - called only by spec_functionD()
//-------------------------------------------------------------------------------------------------
void spec_functionB()
{
....       
}
//-------------------------------------------------------------------------------------------------
//  spec_functionC- called only by spec_functionD()
//-------------------------------------------------------------------------------------------------
void spec_functionC()
{ 
.....
}
//-------------------------------------------------------------------------------------------------
//  spec_functionE
//-------------------------------------------------------------------------------------------------

void spec_functionE()
{
.... 
}
//-------------------------------------------------------------------------------------------------
//  CREATE OBJECTS
//-------------------------------------------------------------------------------------------------

int CreateObjects()
{
  ObjectDelete("str");  .....
tons of test calculations based on spec_functions variables
and creation of objects based on the results

}  // end of CreateObjects()


//-------------------------------------------------------------------------------------------------
//  OBJECT MAKE 
//-------------------------------------------------------------------------------------------------
int ObjectMakeLabel( string n, int window, int xoff, int yoff, bool back )
{
   ObjectCreate( n, OBJ_LABEL, window, 0, 0 );
   ObjectSet( n, OBJPROP_CORNER, 0 );
   ObjectSet( n, OBJPROP_XDISTANCE, xoff );
   ObjectSet( n, OBJPROP_YDISTANCE, yoff );
   ObjectSet( n, OBJPROP_BACK, false );
}

int deinit()
  {
  ...;
  return(0);
  }

 

 

Thanks in Advance

Already learned much here - so thanks in arrears too. 

 
nombanocondo:

Having trouble with this - it works - just doesn't update unless I kick it.

I hollowed out everything to show the flow - there was no special sauce, just if's and for's & assignments

I have to reload or recompile my custom indicator (or change timeframe) to show valid results.

The prints of dependant resulting variables show that after a new Get Global Variable on which they depend for calculations they are not changing - even with new ticks coming in.

I have tried a test of new GV to call start() and WindowRedraw all over the place.

Just for's and global variables that you don't show. No mind readers here. The code you show does nothing, so there is nothing to even guess at.

  1. Is this trying to limit SpM to a range

    if(SpM < sm_range_lo) {SpM = sm_range_lo;}
      else if(SpM > sm_range_hi) {SpM = sm_range_hi;} 
    
    or are you trying to enlarge the range?
  2. I assume SpMLast is global. This
    if(SpM == SpMLast) NewGlobalVariable = false; 
      else NewGlobalVariable = true; 
      SpMLast = SpM;
    
    can be simplified as
    NewGlobalVariable = (SpM != SpMLast);
      SpMLast = SpM;

 
WHRoeder:

Just for's and global variables that you don't show. No mind readers here. The code you show does nothing, so there is nothing to even guess at.

  1. Is this trying to limit SpM to a range

    or are you trying to enlarge the range?
  2. I assume SpMLast is global. Thiscan be simplified as


WHRoeder, Thank you for taking your time to check this. I thought perhaps that it may

be fruitless to give just the layout but that maybe someone with more experience might

just spot an obvious mistake.

 

Yes the SpM was being limited to a range. Thanks for that shortening method tip as well.

 

There does not happen to be a way to stimulate the terminal to update status of

external variables without reloading indicator or without user action, such as an

indicator command (aside from an EA), does there ?

 

Your answer did give me an idea on how to approach the problem. Thanks once again. 

Reason: