Need some help creating an array to store the history of an indicator.

Back to topics list To post a new topic, please log in or register
avatar
3
sh3k3ls 2016.05.26 23: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. 


avatar
13006
WHRoeder 2016.05.27 02: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.
avatar
3
sh3k3ls 2016.05.28 00: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.

avatar
Moderator
3422
GumRai 2016.05.28 01: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?

avatar
3
sh3k3ls 2016.05.28 03: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. 
avatar
13006
WHRoeder 2016.05.28 13: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);
     }}

Back to topics list  

To add comments, please log in or register