Hello I want to add a condition to my purchase code.

 
Hello I want to add a condition to my purchase code. my buy code is as follows:
  double ATRBuy = GetIndicatorValue (handleatr, 0,1);

I would like to add the following condition to this code. I use atr as the line with the following stop loss. Don't buy if the Atr indicator is 2% higher than the price.
how can I do that.
 
Kutluhan Yesilkaya:
Hello I want to add a condition to my purchase code. my purchase code is as follows: double ATRBuy = GetIndicatorValue (handleatr, 0,1);

I want to add the following condition to this code. Don't buy if the atr indicator is 2% higher than the price. how can I do that.

  1. Please post only in English on this forum. Use the automatic translation tool if needed. Use simple language structure when using mechanical translation. 2013.08.09

  2. ATR is the size of the bars. It will never be higher than price.
 
// i assume your code is MQL4
//add this before buy function:

if(ATRBuy > Ask*(2+100)/100 )return;
 
Khuman Bakhramirad:

I forgot to specify. I am using metatrader 5

 
MqlTick latest_price;
if(!SymbolInfoTick(_Symbol,latest_price))
      return;
double Ask = latest_price.ask;
if(ATRBuy > Ask*(2+100)/100 )return;

then add this

 
Khuman Bakhramirad:

sonra bunu ekle

I HAVE TRIED THESE CODES. DOES NOT OPERATE AT ALL. I ONLY WANT IT NOT TO TRANSACTION IF THERE IS A 2% DIFFERENCE

 
sure because "Average True Range" is always lower than price because its the price changing range, but this is what you asked for :\ explain more what do you mean by ATR more than price, do you know what ATR is? 
 
Kutluhan Yesilkaya: I want to add a condition to my purchase code.

Do you actually have code? Not a .EXn; real code? Then no one can help you; you didn't purchase the code.

 
William Roeder :

Gerçekten kodunuz var mı? .EXn değil; gerçek kod? O zaman kimse sana yardım edemez; kodu satın almadınız.

yes ı have got

 
Khuman Bakhramirad:
elbette çünkü " Ortalama Gerçek Aralık " her zaman fiyattan daha düşüktür çünkü fiyat değişim aralığıdır, ancak siz bunu istediniz: \ ATR ile fiyattan çok ne demek istediğinizi açıklayın, ATR'nin ne olduğunu biliyor musunuz? 

That's how I use the atrbuy line

Files:
Adsaz.png  19 kb
 
Khuman Bakhramirad:

sonra bunu ekle

MqlTick latest_price;

if(!SymbolInfoTick(_Symbol,latest_price))

      return;

if(ATRBuy< ASK*(100-ProfitPercentage)/100 ) return;


if(ATRSell  >ASK*(ProfitPercentage+100)/100 )return;

 

only code with atrsell works. atrbuy does not work.

Reason: