# ATR in Pips or Points help please!

int ATRPeriod=14; double atr = iATR(Symbol(),0,ATRPeriod,0); double atr_in_points = NormalizeDouble(atr ,Digits); double atr_in_pips = NormalizeDouble(atr,Digits-1*(Digits==3 || Digits==5));

**aphong:**

Hi all, ... Im quite new to creating EAs ... & Its a pain in the ass for me when it comes to Defintion of PIP, POINT, PIP VALUE, POINT
VALUE, TICK, TICK SIZE, TICK VALUE ... kk

I found 2 ways of converting ATR into Pips or Points ... But got little
confused & Dont know which one is the correct? please help

below is the code:

Thanks in advance & regards,

//------MQL4 Version int ATRPeriod=14; double atr=iATR(NULL,0,ATRPeriod,0); int atr_in_points=(int)round(atr/_Point); //------MQL4 Version

In my personal experience, it is best to completely forget the concept of PIP when working on mql4/5 programming.

For some CFD products, PIP and POINT are the same thing.They refer to the smallest change in market price.

**aphong:**

Hi all, ... Im quite new to creating EAs ... & Its a pain in the ass for me when it comes to Defintion of PIP, POINT, PIP VALUE, POINT
VALUE, TICK, TICK SIZE, TICK VALUE ... kk

I found 2 ways of converting ATR into a number of Pips or Points ... But
got little confused & Dont know which one is the correct? please help

below is the code:

Thanks in advance & regards,

Google:

https://www.investopedia.com/ask/answers/032615/what-difference-between-pips-points-and-ticks.asp

The difference in the following image is 0.9 pips between ask and bid price:

You see that the last number is smaller, than the others. That says, that it is just a part of a whole pip. The fourth digit is a whole pip; the 5th
just a part (like 0.5 or 0.4).

[In Mt4 points are often used, to get whole numbers for parts of pips. Means, 0.9 pip is equivalent to 9 points.]

- www.investopedia.com

What is a TICK? - MQL4 programming forum

double ATR_IN_POINTS = ATR * MathPow(10,Digits - 0); double ATR_IN_PIPS = ATR * MathPow(10,Digits - 1);This code assumes a 3/5 digit broker. Don't assume. Using

*Point*means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.

How to manage JPY pairs with parameters? - MQL4 programming forum

Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

**William Roeder:**

A PIP is not a Point.

What is a TICK? - MQL4 programming forum This code assumes a 3/5 digit broker. Don't assume. Using

*Point*means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.

How to manage JPY pairs with parameters? - MQL4 programming forum

Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum

Thanks Master
**William & the others** ... I study your code
today & the WHRea_mq4 seems advanced to me.

I want to make it simple first ...Lets say I will only work with 5 digit broker & Only major pairs :)

1. below is my code for calculation lotsize based on risk 3% of equity & the SL of 50% of ADR... please check it out & correct me if im wrong.

2. still confused a bit : The SL of your code is (OrderOpenPrice() - OrderClosePrice())*DIR must be in number of Pips? isnt it:)

#property strict /* In code: Risk depends on your initial stop loss, lot size, and the value of the pair. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support. Account Balance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the SPREAD, and DeltaPerLot is usually around $10/pip but it takes account of the exchange rates of the pair vs. your account currency.) Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency (EUR, in this case). MODE_TICKVALUE is not reliable on non-fx instruments with many brokers. You must normalize lots properly and check against min and max. You must also check FreeMargin to avoid stop out Most pairs are worth about $10 per PIP. A $5 risk with a (very small) 5 PIP SL is $5/$10/5=0.1 Lots maximum. Use a GUI EA like mine (for MT4): Indicators: 'Money Manager Graphic Tool' indicator by 'takycard' Forum - Page 6 */ double Risk = 3.0; // Risk 3% double adrSL_percent = 50; // SL 50% ADR(14) int ADRPeriod = 14; double point, pip, lotsize; //--- void OnTick() { if(!is5DigitBorker()) return; // Lets say I only work with 5 digit Broker else{ point = MarketInfo(Symbol(),MODE_POINT); pip = point*10;} // double adrSL_inPips = (adrSL_percent/100)*iATR(Symbol(),PERIOD_D1,ADRPeriod,1)/pip; double equity = AccountEquity(); //AccountBalance * Percent/100 = RISK = (OrderOpenPrice() - OrderClosePrice())*DIR * OrderLots() * DeltaValuePerLot() // lotsize = NormalizeLots ((equity*Risk/100)/(adrSL_inPips*DeltaValuePerLot())); } //+------------------------------------------------------------------+ bool is5DigitBorker () { if (Digits == 5 || Digits == 3) {return(true);} else {Print(" not five (5) digit brokers " + Symbol()); return(false);} } //--- double DeltaValuePerLot(string pair=""){ if (pair == "") pair = Symbol(); return( MarketInfo(pair, MODE_TICKVALUE) / MarketInfo(pair, MODE_TICKSIZE) ); } //--- double NormalizeLots(double lots, string pair=""){ if (pair == "") pair = Symbol(); double lotStep = MarketInfo(pair, MODE_LOTSTEP); lots = MathRound(lots/lotStep ) * lotStep ; // double minlot = MarketInfo(Symbol(), MODE_MINLOT); double maxlot = MarketInfo(Symbol(), MODE_MAXLOT); if (lots < minlot) lots = minlot; if (lots > maxlot) lots = maxlot; //--- return(lots); }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets

You agree to website policy and terms of use

Hi all, ... Im quite new to creating EAs ... & Its a pain in the ass for me when it comes to Defintion of PIP, POINT, PIP VALUE, POINT VALUE, TICK, TICK SIZE, TICK VALUE ... kk

I found 2 ways of converting ATR into a number of Pips or Points ... But got little confused & Dont know which one is the correct? please help

below is the code:

Thanks in advance & regards,