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

[amibroker] Re: Consistent coding structure problem



PureBytes Links

Trading Reference Links

Herman gave a viable answer in his last post.

I'd just like to add that I wouldn't let any bias against looping 
stand in the way of advancing an idea. So few ideas have any real 
promise that the sooner you can get something up and tested the 
better.

You can always refine the code later. Even then, there is a lot to be 
said for code that reads well (to you) vs. code that performs well. If 
after a month's time you find yourself again struggling to decipher 
the code, then you might have been better off going with a more 
familiar construct.

Mike 

--- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@xxx> 
wrote:
>
> Mike & Herman,
> 
> Thank you. Both good ideas... and sorry about moving the goal posts
> here... but the problem is still becoming clear to me as I think 
about
> it more... Actually, the problem I have with IIF() in these
> circumstances is where I want to evaluate more than one expression
> within the if() condition... for example,
> 
> HLRange = abs( H - L );
> ABC = HLRange > Ref( HLRange, -1 ) AND HLRange > Ref( HLRange, -2) 
AND
> HLRange > Ref( HLRange, -3 );
> XYZ_Check=IIf(Ref(ABC,-1),1,IIf(Ref(ABC,-2),2,IIf(Ref(ABC,-
3),3,0)));
> 
> if(XYZ_Check==0)
> {
> RU1_Check = Open>Ref(Open,-1) AND Open>Ref(Open,-2) AND 
Open>Ref(Open,-3);
> RU2_Check = Close>Ref(Close,-1) AND Close>Ref(Close,-2) AND
> Close>Ref(Close,-3);
> }
> if(XYZ_Check==1)
> {
> RU1_Check = Open>Ref(Open,-2) AND Open>Ref(Open,-3) AND 
Open>Ref(Open,-4);
> RU2_Check = Close>Ref(Close,-2) AND Close>Ref(Close,-3) AND
> Close>Ref(Close,-4);
> }
> if(XYZ_Check==2)
> {
> RU1_Check = Open>Ref(Open,-3) AND Open>Ref(Open,-4) AND 
Open>Ref(Open,-5);
> RU2_Check = Close>Ref(Close,-3) AND Close>Ref(Close,-4) AND
> Close>Ref(Close,-5);
> }
> if(XYZ_Check==3)
> {
> RU1_Check = Open>Ref(Open,-4) AND Open>Ref(Open,-5) AND 
Open>Ref(Open,-6);
> RU2_Check = Close>Ref(Close,-4) AND Close>Ref(Close,-5) AND
> Close>Ref(Close,-6);
> }
> 
> Sorry if this is labouring a point. But I always get stuck by this
> structure... I guess I should just use a loop, but I am loathe to if
> there is another way.
> 
> TIA
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@> wrote:
> >
> > Why not do it the same way you did XYZ_Check? Also, it would be 
more 
> > efficient to add variables rather than repeating the same 
operation.
> > 
> > Open1 = Open > Ref(Open, -1);
> > Open2 = Open > Ref(Open, -2);
> > ...
> > Open6 = Open > Ref(Open, -6);
> > 
> > Open123 = Open1 AND Open2 AND Open3;
> > Open234 = Open2 AND Open3 AND Open4;
> > ...
> > Open456 = Open4 AND Open5 AND Open6;
> > 
> > RU1_Check = IIF(XYZ_Check == 0,
> >   Open123,
> >   IIF(XYZ_Check == 1, 
> >     Open234,
> >     IIF(XYZ_Check == 2,
> >     ...
> > );
> > 
> > Mike
> > --- In amibroker@xxxxxxxxxxxxxxx, "sidhartha70" <sidhartha70@> 
> > wrote:
> > >
> > > Herman,
> > > 
> > > This is where the problem occurs... because what I actually want 
to 
> > do
> > > within each conditional if() statement is carry out some more 
array
> > > manipulations. For example,
> > > 
> > > HLRange = abs( H - L );
> > > ABC = HLRange > Ref( HLRange, -1 ) AND HLRange > Ref( HLRange, -
2) 
> > AND
> > > HLRange > Ref( HLRange, -3 );
> > > XYZ_Check=IIf(Ref(ABC,-1),1,IIf(Ref(ABC,-2),2,IIf(Ref(ABC,-
> > 3),3,0)));
> > > 
> > > if(XYZ_Check==0)
> > > {
> > > RU1_Check = Open>Ref(Open,-1) AND Open>Ref(Open,-2) AND 
> > Open>Ref(Open,-3);
> > > }
> > > if(XYZ_Check==1)
> > > {
> > > RU1_Check = Open>Ref(Open,-2) AND Open>Ref(Open,-3) AND 
> > Open>Ref(Open,-4);
> > > }
> > > if(XYZ_Check==2)
> > > {
> > > RU1_Check = Open>Ref(Open,-3) AND Open>Ref(Open,-4) AND 
> > Open>Ref(Open,-5);
> > > }
> > > if(XYZ_Check==3)
> > > {
> > > RU1_Check = Open>Ref(Open,-4) AND Open>Ref(Open,-5) AND 
> > Open>Ref(Open,-6);
> > > }
> > > 
> > > Any way to achieve this across the entire price array outside of 
a
> > > loop....?
> > > 
> > > TIA
> > >
> >
>


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

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

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

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

For other support material please check also:
http://www.amibroker.com/support.html

*********************************
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:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto: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/