Open() not working

Examples step by step how to make your own automated strategy or user indicator
Message
Author
omarloren
Posts: 5
Joined: Wed Nov 23, 2011 1:08 pm

Open() not working

#1 Postby omarloren » Thu Dec 01, 2011 2:43 pm

Hello again, I'm trying to calculate a moving average of Open price every five candles, I have the following:
for (int i=0; i >= 5; i++){
ma += (Open(i));
}
ma= ma /5
I try the same with: "iOpen("EURUSD", PERIOD_M5,i)", but nothing seems to get stored into the ma variable.
Please advice I'm kind of stuck.
thanks...

KelvinHand
Posts: 103
Joined: Sun Jan 02, 2011 6:05 pm

Re: Open() not working

#2 Postby KelvinHand » Wed Dec 28, 2011 9:14 pm

omarloren wrote:Hello again, I'm trying to calculate a moving average of Open price every five candles, I have the following:
for (int i=0; i >= 5; i++){
ma += (Open(i));
}
ma= ma /5
I try the same with: "iOpen("EURUSD", PERIOD_M5,i)", but nothing seems to get stored into the ma variable.
Please advice I'm kind of stuck.
thanks...


I think it is very difficult to understand what your problem with the above partial statement. why don't you attach the complete source code for people to diagnose ?

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#3 Postby Tantalus » Wed Jan 04, 2012 10:20 pm

Take this:

Code: Select all

for (int i = 0; i >= 5; i++)
     ma += (Open(i));
ma = ma / 5


and change it to this:

Code: Select all

for (int i = 0; i < 5; i++)
     ma += (Open(i));
ma = ma / 5


The middle part of the for() block is a 'while', not an 'until'.
Tantalus Research - Developing 21st Century Trading Systems.


Return to “Programming lessons”

Who is online

Users browsing this forum: No registered users and 32 guests