Download MetaTrader 5
To add comments, please log in or register
Sign up to publish an article and receive 200 USD
sh3k3ls
11
sh3k3ls 2016.05.26 21:01 
I want to make a function that will store the past 100 candle values of the ATR(14 period) and then save the lowest value to a variable which can be used by other functions. 

Can anyone help me or provide me a sample snippet of code? I went through the official literature but it just does not want to work for me. 

whroeder1
13619
whroeder1 2016.05.27 00:55  
  1. learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
sh3k3ls
11
sh3k3ls 2016.05.27 22:35  
I just want the "lowest" variable to be the lowest iATR readout from the past 100 candles.

    double atrhist;
     double lowest;
     
void atrcheck()
{     
     for(int i=0; i<100; i++) 
     {
     atrhist=iATR(Symbol(),0,14,i);
     if (atrhist<lowest)
     lowest=atrhist;
     Print(atrhist);
     }}
  My EA places orders based on weather the current iATR is above or below lowest*2.
Keith Watford
Moderator
7952
Keith Watford 2016.05.27 23:37  
void atrcheck()
{    
     lowest=iATR(Symbol(),0,14,0); 
     for(int i=1; i<100; i++) 
     {
     atrhist=iATR(Symbol(),0,14,i);
     if (atrhist<lowest)
     lowest=atrhist;
     Print(atrhist);
     }}

Do you really want to include the incomplete ATR value for bar 0 in your calculations?

sh3k3ls
11
sh3k3ls 2016.05.28 01:17  
GumRai:

Do you really want to include the incomplete ATR value for bar 0 in your calculations?

no.... but im guessing i just change the iATR setting for that at lowest.  thank you very much for your assistance. 
whroeder1
13619
whroeder1 2016.05.28 11:41  
    double atrhist;
     double lowest;
     
void atrcheck()
{     
     for(int i=0; i<100; i++) 
     {
     atrhist=iATR(Symbol(),0,14,i);
     if (atrhist<lowest)  << what is the value of lowest at the start of the loop?
     lowest=atrhist;
     Print(atrhist);
     }}
/
To add comments, please log in or register