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

Re: [amibroker] Re: Help with code bringing Ami to a grinding halt



PureBytes Links

Trading Reference Links

By the way, another common coding mistake is putting loop-invariants
inside the loop.

Move loop-invariant code such as:

HHVBarsSince = HHV(H, 30) ;
LLVBarsSince = LLV(L, 30) ;


OUTSIDE THE LOOP !!!

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "coba702002" <coba702002@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, February 05, 2006 9:51 PM
Subject: [amibroker] Re: Help with code bringing Ami to a grinding halt


> HI Tomasz
> 
> Ok I have revised my incorrect code and removed other code to try 
> and pinpoint the problem, but I still get weird things happening 
> even without datafeed, which Im sure tomorrow when I have data will 
> make the AMI unusable. Right now when I insert that code below into 
> a new window switching between that window and others is ALOT slower 
> ALSO when I select>>view and open say charts it will not open the 
> pane until I minimize ami and restore ami then it shows up... If I 
> try and close that pane it will not close until I Minimize ami and 
> then restore , then its gone.  This Problem Does not show up without 
> this code in any windows???
> 
> Thanks for any thoughts or ideas to fix this
> 
> Brian
> 
> range2=95;
> LastBar = BarCount-1;
> HiVal2 = HHV(H,range2);
> LoVal2 = LLV(L,range2);
> 
> step = 8;
> for( i = 0; i < BarCount; i++ ) 
> {
> if(HiVal2[i] >1.0 AND  HiVal2[i]<=25 )
> set = 30;
> else if (HiVal2[i]>25 AND  HiVal2[i]<=50 )
> set = 55; 
> else if (HiVal2[i]>50 AND  HiVal2[i]<=100 )
> set = 120; 
> else if (HiVal2[i]>100 AND  HiVal2[i]<=200 )
> set = 220;
> else if (HiVal2[i]>200 AND  HiVal2[i]<=500 )
> set = 510;  
> else if (HiVal2[i]>500 AND  HiVal2[i]<=900 )
> set = 920; 
> else if (HiVal2[i]>9000 AND  HiVal2[i]<=13000 )
> set = 13000; 
> else set = 13000; 
> 
> }
> 
> maxDegreesZero = set;
> degreesZero = 1;
> increment = 1;
> degreesValueInt = 0;
> angleFactor = 0;
> sqrtDegreesZero = 0;
> degreesValue = 0;
> 
> 
> 
>        // Iterate through the set of squares
>        while (degreesZero < maxDegreesZero)
>        {
>      sqrtDegreesZero = sqrt(degreesZero);
>                  
>            // Iterate through the circle for this square, in 11.25 
> degree increments
>            for (angle = 0; angle < 360; angle = angle + 11.25)
>            {
>                angleFactor = (angle / 360.0) * 2.0; 
>     degreesValue = (sqrtDegreesZero + 
> angleFactor) ^ 2;
> 
>        roundedValue = round(degreesValue);
> 
> 
> HHVBarsSince = HHV(H, 30) ;
> LLVBarsSince = LLV(L, 30) ;
> 
> 
>   if (roundedValue[LastBar]< (HHVBarsSince[Lastbar]) 
> AND roundedValue[LastBar]>(LLVBarsSince[Lastbar]) ){ 
>   Plot(Prec(roundedValue,2), "", 
> colorGrey40|styleLine, -(LLVBarsSince[Lastbar]),(HHVBarsSince
> [Lastbar]));
>   
>   }
>   
>            }
> 
>            // Find the next 0 degree value
>            degreesZero = degreesZero + increment;
>            increment = increment + step;
>        }
> 
> // End Square Of Nine  ************
> 
> PlotOHLC(Open,High,Low,Close,"",colorBlack, styleCandle);
> 
> TitleStr= Interval(2) ;
> 
> 
> Title = TitleStr;
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxx> 
> wrote:
>>
>> Hello,
>> 
>> No, I am referring to IIFs at the beginning that are written 
> incorrectly. I did not even
>> check further since the beginning of the code is wrong.
>> You are mixing up if (statement) with iif (function)
>> 
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message ----- 
>> From: "coba702002" <coba702002@xxx>
>> To: <amibroker@xxxxxxxxxxxxxxx>
>> Sent: Saturday, February 04, 2006 9:05 PM
>> Subject: [amibroker] Re: Help with code bringing Ami to a grinding 
> halt
>> 
>> 
>> > Thanks for your fast response... I can't test it today, no 
> datafeed  
>> > But just glancing at it, are you referring to the rounding 
> section 
>> > of the code?  If so Im pretty sure that didn't make any 
> difference 
>> > when it wasn't in there. 
>> > 
>> > So what your saying is this code once correct shouldn't be a 
> problem 
>> > working in an indicator VS a plain jane price chart in real 
> time?  
>> > My test comparison of the two was a MAJOR slowdown with my code 
>> > added.
>> > 
>> > Thanks again for any thoughts
>> > Brian
>> > 
>> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@> 
>> > wrote:
>> >>
>> >> The code contains numerous errors listed in "common coding 
>> > mistakes" in the User's Guide:
>> >> 
>> >> http://www.amibroker.com/guide/a_mistakes.html
>> >> 
>> >> Best regards,
>> >> Tomasz Janeczko
>> >> amibroker.com
>> >> ----- Original Message ----- 
>> >> From: "coba702002" <coba702002@>
>> >> To: <amibroker@xxxxxxxxxxxxxxx>
>> >> Sent: Saturday, February 04, 2006 8:10 PM
>> >> Subject: [amibroker] Help with code bringing Ami to a grinding 
> halt
>> >> 
>> >> 
>> >> > Can anyone help me figure out why when I add a window with 
> this 
>> > code 
>> >> > in it.. Ami (ver-4.76, windows xp, Ib tws 1.51) slows down to 
>> >> > unusable levels. ie switching windows takes forever... 
> candles 
>> > seem 
>> >> > stuck then suddenly change price.
>> >> > 
>> >> > Is there a way to make this code work???
>> >> > 
>> >> > any help or ideas would be greatly appreciated
>> >> > 
>> >> > Thanks
>> >> > Brian
>> >> > 
>> >> > // Begin Square Of Nine  ************   
>> >> > 
>> >> > range2=95;
>> >> > LastBar = BarCount-1;
>> >> > HiVal2 = HHV(H,range2);
>> >> > LoVal2 = LLV(L,range2);
>> >> > 
>> >> > step = 8;
>> >> > IIf(HiVal2>1.0 AND  HiVal2<=25 ,set = 30,0); 
>> >> > IIf(HiVal2>25 AND  HiVal2<=50 ,set = 55,0); 
>> >> > IIf( (HiVal2>50 AND  HiVal2<=100 ),set = 120,0);
>> >> > IIf( (HiVal2>100 AND  HiVal2<=200 ),set = 220,0);
>> >> > IIf( (HiVal2>200 AND  HiVal2<=500 ),set = 510,0);
>> >> > IIf( (HiVal2>500 AND  HiVal2<=900 ),set = 920,0);
>> >> > IIf( (HiVal2>9000 ),set = 13000,0);
>> >> > maxDegreesZero = set;
>> >> > degreesZero = 1;
>> >> > increment = 1;
>> >> > degreesValueInt = 0;
>> >> > angleFactor = 0;
>> >> > sqrtDegreesZero = 0;
>> >> > degreesValue = 0;
>> >> > 
>> >> > 
>> >> > 
>> >> >        // Iterate through the set of squares
>> >> >        while (degreesZero < maxDegreesZero)
>> >> >        {
>> >> >      sqrtDegreesZero = sqrt(degreesZero);
>> >> >                  
>> >> >            // Iterate through the circle for this square, in 
>> > 11.25 
>> >> > degree increments
>> >> >            for (angle = 0; angle < 360; angle = angle + 11.25)
>> >> >            {
>> >> >                angleFactor = (angle / 360.0) * 2.0; 
>> >> >     degreesValue = (sqrtDegreesZero + 
>> >> > angleFactor) ^ 2;
>> >> > 
>> >> >   // round either to tenths, quarters, OR wholes
>> >> >    if (degreesValue <= 450)
>> >> >    {
>> >> > degreesValue = degreesValue 
>> >> > * 10;
>> >> >        roundedValue = Prec
>> >> > (degreesValue,2) / 10;
>> >> >    }
>> >> >    else if (degreesValue > 450 AND degreesValue 
>> >> > < 5000)
>> >> >    {
>> >> >        remainder = frac(degreesValue);
>> >> >         intValue = degreesValue - remainder;
>> >> >        if (remainder > 0 AND remainder 
>> >> > <= .25)
>> >> >            remainder = .25;
>> >> >        else if (remainder > .25 AND 
>> >> > remainder <= .5)
>> >> >            remainder = .5;
>> >> >        else if (remainder > .5 AND 
>> >> > remainder <= .75)
>> >> >            remainder = .75;
>> >> >        else 
>> >> >            remainder = 1;
>> >> >        roundedValue = intValue + 
>> >> > remainder;
>> >> >    }
>> >> >    else
>> >> >    {
>> >> >        roundedValue = round(degreesValue);
>> >> > 
>> >> >    } 
>> >> > 
>> >> > 
>> >> > HHVBarsSince = HHV(H, 30) ;
>> >> > LLVBarsSince = LLV(L, 30) ;
>> >> > 
>> >> > 
>> >> >   //if (roundedValue[LastBar]<(45) AND roundedValue
>> >> > [LastBar]>(30) ){
>> >> >   if (roundedValue[LastBar]< (HHVBarsSince[Lastbar]) 
>> >> > AND roundedValue[LastBar]>(LLVBarsSince[Lastbar]) ){ 
>> >> >   Plot(Prec(roundedValue,2), "", 
>> >> > colorGrey40|styleLine, -(LLVBarsSince[Lastbar]),(HHVBarsSince
>> >> > [Lastbar]));
>> >> >   
>> >> >   }
>> >> >   
>> >> >            }
>> >> > 
>> >> >            // Find the next 0 degree value
>> >> >            degreesZero = degreesZero + increment;
>> >> >            increment = increment + step;
>> >> >        }
>> >> > 
>> >> > // End Square Of Nine  ************
>> >> > 
>> >> > PlotOHLC(Open,High,Low,Close,"",colorBlack, styleCandle);
>> >> > 
>> >> > TitleStr= Interval(2) ;
>> >> > 
>> >> > 
>> >> > Title = TitleStr;
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > Please note that this group is for discussion between users 
> only.
>> >> > 
>> >> > To get support from AmiBroker please send an e-mail directly 
> to 
>> >> > SUPPORT {at} amibroker.com
>> >> > 
>> >> > For other support material please check also:
>> >> > http://www.amibroker.com/support.html
>> >> > 
>> >> > 
>> >> > Yahoo! Groups Links
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> > 
>> >> >
>> >>
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > Please note that this group is for discussion between users only.
>> > 
>> > To get support from AmiBroker please send an e-mail directly to 
>> > SUPPORT {at} amibroker.com
>> > 
>> > For other support material please check also:
>> > http://www.amibroker.com/support.html
>> > 
>> > 
>> > Yahoo! Groups Links
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> >
>>
> 
> 
> 
> 
> 
> 
> 
> Please note that this group is for discussion between users only.
> 
> To get support from AmiBroker please send an e-mail directly to 
> SUPPORT {at} amibroker.com
> 
> For other support material please check also:
> http://www.amibroker.com/support.html
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

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/

<*> 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/