for my EA, I need a function that is able to show the market value of SP500 when it opens and when it closes from the previous day.
Does something like this exists and if not, what I assume since I didn't find anything, has anyone of you an idea how to solve this?
P.S. Sorry for any spelling mistakes
With such a vague and general request, it seems obvious that your coding skill is most probably close to ZERO, so I suggest that you head on over to the Freelance section and hire someone to code it for you!
EDIT: PS! Hopefully your broker already supports trading the S&P 500, otherwise you will have to find a broker that does.
just want to post my soultion in case anyone is searching for something similar:
double Sp500_Open, Sp500_Close;
Sp500_Open = iOpen("[SP500]",PERIOD_D1, 1);
Sp500_Close = iClose("[SP500]",PERIOD_D1, 1);
Sp500_Open = iOpen("[SP500]",PERIOD_D1, 3);
Sp500_Close = iClose("[SP500]",PERIOD_D1, 3);
You first need to check which day of the week it is because obviously when you say "give the opening value of SP500 from the previous day" on a monday, you won't get a value.
This is why the function checks if the day is greater or equal tuesday. If this is the case, you get the opening price of Market [SP500] for period 1 Day minus 1 (so yesterday). Same goes for closing price.
However if it's a monday, you get the prices from 3 days ago (last friday).
Thanks again gooly.
To add comments, please log in or register