[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

Brian,

I'd be really interested to see the final result myself. I was chasing 
Square9/Square12 for some work I was doing but I never got back to it 
nor am I that good a coder.

Cheers and I hope it gets worked out
Martin

coba702002 wrote:
> Tomasz
> With all due respect I wasn't asking for anyone to 'debug' the code, 
> I was just looking for ideas from more skilled code writers then I, 
> on what might be wrong with the code. I thought thats what this rooms 
> purpose was?
> 
> What I was trying to acheive was to calculate the square or nine and 
> display or plot that value as a line but only close to the 
> current 'c' price as to not mess up autoscaling. The numbers it 
> calculates are correct... but I guess its not a efficient or even 
> correct way to show it.?
> 
> And yes from my understanding in order to calc the sq of 9 #'s, in 
> the YM, for example, there are sq9 numbers from 0 to the current 
> close price (ie 10900ish) I thought by limiting the plot portion (as 
> shown below) would cut down on the lines being plotting (for 
> autoscale issues AND to do less work in the program????
> 
> if (roundedValue[LastBar]< (HHVBarsSince[Lastbar]) 
>>>>>>> AND roundedValue[LastBar]>(LLVBarsSince[Lastbar]) ){ 
>>>>>>>   Plot(Prec(roundedValue,2), "", 
>>>>>>> colorGrey40|styleLine, -(LLVBarsSince[Lastbar]),
> (HHVBarsSince
>>>>>>> [Lastbar]));
> 
> Thanks again
> brian
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxx> 
> wrote:
>> Hello,
>>
>> Debugging your code is YOUR task, not ours.
>>
>> From what I can see your code calls Plot hundreds (or even 
> thousands) of times
>> inside the loop. If this is the case it is not suprising it works 
> slow.
>> Use _TRACE function and DebugView to find out.
>> http://www.amibroker.com/guide/afl/afl_view.php?name=_TRACE
>>
>> BTW: you don't even say what this code is supposed to do, from
>> the code it looks like it plots thousands of horizontal lines (what 
> for?).
>> Again: learn to debug your own code.
>>
>> Best regards,
>> Tomasz Janeczko
>> amibroker.com
>> ----- Original Message ----- 
>> From: "coba702002" <coba702002@xxx>
>> 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@> 
>>> 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@>
>>>> 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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
> 
> 
> 
> 
> 
> 
> 
> 
> 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/