Re: [amibroker] How to get a number from an array

 

Try this and see if it works for you!  Code does not use looping.  You can change the trigger expression.  Trigger same as a Buy or a Sell signal.

trigger = (MA(Close,50)> MA(Close,10)); //Expression that starts bar counting
nbst = barssince(1 - trigger); // Number of bars since trigger
hhvaluest = HHV(High,nbst);  //Highest High Value since Trigger

Plot(hhvaluest,"Highest High Value Since Trigger: ",colorRed);


On 2/22/2016 11:50 AM, gamacc@aruba.it [amibroker] wrote:
 

Hello there,

in order to obtain the highest peak value of the bars after the entry bar  I've written this code:


Buy = IIf(<entry condition>,True,0);

EntryBar = IIf(<entry condition>,BarIndex(),0);

for( i = EntryBar; i < BarCount; i++ )
{
   PeakValue = HHV(H,(Bar - i);
   ....
}


This code doesn't work; the AFL reports the error nr. 6: "Condition in IF, WHILE, FOR statement must numeric or boolean type; you cannot use array here...".

How can I change the variable EntryBar from an array into a number? I've tried "Bar = EntryBar" but it's the same thing.

Thanks to anyone have an answer.


Regards







__._,_.___

Posted by: Alan <alan@thenorthams.us>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (14)
**** 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/


.

__,_._,___


EmoticonEmoticon