help code please - page 2

 
thank you very much for your willingness to share your skills and with us.
soon as I had many questions :-)
Good evening (or good day if you are in the USA)
friendly
 
phenix77:
thank you very much for your willingness to share your skills and with us.
soon as I had many questions :-)
Good evening (or good day if you are in the USA)
friendly

Good afternoon,  I'm in the UK  :-)

You are welcome,  I learn by trying to help other people . . .  it's the best way. 

 

hello all.
I followed the recommendations RaptorUK.

Code 1 is the one that works on the current chart I made as an example GBPUSD.

Code 2 is modified so that it works is whatever the chosen pair.

in the code as I took two GBPUSD so I should have the same information as the one put code on a chart GBPUSD.

Unfortunately this is not the case when the signal is buy it seems correct code 1 and code 2 give the

same results but in a sell signal they do not give the same results code 2 gives results which are necessary and vary

functions during short sell signal known value changes all the time what is wrong and this is not the case in the code 1.
So can you tell me where is my mistake?
thank you for your help.
cordially

 

 code 1


//---- indicator settings
//#property  indicator_separate_window
#property indicator_chart_window
#property  indicator_buffers      8
#property  indicator_color1       DarkOrange
#property  indicator_width1       2
 
double cloture;
//---- indicator parameters
extern string     __Copyright__               = "http://jjnewark.atw.hu";
extern color      BuyColor                    = YellowGreen;
extern color      SellColor                   = OrangeRed;
extern color      FontColor                   = Black;
extern int        DisplayDecimals             = 4;
extern int        PosX                        = 10;
extern int        PosY                        = 20;

//---- indicator buffers
double     MainVal[];
 
double ValSum[];
 
 
double Vals[8];
double ValSumTemp;
int per[]={5,8,13,21,34,55,89,144};
 
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  // IndicatorBuffers(8);
   SetIndexStyle(4,DRAW_SECTION);
   SetIndexBuffer(4,MainVal);
   SetIndexBuffer(5,ValSum);
      
   SetIndexLabel(4,"MainVal");
   
   ObjectCreate("NuggetIndName",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetIndName",OBJPROP_CORNER,0);
   ObjectSet("NuggetIndName",OBJPROP_XDISTANCE,PosX+12);
   ObjectSet("NuggetIndName",OBJPROP_YDISTANCE,PosY);
   ObjectSetText("NuggetIndName","JJN-Nugget",8,"Lucida Sans Unicode",FontColor);
   
   ObjectCreate("NuggetLine0",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine0",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine0",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine0",OBJPROP_YDISTANCE,PosY+8);
   ObjectSetText("NuggetLine0","------------------",8,"Tahoma",FontColor);
   
   ObjectCreate("NuggetLine1",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine1",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine1",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine1",OBJPROP_YDISTANCE,PosY+10);
   ObjectSetText("NuggetLine1","------------------",8,"Tahoma",FontColor);
    
   ObjectCreate("NuggetDirection",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetDirection",OBJPROP_CORNER,0);
   ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetDirection",OBJPROP_YDISTANCE,PosY+12);
   ObjectSetText("NuggetDirection","Wait ...",28,"Lucida Sans Unicode",FontColor);   
   
   ObjectCreate("NuggetLevel",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLevel",OBJPROP_CORNER,0);
   ObjectSet("NuggetLevel",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetLevel",OBJPROP_YDISTANCE,PosY+50);
   ObjectSetText("NuggetLevel","  -----  ",9,"Lucida Sans Unicode",FontColor);
//---- 
 //  IndicatorShortName("JJN-Nugget");
   
   
//---- initialization done
   return(0);
  }
 
int deinit()
  {
//----
   ObjectDelete("NuggetLine0");
   ObjectDelete("NuggetLine1");
   ObjectDelete("NuggetIndName");
   ObjectDelete("NuggetDirection");
   ObjectDelete("NuggetLevel");
      
//----
   return(0);
  }
 
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
 
   for(int i=0; i<limit; i++)
   {
      for(int j=0; j<8; j++)
      {
      Vals[j]=iMA(NULL,0,per[j],0,MODE_EMA,PRICE_CLOSE,i);
      }
   
      ValSumTemp=0;
      for(int k=0; k<8; k++)
      {
      ValSumTemp+=Vals[k];
      }
      ValSum[i]=ValSumTemp/8;
   }
   
   //*******************************************************************
   for(i=0; i<limit; i++)
   {
   if(ValSum[i]>(High[i]+Low[i])/2 && ValSum[i+1]<(High[i+1]+Low[i+1])/2) 
      { 
      MainVal[i]=High[i]; 
      }
   else if(ValSum[i]<(High[i]+Low[i])/2 && ValSum[i+1]>(High[i+1]+Low[i+1])/2) 
      {
      MainVal[i]=Low[i];
      }
   else MainVal[i]=EMPTY_VALUE;
   }
   
   double lastprice=0;
 
   int found=0;
   int w=0;
      
      while(found<1)
      {
         if(MainVal[w]!=EMPTY_VALUE)
         {
            lastprice=MainVal[w];
            found++;
         }
         w++;
      }
     
     cloture=Close[0];   
        
    if(ValSum[0]<(High[0]+Low[0])/2)
    { 
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+5);
    ObjectSetText("NuggetDirection","BUY",28,"Lucida Sans Unicode",BuyColor); 
    ObjectSetText("NuggetLevel","above "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",BuyColor);

    }
    else if(ValSum[0]>(High[0]+Low[0])/2)
    {
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+2);
    ObjectSetText("NuggetDirection","SELL",28,"Lucida Sans Unicode",SellColor); 
    ObjectSetText("NuggetLevel","under "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",SellColor); 
    }
    
   
   return(0);
  }


//*******************************************************
//*******************************************************
 

CODE 2

 

 

CODE 2


#property indicator_chart_window
#property  indicator_buffers      8
#property  indicator_color1       DarkOrange
#property  indicator_width1       2
 
extern string symbole_trade="GBPUSD";

//---- indicator parameters
extern string     __Copyright__               = "http://jjnewark.atw.hu";
extern color      BuyColor                    = YellowGreen;
extern color      SellColor                   = OrangeRed;
extern color      FontColor                   = Black;
extern int        DisplayDecimals             = 4;
extern int        PosX                        = 10;
extern int        PosY                        = 20;
 
double     MainVal[];
 
double ValSum[];
double lastprice=0;
double cloture=0;

 
double Vals[8];
double ValSumTemp;
int per[]={5,8,13,21,34,55,89,144};
 
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
  
  // IndicatorBuffers(8);
   SetIndexStyle(4,DRAW_SECTION);
   SetIndexBuffer(4,MainVal);
   SetIndexBuffer(5,ValSum);
      
   SetIndexLabel(4,"MainVal");
   
   ObjectCreate("NuggetIndName",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetIndName",OBJPROP_CORNER,0);
   ObjectSet("NuggetIndName",OBJPROP_XDISTANCE,PosX+12);
   ObjectSet("NuggetIndName",OBJPROP_YDISTANCE,PosY);
   ObjectSetText("NuggetIndName","JJN-Nugget",8,"Lucida Sans Unicode",FontColor);
   
   ObjectCreate("NuggetLine0",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine0",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine0",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine0",OBJPROP_YDISTANCE,PosY+8);
   ObjectSetText("NuggetLine0","------------------",8,"Tahoma",FontColor);
   
   ObjectCreate("NuggetLine1",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLine1",OBJPROP_CORNER,0);
   ObjectSet("NuggetLine1",OBJPROP_XDISTANCE,PosX+5);
   ObjectSet("NuggetLine1",OBJPROP_YDISTANCE,PosY+10);
   ObjectSetText("NuggetLine1","------------------",8,"Tahoma",FontColor);
    
   ObjectCreate("NuggetDirection",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetDirection",OBJPROP_CORNER,0);
   ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetDirection",OBJPROP_YDISTANCE,PosY+12);
   ObjectSetText("NuggetDirection","Wait ...",28,"Lucida Sans Unicode",FontColor);   
   
   ObjectCreate("NuggetLevel",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("NuggetLevel",OBJPROP_CORNER,0);
   ObjectSet("NuggetLevel",OBJPROP_XDISTANCE,PosX);
   ObjectSet("NuggetLevel",OBJPROP_YDISTANCE,PosY+50);
   ObjectSetText("NuggetLevel","  -----  ",9,"Lucida Sans Unicode",FontColor);
//---- 
 //  IndicatorShortName("JJN-Nugget");
   
   
//---- initialization done
   return(0);
  }
 
int deinit()
  {
//----
   ObjectDelete("NuggetLine0");
   ObjectDelete("NuggetLine1");
   ObjectDelete("NuggetIndName");
   ObjectDelete("NuggetDirection");
   ObjectDelete("NuggetLevel");
      
//----
   return(0);
  }
 
int start()
  {
   
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
 
   for(int i=0; i<limit; i++)
   {
      for(int j=0; j<8; j++)
      {
      Vals[j]=iMA(symbole_trade,0,per[j],0,MODE_EMA,PRICE_CLOSE,i);
      }
   
      ValSumTemp=0;
      for(int k=0; k<8; k++)
      {
      ValSumTemp+=Vals[k];
      }
      ValSum[i]=ValSumTemp/8;
   }
   
   //***********************************************************************
  
   for(i=0; i<limit; i++)
   {
   if(ValSum[i]>(iHigh(symbole_trade, 0, i)+iLow(symbole_trade, 0, i))/2 && ValSum[i+1]<(iHigh(symbole_trade, 0, i+1)+iLow(symbole_trade, 0, i+1))) 
      { 
      MainVal[i]=iHigh(symbole_trade, 0, i); 
      }
   else if(ValSum[i]<(iHigh(symbole_trade, 0, i)+iLow(symbole_trade, 0, i))/2  && ValSum[i+1]>(iHigh(symbole_trade, 0, i+1)+iLow(symbole_trade, 0, i+1))) 
      {
      MainVal[i]=iLow(symbole_trade, 0, i);
      }
   else MainVal[i]=EMPTY_VALUE;
   }
   
   double lastprice=0;
 
   int found=0;
   int w=0;
      
      while(found<1)
      {
         if(MainVal[w]!=EMPTY_VALUE)
         {
            lastprice=MainVal[w];
            found++;
         }
         w++;
      }
   cloture=iClose(symbole_trade, 0, 0);          
        
    if(ValSum[0]<(iHigh(symbole_trade, 0, 0)+iLow(symbole_trade, 0, 0))/2)
    { 
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+5);
    ObjectSetText("NuggetDirection","BUY",28,"Lucida Sans Unicode",BuyColor); 
    ObjectSetText("NuggetLevel","above "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",BuyColor);

    }
    else if(ValSum[0]>(iHigh(symbole_trade, 0, 0)+iLow(symbole_trade, 0, 0))/2)
    {
    ObjectSet("NuggetDirection",OBJPROP_XDISTANCE,PosX+2);
    ObjectSetText("NuggetDirection","SELL",28,"Lucida Sans Unicode",SellColor); 
    ObjectSetText("NuggetLevel","under "+DoubleToStr(lastprice,DisplayDecimals),9,"Lucida Sans Unicode",SellColor); 
    }
   
   return(0);
   
  }
//+--------------------
 
phenix77:

Here is a piece of code, this code only works on the pair lying on the graph.
but I need it to work on any pair.

The question is why? Just open another chart with another pair and put it on the new chart. Done.
 
I'm not sure to understand the translation of google translate.
but I try to put on another pair table and there is a gap with version 2 and when the signal is always sell.
and I do not know why it works for buy signals and not for sell.
thank you for your help.