Re: Coding Help

#461
salexes wrote:
Thu Aug 03, 2017 3:30 am
I have a strange problem regarding rounding numbers.

I was using the Buy Sell Volume V 1.0 indicator via iCustom but now I wanted to integrate it directly into my indicator.... So I did that.
Below you will find the sourcecode of the indicator and my integration into my indicator.

Here is a picture of the strange rounding:
If I round it via NormalizeDouble it Roundsup 76.5 to 77.0 and 25.5 to 26.
Why are the values different ?
What do I need to do to get the exact same values? ("Note: I can not use IndicatorDigits(0); because for the other buffers i do need the numbers behind the . )

BuySellVolume SourceCode:

Code: Select all

//+-------------------------------------------------------------------+
//|                                        Buy_Sell_Volumes_v1.0.mq4  |
//|                                            Copyright © 2013, Pip  |
//|                                    http://www.pricemasterpro.com  |
//| This indicator is for personal use only.                          |
//| Please respect the intellectual rights of the original programmer |
//| and the work of others that contributed to this indicator         |
//| under no circumstances is this indicator to be sold for money or  |
//| to be repackged into a commercial package or to be distributed as |
//| original work by anyone else.                                     |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2013, Pip; admin@pricemasterpro.com"
#property link      "http://www.pricemasterpro.com/"
//---- indicator settings
#property  indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 6
#property indicator_color1  White
#property indicator_color2  White
#property indicator_color3  Red
#property indicator_color4  Red
#property indicator_color5  Green
#property indicator_color6  Green
#property indicator_width1  1
#property indicator_width2  1
#property indicator_width3  1
#property indicator_width4  1
#property indicator_width5  1
#property indicator_width6  1
//---- indicator buffers
double ExtVolumesBufferHisto[];
double ExtVolumesBufferLine[];
double ExtVolumesUpBufferHisto[];
double ExtVolumesUpBufferLine[];
double ExtVolumesDownBufferHisto[];
double ExtVolumesDownBufferLine[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtVolumesBufferHisto);       
   SetIndexBuffer(1,ExtVolumesBufferLine);
   SetIndexBuffer(2,ExtVolumesUpBufferHisto);
   SetIndexBuffer(3,ExtVolumesUpBufferLine);       
   SetIndexBuffer(4,ExtVolumesDownBufferHisto);
   SetIndexBuffer(5,ExtVolumesDownBufferLine);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexStyle(5,DRAW_LINE);
//---- sets default precision format for indicators visualization
   IndicatorDigits(0);   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Buy_Sell Volume Pressure");
   SetIndexLabel(0,"Total Volume");      
   SetIndexLabel(1,"Buy Volume");
   SetIndexLabel(2,"Sell Volume");
//---- sets drawing line empty value
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(3,0.0); 
   SetIndexEmptyValue(5,0.0);      
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Volumes                                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
   if(nCountedBars>0) nCountedBars--;
   nLimit=Bars-nCountedBars;
//----
   for(i=0; i<nLimit; i++)
     {
    double bullp   = MathAbs(iBullsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double bearp   = MathAbs(iBearsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double vol     = iVolume(Symbol(), 0, i);
    double Buyers  = (bullp * vol) / MathMax((bullp + bearp),0.000001);
    double Sellers = (bearp * vol) / MathMax((bullp + bearp),0.000001);
   
         ExtVolumesBufferHisto[i]=vol;
         ExtVolumesBufferLine[i]=vol;
         ExtVolumesUpBufferHisto[i]=Buyers;
         ExtVolumesUpBufferLine[i]=Buyers;
         ExtVolumesDownBufferHisto[i]=Sellers; 
         ExtVolumesDownBufferLine[i]=Sellers;       
     
     }        
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

The calculation is exactly the same:

Code: Select all

int BuySellVolume(int offset, int limit){
   for(int i=offset; i<limit; i++)
     {
    double bullp   = MathAbs(iBullsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double bearp   = MathAbs(iBearsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double vol     = iVolume(Symbol(), 0, i);
    double Buyers  = (bullp * vol) / MathMax((bullp + bearp),0.000001);
    double Sellers = (bearp * vol) / MathMax((bullp + bearp),0.000001);
   
         ExtVolumesBufferHisto[i]=NormalizeDouble(vol,0);
         ExtVolumesUpBufferLine[i]=NormalizeDouble(Buyers,0);
         ExtVolumesDownBufferHisto[i]=NormalizeDouble(Sellers,0);  
     }        
   return(0);
}
From the code it seems that you should check the 6th decimal
Do that and it should be clear


Re: Coding Help

#462
mladen wrote:
Thu Aug 03, 2017 3:50 am
salexes wrote:
Thu Aug 03, 2017 3:30 am
I have a strange problem regarding rounding numbers.

I was using the Buy Sell Volume V 1.0 indicator via iCustom but now I wanted to integrate it directly into my indicator.... So I did that.
Below you will find the sourcecode of the indicator and my integration into my indicator.

Here is a picture of the strange rounding:
If I round it via NormalizeDouble it Roundsup 76.5 to 77.0 and 25.5 to 26.
Why are the values different ?
What do I need to do to get the exact same values? ("Note: I can not use IndicatorDigits(0); because for the other buffers i do need the numbers behind the . )

BuySellVolume SourceCode:

Code: Select all

//+-------------------------------------------------------------------+
//|                                        Buy_Sell_Volumes_v1.0.mq4  |
//|                                            Copyright © 2013, Pip  |
//|                                    http://www.pricemasterpro.com  |
//| This indicator is for personal use only.                          |
//| Please respect the intellectual rights of the original programmer |
//| and the work of others that contributed to this indicator         |
//| under no circumstances is this indicator to be sold for money or  |
//| to be repackged into a commercial package or to be distributed as |
//| original work by anyone else.                                     |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2013, Pip; admin@pricemasterpro.com"
#property link      "http://www.pricemasterpro.com/"
//---- indicator settings
#property  indicator_separate_window
#property indicator_minimum 0
#property indicator_buffers 6
#property indicator_color1  White
#property indicator_color2  White
#property indicator_color3  Red
#property indicator_color4  Red
#property indicator_color5  Green
#property indicator_color6  Green
#property indicator_width1  1
#property indicator_width2  1
#property indicator_width3  1
#property indicator_width4  1
#property indicator_width5  1
#property indicator_width6  1
//---- indicator buffers
double ExtVolumesBufferHisto[];
double ExtVolumesBufferLine[];
double ExtVolumesUpBufferHisto[];
double ExtVolumesUpBufferLine[];
double ExtVolumesDownBufferHisto[];
double ExtVolumesDownBufferLine[];
 
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtVolumesBufferHisto);       
   SetIndexBuffer(1,ExtVolumesBufferLine);
   SetIndexBuffer(2,ExtVolumesUpBufferHisto);
   SetIndexBuffer(3,ExtVolumesUpBufferLine);       
   SetIndexBuffer(4,ExtVolumesDownBufferHisto);
   SetIndexBuffer(5,ExtVolumesDownBufferLine);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_HISTOGRAM);
   SetIndexStyle(5,DRAW_LINE);
//---- sets default precision format for indicators visualization
   IndicatorDigits(0);   
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Buy_Sell Volume Pressure");
   SetIndexLabel(0,"Total Volume");      
   SetIndexLabel(1,"Buy Volume");
   SetIndexLabel(2,"Sell Volume");
//---- sets drawing line empty value
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(3,0.0); 
   SetIndexEmptyValue(5,0.0);      
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Volumes                                                          |
//+------------------------------------------------------------------+
int start()
  {
   int    i,nLimit,nCountedBars;
//---- bars count that does not changed after last indicator launch.
   nCountedBars=IndicatorCounted();
//---- last counted bar will be recounted
   if(nCountedBars>0) nCountedBars--;
   nLimit=Bars-nCountedBars;
//----
   for(i=0; i<nLimit; i++)
     {
    double bullp   = MathAbs(iBullsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double bearp   = MathAbs(iBearsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double vol     = iVolume(Symbol(), 0, i);
    double Buyers  = (bullp * vol) / MathMax((bullp + bearp),0.000001);
    double Sellers = (bearp * vol) / MathMax((bullp + bearp),0.000001);
   
         ExtVolumesBufferHisto[i]=vol;
         ExtVolumesBufferLine[i]=vol;
         ExtVolumesUpBufferHisto[i]=Buyers;
         ExtVolumesUpBufferLine[i]=Buyers;
         ExtVolumesDownBufferHisto[i]=Sellers; 
         ExtVolumesDownBufferLine[i]=Sellers;       
     
     }        
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

The calculation is exactly the same:

Code: Select all

int BuySellVolume(int offset, int limit){
   for(int i=offset; i<limit; i++)
     {
    double bullp   = MathAbs(iBullsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double bearp   = MathAbs(iBearsPower(NULL, 0, 1, PRICE_CLOSE, i));
    double vol     = iVolume(Symbol(), 0, i);
    double Buyers  = (bullp * vol) / MathMax((bullp + bearp),0.000001);
    double Sellers = (bearp * vol) / MathMax((bullp + bearp),0.000001);
   
         ExtVolumesBufferHisto[i]=NormalizeDouble(vol,0);
         ExtVolumesUpBufferLine[i]=NormalizeDouble(Buyers,0);
         ExtVolumesDownBufferHisto[i]=NormalizeDouble(Sellers,0);  
     }        
   return(0);
}
From the code it seems that you should check the 6th decimal
Do that and it should be clear
I set indicator digits to 7 even but there were only zeros 76.50000000 and 25.0000000. So I still have no idea/clue why the rounding is different.

Re: Coding Help

#463
salexes wrote:
Thu Aug 03, 2017 4:15 am
mladen wrote:
Thu Aug 03, 2017 3:50 am


From the code it seems that you should check the 6th decimal
Do that and it should be clear
I set indicator digits to 7 even but there were only zeros 76.50000000 and 25.0000000. So I still have no idea/clue why the rounding is different.
Got it. MathRound() did the trick.

Re: Coding Help

#464
Hi experts
Needs your kind help regarding 2 errors (correction) in this EA - some of errors and warnings already removed but these are out of my level :)
regards
MFI_R2_EA_v2.3.mq4
(98.71 KiB) Downloaded 430 times
Indicator is just a tool.

Use it only if it can benefit you. Leave it if you don't know how to use it optimally.

Re: Coding Help

#465
mntiwana wrote:
Thu Aug 03, 2017 4:06 pm
Hi experts
Needs your kind help regarding 2 errors (correction) in this EA - some of errors and warnings already removed but these are out of my level :)
regards
Try it out now
MFI_R2_EA_v2.3.mq4
(98.67 KiB) Downloaded 468 times


Re: Coding Help

#466
mladen wrote:
Thu Aug 03, 2017 6:00 pm
mntiwana wrote:
Thu Aug 03, 2017 4:06 pm
Hi experts
Needs your kind help regarding 2 errors (correction) in this EA - some of errors and warnings already removed but these are out of my level :)
regards
Try it out now
Thanks,it is clean now :)
Indicator is just a tool.

Use it only if it can benefit you. Leave it if you don't know how to use it optimally.

Re: Coding Help

#467
Please mladen i dont know how to code OBV indicator when is OB/OS beacouse the indicator have fluctuant levels, i want to use it with Icustom when is at bottom and up of the windows.
1000.png
OBV.mq4
(8.19 KiB) Downloaded 384 times

Re: Coding Help

#468
Cladi39 wrote:
Fri Aug 04, 2017 6:38 am
Please mladen i dont know how to code OBV indicator when is OB/OS beacouse the indicator have fluctuant levels, i want to use it with Icustom when is at bottom and up of the windows.
Unfortunately those points are obvious - only after the fact
There is no way to do that in run-time

Re: Coding Help

#470
traderduke wrote:
Sat Aug 05, 2017 3:44 am
Mladen
could you check out why this 2ma won't due mtf, it works on current.
Thanks Ray

RK-2MA histo-Diff-lines nmc.mq4
I does not show anything on any time frame (not even on current time frame)
Adjust the diff level
Also (you are missing it in the iCustom() call - along with completely wrong parameters order in the iCustom() call - once when you order the parameters as they should be, it should work


  1. Similar Topics

    1. CODING HELP

      0 Replies 1304 Views

      by slyfer91, Sun Apr 25, 2021 6:43 am in Coding Help

      0 Replies
      1304 Views
    2. iMAonArray - Coding help

      0 Replies 547 Views

      by rogerha, Fri Oct 15, 2021 2:21 am in Coding Help

      0 Replies
      547 Views
    3. Help me to calculate slope

      2 Replies 493 Views

      by Eddie_83, Fri Apr 23, 2021 3:08 am in Coding Help

      2 Replies
      493 Views

Return to “Coding Help”

Users viewing this forum: CommonCrawl [Bot] and 3 guests