[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Help with filling array


  • Date: Thu, 24 Dec 2009 14:51:42 -0000
  • From: "Marty J" <prog200@xxxxxxxxx>
  • Subject: [amibroker] Re: Help with filling array

PureBytes Links

Trading Reference Links


--- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxx> wrote:
>
> You are only defining the values for bars between 5 and 50, not a full
> array. ie slope[40] is the value for the 40th bar (per barindex()
> count) of the history.
> You need to explain what you are actually trying to achieve before any
> help can be given
> 
> -- 
> Cheers
> Graham Kav
> AFL Writing Service
> http://www.aflwriting.com
> 
> 
> 
> 2009/12/24 Marty J <prog200@xxx>:
> >
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, Aron <aron.groups@> wrote:
> >>
> >> |*for*(i=5;i<51;i++)
> >> {
> >> AvgSum = Sum(*C*,i)/i;
> >> ry= Ref(AvgSum ,-1);
> >> array = (AvgSum - ry)/*C* *100;
> >> slope[i] = array[i];
> >> }
> >> |
> >>
> >>
> >> On 12/23/2009 1:43 AM, Marty J wrote:
> >> > I'm having trouble with the following code
> >> > Like to fill the array.
> >> >
> >> > for(i=5;i<51;i++)
> >> > {
> >> > AvgSum = Sum(C,i)/i;
> >> > ry= Ref(AvgSum ,-1);
> >> > slope[i] = (AvgSum - ry)/C *100;
> >> > }
> >> >
> >> > The following error occurs
> >> > Error 8. Type mismatch, the value assigned to the array element has to be a number. You can not use array on the right-side of this assignment.
> >> >
> >> >
> >> > Is there another way of doing this?
> >> >
> >> > Thnx
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > ------------------------------------
> >> >
> >> > **** IMPORTANT PLEASE READ ****
> >> > This group is for the discussion between users only.
> >> > This is *NOT* technical support channel.
> >> >
> >> > TO GET TECHNICAL SUPPORT send an e-mail directly to
> >> > SUPPORT {at} amibroker.com
> >> >
> >> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> >> > http://www.amibroker.com/feedback/
> >> > (submissions sent via other channels won't be considered)
> >> >
> >> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> >> > http://www.amibroker.com/devlog/
> >> >
> >> > Yahoo! Groups Links
> >> >
> >> >
> >> >
> >> >
> >>
> > Still not working correctly.
> >
> > for(i=45;i<51;i++)
> > {
> > AvgSum = Sum(C,i)/i;
> > ry= Ref(AvgSum ,-1);
> > array = (AvgSum - ry)/C *100;
> > slope[i] = array[i];
> > printf("array = %f\n" ,array  );
> > printf("slope1[%g] = %f\n",i, slope[i] );
> > }
> >
> > array = 0.543919      <==== this is what the value should be
> > slope[45] = 0.073096  <==== This is wrong. Why?
> > array = 0.562687
> > slope[46] = 0.068811
> > array = 0.441399
> > slope[47] = 0.088211
> > array = 0.372907
> > slope1[48] = 0.094559
> > array = 0.432736
> > slope[49] = 0.096924
> > array = 0.454843
> > slope[50] = 0.094987
> > array = 0.454843
> >
> >
> > Thnx
> >
> >
> >
> > ------------------------------------
> >
> > **** IMPORTANT PLEASE READ ****
> > This group is for the discussion between users only.
> > This is *NOT* technical support channel.
> >
> > TO GET TECHNICAL SUPPORT send an e-mail directly to
> > SUPPORT {at} amibroker.com
> >
> > TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> > http://www.amibroker.com/feedback/
> > (submissions sent via other channels won't be considered)
> >
> > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> > http://www.amibroker.com/devlog/
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
What I want to do is fill an array (40,41,42...50) instead of writing code for each one. This code calculate the slope.


Avg40 = Sum(C,40)/40;
ry = Ref(Avg40,-1);
savg40 = (Avg40- ry)/ C *100;

Avg41 = Sum(C,41)/41;
ry = Ref(Avg41,-1);
savg41 = (Avg41- ry)/ C *100;
.
.
.
Avg50 = Sum(C,50)/50;
ry = Ref(Avg50,-1);
savg50 = (Avg50 - ry)/ C *100;

Like the above code to be shorten into a single for statement

for(i=40;i<51;i++)
{  
AvgSum = Sum(C,i)/i;
ry= Ref(AvgSum ,-1);
array = (AvgSum - ry)/C *100; 
slope[i ] = array[i];

printf("slope1[%g] = %f\n",i, slope[i] );
}
where slope[40] = savg40
where slope[41] = savg41
.
.
where slope[50] = savg50

Thnx



------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/