Urgent : Please help - Need to make this indicator sensitive to the nearest 1 pip instead of 10 pips

 

This indicator does not work on a 4 decimal place MetaTrader account if I put it as 3 pips but if I use a 5 decimal place MetaTrader account and put 30 pips, it tracks the bar highs and lows to the nearest 3 pips.


Anyone knows why?


Thank you


//+------------------------------------------------------------------+

//| PPZ.mq4
//| By fxsheep[forex factory]
//|
//| Description:
//| - Draws number of ppz lines specified by user. (num_ppz_show)
//| - Draws ppz with highest number of confulence first.
//| confulence is calcuated by how close to high/low of a bar (tolerance)
//| - PPz levels are at certain pips away from each other (ppz_spacing)
//| - programs runs at startup or at first 2 minute of time frame
//| work best at 4H & daily charts
//|
//| Mar 18, 2009 fxsheep - first cut
//|
//|
//+------------------------------------------------------------------+
#property indicator_chart_window

//---- input parameters
extern int BarCount = 50, // Number of bars to look back on the chart
Tolerance = 3, // Tolerance in pips counting confluence
ppz_spacing = 10, // spacing requirement between ppz levels in pips
num_ppz_show = 10; // number of ppz lines to show


extern color Color = DeepSkyBlue;

//-- internal global variables
int con[]; //confluence at each price point
int price_range = 0; // range between highest and lowest prices
int ll_pip; // highest price in 10pip unit
int hh_pip;
int TimeFrame = 0; // Time frame to analyze bars from {0=current chart, 1=M1, 5=M5, ..., 1440=D1, 10080=W1, 43200=MN1}
double hh; // highest price
double ll; // lowest price

bool timeToCheck=false;
bool startup = false; // variable to signal problem start
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void init()
{
IndicatorShortName("PPZ");
DeleteLines();
startup = true;
if(TimeFrame==0)
TimeFrame=Period();
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void deinit()
{
DeleteLines();
startup = false;
}

//+------------------------------------------------------------------+
void DrawLevel(double price, int conf)
{
price = NormalizeDouble(price,Digits);
string name = DoubleToStr(price,Digits)+" "+conf+" PPZ Level "+" confulence ";

if(ObjectFind(name)==-1)
ObjectCreate(name,OBJ_HLINE,0,0,price);

ObjectSet(name,OBJPROP_COLOR,Color);
}

//+------------------------------------------------------------------+
// draws ppz lines up to the number specified by user
// draws ppz with highest confulence first
// filter out any lines within ppz already drawn on chart
void DrawPPZ()
{
int con_sorted[];
int drawn_array[];
int drawn = 0;
int i;
bool far_enough = true;

//-- before drawing, delete existing ppz lines
DeleteLines();

ArrayResize(con_sorted,ArrayDimension(con));

ArrayCopy(con_sorted,con);
ArraySort(con_sorted,WHOLE_ARRAY,0,MODE_DESCEND);
//Print("non", con[0]," ", con[1], " ",con[2]," ",con[3]," ",con[4]);
//Print("sorted", con_sorted[0]," ", con_sorted[1], " ",con_sorted[2]," ",con_sorted[3]," ",con_sorted[4]);

ArrayResize(drawn_array,num_ppz_show);

int j = 0;
//while (j < num_ppz_show)
while (con_sorted[j] > 1)
{
for(i = 0; i < price_range; i++)
{
// match highest confluence for the price i
if(con[i] == con_sorted[j])
{

//-- if haven't drawn enough ppz and ppz level yet
if ((drawn < num_ppz_show)){
//-- make sure price is far enough from ppz already drawn
far_enough = true;
for (int k=0;k<drawn;k++) {
//Print ("i is ",i," drawn_array has ",drawn_array[k]);
if (MathAbs(i - drawn_array[k]) < ppz_spacing/10) {
far_enough = false;
}
} //-- end for drawn

if (far_enough) {
drawn_array[drawn] = i;
//Print ("calculation based on price ", ll, " to ",hh);
// Print ("drawn# ",drawn," ppz: ",ll_pip+i, " w/ confulence of ", con[i]);
//-- use Point*10 cuz base unit is 10pip
DrawLevel( (ll_pip+i)*Point*10, con[i]);
drawn++;
} //-- end if far_enough
}//-- end if drawn
} //-- end if con
} //-- end for i
j++;
} //--end while
} //-- end procedure

//+------------------------------------------------------------------+
// delete any horizontal lines with name "PPZ" in it
void DeleteLines()
{
string name;
for (int m =0; m< ObjectsTotal(); m++)
{
//if first 3 char eq ppz
name = ObjectName(m);
//Print ("name is ",name);
int found = StringFind(name, "PPZ");
//Print ("index ",found);
if (found >= 0) // if not found, index returned is -1
{
//Print("delete");
ObjectDelete(name);
}
//delete it
}
}

//+-------------------------------------------------------
// if program just startup, return true,
// if in the first minute of each time frame, return true
void CheckTime(bool&check)
{

switch (Period())
{

case PERIOD_M1:
Print ("PPZ not supported in M1");
break;
case PERIOD_M5:
Print ("PPZ not supported in M5");
break;
case PERIOD_M15:
Print ("PPZ not supported in M15");
break;
case PERIOD_M30:
if ((Minute()>28 && Seconds()>50) || startup) check=true; else check=false;
break;
case PERIOD_H1:
//Print("I am in H1!");
if ((Minute()<2 && Seconds()>50) || startup) check=true; else check=false;
//Print("check=", check);
break;
case PERIOD_H4:
if ((MathMod(Hour(),4)==0 && Minute()<2 && Seconds()>50) || startup) check=true; else check=false;
break;
case PERIOD_D1:
if ((Hour()==0 && Minute()<2 && Seconds()>50) || startup) check=true; else check=false;
//Print("check=",check);
break;
case PERIOD_W1:
if ((DayOfWeek()==0 && Hour()==0 && Minute()<2 && Seconds()>50) || startup) check=true; else check=false;
break;
case PERIOD_MN1:
if ((Day()==0 && Hour()==0 && Minute()<2 && Seconds()>50) || startup) check=true; else check=false;
break;
default:
Print("I am in default!");
check=false;
break;
}//-- end switch
} //-- end CheckTime

//+------------------------------------------------------------------+
void start()
{
//-- run checkTime routine to figure out if it's time to run
CheckTime(timeToCheck);
// Print ("timeToCheck",timeToCheck);
if (timeToCheck == true)
{
hh = iHigh(NULL,TimeFrame,iHighest(NULL,TimeFrame,MODE_HIGH,BarCount,0));
ll = iLow (NULL,TimeFrame,iLowest (NULL,TimeFrame,MODE_LOW, BarCount,0));

// use 10pips as basic unit, instead of 1 pip
hh_pip = hh/(Point*10);
ll_pip = ll/(Point*10);

price_range = hh_pip -ll_pip + 1; //price range in pips

//Print ("hh_pip ",hh_pip, " ll_pip ", ll_pip, " price range: ",price_range);

ArrayResize(con,price_range);
ArrayInitialize(con,0);

int price;
// i=1: start with last bar
for(int i = 1; i < BarCount; i++)
{
int high = iHigh(NULL,TimeFrame,i) / (Point *10);
int low = iLow(NULL,TimeFrame,i) / (Point *10);
// each price++ is 10 pips
for(price = ll_pip; price <= hh_pip; price++)
{
if ((MathAbs(price - high) < Tolerance/10) || (MathAbs(price - low) < Tolerance/10))
{
int index = price - ll_pip; //move index to store in array
con[index]++;
//Print ("ppz price level(x10pips) ",price," at index [",index,"] has confulence of ", con[index]);
} // end if
} // end for
} // end for
//-- call drawPPZ function
DrawPPZ();
}//-- end if CheckTime

startup = false;
} //-- end start
 

Look at all of the "Point*10" items in there..

Point is the 4th decimal place on a 4 digit broker and 5th on a 5 digit broker.

Which is why it ^ works on a 5 digit but not a four

 
spacechimp:

Look at all of the "Point*10" items in there..

Point is the 4th decimal place on a 4 digit broker and 5th on a 5 digit broker.

Which is why it ^ works on a 5 digit but not a four


I tried to change it to *1 but it does not work. Any idea how to solve it
 
tradertt:


I tried to change it to *1 but it does not work. Any idea how to solve it
spacechimp:

Look at all of the "Point*10" items in there..

Point is the 4th decimal place on a 4 digit broker and 5th on a 5 digit broker.

Which is why it ^ works on a 5 digit but not a four


anyone can assisit thanks
Reason: