stevehopwoodforex.com
https://www.stevehopwoodforex.com/phpBB3/
Print view

Values of ibands vs bands on chart different !!
https://www.stevehopwoodforex.com/phpBB3/viewtopic.php?t=5210
Page 1 of 1
Author:  lwtrade [ Fri Jun 30, 2017 11:16 pm ]
Post subject:  Values of ibands vs bands on chart different !!

Hey everyone, I just need a more expert eye over this please...

I am printing a dot on the chart to illustrate the offset issue...
2017-07-01 10_38_47-Greenshot.png
You can see where the arrow is highlighting... the first number in the object name is correct, but then the actual price it uses is different!!!! Grrrr!!!

Any thoughts?


In troubleshooting I tried:
This is not just a printing to chart issue as the values ARE actually different (see circled values in image)
Tried about 4 different bands indicators which all produce the same lines, obviously)
Tried iCustom with Bands indi which also produced different values to chart indi's
These value differences range in value. ie not just 100 different for each bar
Values are not returning for the wrong bar... it is value to bar accurate

Here is the code I am using for iBands:

Code: Select all

iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,i);
The print to chart function:

Code: Select all

void DrawDot(int barr, double price)   {  
   string objName = objPrefix + barr + " " + price;
   ObjectCreate(objName, OBJ_TEXT, 0, Time[barr], price);
   ObjectSetText(objName, CharToStr(159), 24, "Wingdings", Red); 
}


the entire indi:

Code: Select all

#property indicator_chart_window 
string objPrefix = "printBB_";
int init()
  {
   for (int i=1;i<100;i++){
      DrawDot(i,iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,i));
   }
   return(0);
  }
  
int deinit(){
   deleteObjects();
   return(0);
   }

int start() {
   if (IsNewBar()) DrawDot(1,iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,1));;
}

void DrawDot(int barr, double price)   {  
   string objName = objPrefix + barr + " " + price;
   ObjectCreate(objName, OBJ_TEXT, 0, Time[barr], price);
   ObjectSetText(objName, CharToStr(159), 24, "Wingdings", Red); 
}
      
bool IsNewBar()   {
   static datetime lastbar;
   datetime curbar = Time[0];
   if(lastbar!=curbar){
      lastbar=curbar;
      return (true);
      }
   else{
      return(false);
      }
}

void deleteObjects(){
   for(int i=ObjectsTotal();i >= 0;i--){
      if(StringSubstr(ObjectName(i),0,StringLen(objPrefix))==objPrefix) 
         ObjectDelete(ObjectName(i));    
   }  
}
Author:  renexxxx [ Sat Jul 01, 2017 12:12 am ]
Post subject:  Values of ibands vs bands on chart different !!

You have to set the anchor point of your dot objects in the center, like so:

Code: Select all

        void DrawDot(int barr, double price)   {  
           string objName = objPrefix + barr + " " + price;
           ObjectCreate(objName, OBJ_TEXT, 0, Time[barr], price);
           ObjectSetText(objName, CharToStr(159), 24, "Wingdings", Red);
           ObjectSetInteger( ChartID(), objName, OBJPROP_ANCHOR, ANCHOR_CENTER );
        }
Cheers ...
Author:  lwtrade [ Sat Jul 01, 2017 12:40 am ]
Post subject:  Values of ibands vs bands on chart different !!

Oh Renexxxx,

That fixed it!!!! I had this issue last year as well!

Thanks a million times! :clap: :clap: :clap: :clap:
All times are UTC Page 1 of 1