Point Value wrong when adding Indicator from Template

 
I guess I found a detail about the wrong point value that makes it reproduceable

1) Add an Indicator to a chart with Point = 0.0001 (EURUSD)
2) Save template
3) Switch to a JPY chart
4) Apply Template

Point value for the indicator will be wrong. Also works the other way round (storing from JPY and applying to other chart). It will correct itself if the timeframe is switched on the chart. Looks like there's something about the point value stored in the chart template.


Markus
 
MetaQuotes please ...
 
sample of indicator please. we cannot reproduce your problem
 
Indicator name "SDX-Bunnygirl"

- Open plain GBPUSD/M30
- Attach SDX-Bunnygirl
- Template, Save-As, 0-Test (done via Toolbar)
- Open plain EURJPY/M30
- Select 0-Test template (via Toolbar)

Output (Build 184, Oct. 24)


14:00:08 SDX-Bunnygirl GBPUSD,M30: Cross of WMA with a EntryFilterPips of 30 pips (Point= 0.0001).
14:00:08 SDX-Bunnygirl GBPUSD,M30: Only shows buy/sell EntryFilterPipss from 8 to 19 hours (chart time).
14:00:08 SDX-Bunnygirl GBPUSD,M30: initialized
14:00:31 SDX-Bunnygirl EURJPY,M30: loaded successfully
14:00:31 SDX-Bunnygirl EURJPY,M30: Cross of WMA with a EntryFilterPips of 30 pips (Point= 0.0001).
14:00:31 SDX-Bunnygirl EURJPY,M30: Only shows buy/sell EntryFilterPipss from 8 to 19 hours (chart time).



//+------------------------------------------------------------------+
//| Bunnygirl.mq4                                                    |
//| Shimoday (based on BunnygirlCross by David W Thomas)             |
//| System: http://www.rivetworks.com/www/misc/BGX2-0-hires.pdf      |
//+------------------------------------------------------------------+
#property copyright "Shimodax based on work by David W. Thomas"
#property link      "http://www.strategybuilderfx.com/forums/showthread.php?t=7916"

#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 CornflowerBlue   // today's open
#property indicator_color2 LightSkyBlue     // Cross Level (for setting SL)
#property indicator_color3 CornflowerBlue   // EntryFilter 
#property indicator_color4 CornflowerBlue   // EntryFilter (not used)
#property indicator_color5 LightCyan        // Cross Marker (Symbol)
#property indicator_color6 LightSkyBlue     // Entry Signal (Symbol)
#property indicator_color7 CornflowerBlue   // LWMA 5
#property indicator_color8 CornflowerBlue   // LWMA 20



#define CROSSTYPE_LONG 1
#define CROSSTYPE_SHORT -1


//---- input parameters
extern bool DoEntryAlerts= false;
extern int PipsForBounce= 3;
extern int TimeZoneOfData= 2;
extern bool FilterTradingTime= true;
extern bool ShowDailyOpenLevel= false;
extern bool ShowComment= false;


//---- hidden inputs
int MA_Method= MODE_LWMA;


//---- buffers
double TodayOpenBuffer[];
double CrossBounceBuffer[];
double EntryFilterBuffer[];
double EntryFilterBuffer2[];
double EntrySignalsBuffer[];
double CrossSignalsBuffer[];
double WMA5Buffer[];
double WMA20Buffer[];
// double WMA100Buffer[];

//---- variables

string TypeStrMA = "";

double EntryFilterPips = 0;
		

int TimeFilterStart = 0;
int TimeFilterEnd = 24;


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   //---- indicators
	SetIndexStyle(0, DRAW_LINE, STYLE_DASH, 2);
	SetIndexBuffer(0, TodayOpenBuffer);
	SetIndexLabel(0, "Daily Open");
	SetIndexEmptyValue(0, 0.0);
	
	SetIndexStyle(1, DRAW_ARROW);
	SetIndexBuffer(1, CrossBounceBuffer);
	SetIndexLabel(1, "Cross/Bounce");
	SetIndexArrow(1,250);
	SetIndexEmptyValue(1, 0.0);
	
	SetIndexStyle(2, DRAW_LINE, STYLE_DOT);
	SetIndexBuffer(2, EntryFilterBuffer);
	SetIndexLabel(2, "Buy EntryFilterPips");
	SetIndexEmptyValue(2, 0.0);
	
	SetIndexStyle(3, DRAW_LINE, STYLE_DOT);
	SetIndexBuffer(3, EntryFilterBuffer2);
	SetIndexLabel(3, "Sell EntryFilterPips");
	SetIndexEmptyValue(3, 0.0);

	SetIndexStyle(4, DRAW_ARROW);
	SetIndexArrow(4, 250);
	SetIndexBuffer(4, CrossSignalsBuffer);
	SetIndexLabel(4, "Bunnygirl Entry Signal");
	SetIndexEmptyValue(4, 0.0);

	SetIndexStyle(5, DRAW_ARROW);
	SetIndexArrow(5, 162);
	SetIndexBuffer(5, EntrySignalsBuffer);
	SetIndexLabel(5, "Bunnygirl Cross");
	SetIndexEmptyValue(5, 0.0);
	
	SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1);
	SetIndexBuffer(6, WMA5Buffer);
	SetIndexLabel(6, "30min. WMA5");
	SetIndexEmptyValue(6, 0.0);	  

	SetIndexStyle(7, DRAW_LINE, STYLE_DOT, 1);
	SetIndexBuffer(7, WMA20Buffer);
	SetIndexLabel(7, "30min. WMA20");
   SetIndexEmptyValue(7, 0.0);	  
	


		
		
	if (Symbol() == "EURUSD")
		EntryFilterPips = 25 * Point;
	else
		EntryFilterPips = 30 * Point;
		
	if (MA_Method == MODE_EMA)
		TypeStrMA = "EMA";
	else
		TypeStrMA = "WMA";
		
	Print(" Cross of ", TypeStrMA, " with a EntryFilterPips of ", EntryFilterPips/Point, " pips (Point= ", Point, ").");
	if (FilterTradingTime) {
		TimeFilterStart = 6 + TimeZoneOfData;
		TimeFilterEnd = 17 + TimeZoneOfData;
      Print(" Only shows buy/sell EntryFilterPipss from ", TimeFilterStart, " to ", TimeFilterEnd, " hours (chart time).");
	}
	else {
		TimeFilterStart = 0;
		TimeFilterEnd = 24;
		Print(" Show buy/sell EntryFilterPipss at all times.");
	}

	return(0);
}


//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{

	return(0);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int counted_bars= IndicatorCounted(),
         lastbar;

   if (counted_bars>0)
      counted_bars--;
      
   lastbar= Bars- counted_bars;	


   //
   // Compute Crosses
   //
   Bunnygirl(0, lastbar);
   
   
   
   //
   // check alerts   
   //
   static datetime lastalerttime;
   static double lastalertprice;

   if (DoEntryAlerts && lastalerttime!=Time[0] && EntrySignalsBuffer[0]!=0 && EntrySignalsBuffer[0]!=lastalertprice) {
      Alert("Range breakout!");
      lastalerttime= Time[0];
      lastalertprice= EntrySignalsBuffer[0];
   } 
   else {
      lastalerttime= 0;
      lastalertprice= 0.0;
   }
   
   
   return (0);
}
	   


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int Bunnygirl(int offset, int lastbar)
{
   static datetime timelastcross = 0;
   static int crosstype= CROSSTYPE_LONG;   // LONG
   static double crosslevel= 0;

	string crossdirstr = "";

   int idxcross= 0, 
         tzdiffsec= TimeZoneOfData * 3600,
         shift, idxline;
   
	double ma20p, ma20p1, ma20p2,
	       ma5p, ma5p1, ma5p2,
	       ma100p,
			 diff0, diff1, diff2,
          tz, exactcross,
          barsper30= 1.0*PERIOD_M30/Period(),
          barsperday= PERIOD_D1/Period(),
          deltatime= 2.0; // computed beween bar shift and shift+2	
          
   // lastbar+= barsperday+2;  // make sure we catch the daily open		 

   lastbar= MathMin(Bars-20*barsper30-1, lastbar);

	for (shift= lastbar; shift>=offset; shift--) {
	
		TodayOpenBuffer[shift]= 0;
		CrossBounceBuffer[shift]= 0;
		EntryFilterBuffer[shift]= 0;
		EntrySignalsBuffer[shift]= 0;
		CrossSignalsBuffer[shift]= 0;
		

      if (ShowDailyOpenLevel) {

         if (TimeDayOfWeek(Time[shift]-tzdiffsec) != TimeDayOfWeek(Time[shift+1]-tzdiffsec)) { // day change
            TodayOpenBuffer[shift]= Open[shift];         
            TodayOpenBuffer[shift+1]= 0;  // avoid stairs in the line
         }
         else {
            TodayOpenBuffer[shift]= TodayOpenBuffer[shift+1];
         }
		}
		
		if (0 && Symbol()=="GBPUSD") Print("x");
		
      ma5p= iMA(NULL,0,   5*barsper30, 0, MA_Method, PRICE_CLOSE,  shift);
      ma5p1= iMA(NULL,0,  5*barsper30, 0, MA_Method, PRICE_CLOSE,  shift+1);
      ma5p2= iMA(NULL,0,  5*barsper30, 0, MA_Method, PRICE_CLOSE,  shift+2);
      
      ma20p= iMA(NULL,0,   20*barsper30, 0, MA_Method, PRICE_CLOSE,  shift);
      ma20p1= iMA(NULL,0,  20*barsper30, 0, MA_Method, PRICE_CLOSE,  shift+1);
      ma20p2= iMA(NULL,0,  20*barsper30, 0, MA_Method, PRICE_CLOSE,  shift+2);
      
      // ma100p= iMA(NULL,0,   100*barsper30, 0, MA_Method, PRICE_CLOSE,  shift);
      
      diff0= ma5p - ma20p;
      diff1= ma5p1 - ma20p1;
      diff2= ma5p2 - ma20p2;
      
      if (0 && Symbol()=="GBPUSD") {
         Print("x", shift, ":",  ma5p, ", ", ma5p2);
      }
      
      WMA5Buffer[shift]= ma5p;
      WMA20Buffer[shift]= ma20p;
      // WMA100Buffer[shift]= ma100p;

      idxcross= 0;
      deltatime= 2.0; // computed beween bar shift and shift+2
      
      // equate ma5p2 + tz * deltaprice5 = ma20p2 + tz * deltaprice20
      tz= (ma20p2 - ma5p2) * deltatime / ((ma5p - ma5p2) - (ma20p - ma20p2));
      exactcross= ma5p2 + tz * (ma5p - ma5p2) / deltatime;
      

      if (tz>=0.0 && tz<=deltatime) {   // cross within the time segment of the two samples
         idxcross= shift+2-MathRound(tz);
         if (diff0 > 0) 
            crosstype= CROSSTYPE_LONG;
         else
            crosstype= CROSSTYPE_SHORT;
            
         crosslevel= exactcross;
      }
      else {   // check bounce
		   // bull bounce signals:
		   if (diff0>0 && diff1>0 && diff2>diff1 && diff0>=diff1 && diff1<=PipsForBounce*Point) {
		      idxcross= shift+1;
			   crosstype= CROSSTYPE_LONG;
			   crosslevel = ma20p1;
		   }

		   // bear bounce signals:
		   if (diff0<0 && diff1<0 && diff2<diff1 && diff0<=diff1 && MathAbs(diff1)<=PipsForBounce*Point) {
            idxcross= shift+1;
			   crosstype= CROSSTYPE_SHORT;
			   crosslevel = ma20p1;
		   }
      }

		if (idxcross!=0) {
		   timelastcross= Time[idxcross];
		   CrossSignalsBuffer[idxcross]= crosslevel;
		}
		else {
         idxline= shift;   		     
		}
		      
		/*
		CrossBounceBuffer[shift] = crosslevel;
		
		if (idxcross!=0) {
		   CrossBounceBuffer[idxcross]= crosslevel;  
		   if (CrossBounceBuffer[idxcross+1]!=crosslevel)
		      CrossBounceBuffer[idxcross+1]= 0;   
		}
      */

		if (TimeHour(Time[shift])>=TimeFilterStart && TimeHour(Time[shift])<=TimeFilterEnd) {

         double entryfilter= 0;		

         if (crosstype==CROSSTYPE_LONG) {

            entryfilter= crosslevel + crosstype*EntryFilterPips /* + Ask - Bid */;

            if (CheckSignal(shift, entryfilter, OP_BUY, EntrySignalsBuffer)) {
              CrossBounceBuffer[shift]= crosslevel;
            }
         }
         else 
         if (crosstype==CROSSTYPE_SHORT) {
            entryfilter= crosslevel + crosstype*EntryFilterPips;

            if (CheckSignal(shift, entryfilter, OP_SELL, EntrySignalsBuffer)) {
              CrossBounceBuffer[shift]= crosslevel;
            }
         }
         
         if (entryfilter!=0) 
            EntryFilterBuffer[shift]= entryfilter;
		}
	}

   if (ShowComment) {
	   if (crosstype==CROSSTYPE_LONG)
		   crossdirstr= "bull";
	   else
      if (crosstype==CROSSTYPE_SHORT) 
		   crossdirstr= "bear";

	   if (timelastcross!=0)  
		   Comment("Last ", TypeStrMA, " cross/bounce: ", TimeToStr(timelastcross), ", ", crossdirstr, " at ", DoubleToStr(crosslevel,Digits));
	   else
		   Comment("Last ", TypeStrMA, " cross/bounce: ", crossdirstr, " at ", DoubleToStr(crosslevel,Digits));
   }	
   
	return(0);
}




//+------------------------------------------------------------------+
//| Check price break                                                |
//+------------------------------------------------------------------+
bool CheckSignal(int shift, double price, int type, double &signalbuffer[]) 
{
   bool signal= false;

   if (type==OP_BUY && ((Open[shift]<price && High[shift]>price) || (Close[shift+1]<price && Open[shift]>price))) {
      signalbuffer[shift]= price;
      signal= true;
  }

   if (type==OP_SELL && ((Open[shift]>price && Low[shift]<price) || (Close[shift+1]>price && Open[shift]<price))) {
      signalbuffer[shift]= price;
      signal= true;
  }
  
  return (signal);
}
 
btw, I have that indicator on multiple charts at the same time, i.e. it already resides on a couple of JPY and non JPY charts when this sequence of operations is performed. Also, I leave the first chart (GPBUSD in the sample) open when adding the EURJPY.



Markus
 
Still open.
 
Definitely a bug. See my other post.

Markus
 
fixed. wait for next build
Reason: