Jump to content

Pipsmark V3 Indicator


4xmeter

Recommended Posts

8-) No :?:

 

 

 

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

//| PipsMark.mq4 |

//| Ted Goulden |

//| |

// This indicator will mark the newest bar with an arrow if its high/Low

// exceeds the input MA by the input number of pips. There is also

// an alert feature that can be selected.

//

//

// Input Parameters:

//

// InputMAVal - the number of periods to be used by the MA calculation. - the number of periods to be used by the MA calculation.

// InputMAtype - the type of MA to be used for MA calculation.

// PipSignal - the arrow appears if this number of pips above/below the MA is exceeded.

// NoAlert - controls whether an audible alert is given.

//

// Modification History:

// Oct 26 09 - Ted Goulden, Initial Version

// Oct 28 09 - Ted Goulden, added comment string

// Feb 07 10 - flyer415 , can now select other MA inputs

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

#property copyright "Ted Goulden"

#property link ""

 

#property indicator_chart_window

 

#include <stdlib.mqh>

 

 

//---- input parameters

extern int InputMAval=10;

extern int InputMAtype=1; // 0 for Simple, 1 for Exponential

extern int InputMAshift=0;

extern int InputMAprice=0;

extern int PipSignal=20;

extern bool NoAlert=true;

 

double pips, pf = 1., ff = 1.;

bool alertDone = false;

int barStart = 0;

string ArrowName1 = "", ArrowName2 = "";

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

 

 

pips = MarketInfo(Symbol(), MODE_TICKSIZE);

if (Digits < 4)

{

pf = (0.01/pips);

ff = (pips/0.001);

}

if (Digits > 3)

{

pf = (0.0001/pips);

ff = (pips/0.00001);

}

 

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

Comment ("");

ObjectDelete(ArrowName1);

ObjectDelete(ArrowName2);

//----

return(0);

}

 

 

 

void SetArrow(string ArrowName, datetime ArrowTime, double Price,

double ArrowCode, color ArrowColor, bool LimitArrow)

{

int err;

 

// Note, if ArrowName was already used, the object will be replaced by current arrow.

if (ObjectFind(ArrowName) != -1) ObjectDelete(ArrowName);

if(!ObjectCreate(ArrowName, OBJ_ARROW, 0, ArrowTime, Price))

{

err=GetLastError();

Print("error: can't create Arrow! code #",err," ",ErrorDescription(err));

return;

}

else

{

ObjectSet(ArrowName, OBJPROP_ARROWCODE, ArrowCode);

ObjectSet(ArrowName, OBJPROP_COLOR, ArrowColor);

ObjectSet(ArrowName, OBJPROP_WIDTH, 2);

 

ObjectsRedraw();

}

} // end function

 

 

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

//| Custom indicator iteration function |

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

 

int start()

{

int counted_bars=IndicatorCounted();

//----

if (barStart < Time[0]) //start of new bar

{

Comment ("");

if (ArrowName1 > "") ObjectDelete(ArrowName1);

if (ArrowName2 > "") ObjectDelete(ArrowName2);

barStart = Time[0];

alertDone = false;

}

 

if (InputMAval > 0) double maVal = iMA(NULL, 0, InputMAval, InputMAshift, InputMAtype, InputMAprice, 0);

ArrowName1 = TimeToStr(Time[0])+"lo"+Symbol();

ArrowName2 = TimeToStr(Time[0])+"hi"+Symbol();

double typicalPrice = (High[0] + Low[0] + Close[0])/3;

double diff1 = MathRound((typicalPrice - maVal)/Point);

double diff2 = MathRound((maVal - typicalPrice )/Point);

if (( diff1 > PipSignal*pf) || ( diff2 > PipSignal*pf))

{

if (diff2 > PipSignal*pf)

{

SetArrow(ArrowName1, Time[0], Low[0], 233, Purple, false);

if (!NoAlert && !alertDone) Alert(Symbol(), " Pips diff : ", NormalizeDouble(diff2, 0));

Comment (" Price is below ", InputMAval, " moving average");

alertDone = true;

}

if (diff1 > PipSignal*pf)

{

SetArrow(ArrowName2, Time[0], High[0] + 15*Point, 234,DodgerBlue, false);

if (!NoAlert && !alertDone) Alert(Symbol(), " Pips diff : ", NormalizeDouble(diff1, 0));

Comment (" Price is above ", InputMAval, " moving average");

alertDone = true;

}

}

else Comment ("");

 

 

//----

return(0);

}

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

8-)

Link to comment
Share on other sites

Re: Pipsmark V3 Indicator

 

As you know, the indicator has as reference point the moving average; specified by the user and that determines its range by the number of pips selected. Could any programmer in this forum, (Williams, SEFC or Sharpeye) please 'fix it' in a way that the reference point could be any price (input) by the user instead of only the MA? >:) Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...