Login Page - Create Account

Support Board


Date/Time: Mon, 06 May 2024 11:22:20 +0000



[User Discussion] - ACSIL Drawing Problem/Question

View Count: 1179

[2015-03-13 21:04:31]
WarEagle - Posts: 70
Hi,

I am trying to draw a rectangle at various price levels pulled from a text file. I am able to read the file fine and draw the shape at the correct levels. I am using the following code framework:


int Hour, Minute; //These are set to the sc.Index bar hour and minute
if ((Hour == 8) && (Minute = 25) )
{
//Code to read file to get prices
//Code for Tool setup

sc.UseTool(Tool);
}

The problem is that the rectangles are being drawn more than once and on bars that follow the 8:25 bar. I have attached a picture to show the outcome. This is a 5 minute chart and the if statement checks that we are on the 8:25 bar to start the drawing, however I have drawings for several bars after that. Why would the 8:30, 8:35 etc bars trigger a drawing? My theory is that the drawing is trying to draw on the same bar but since another drawing is already there it is pushing the start index out to the next bar, causing the cascading effect. The problem is that there should only be one drawing at each level.

I also have a question that may be related to this problem. I use the message log for debugging and noticed that when I wrote the price levels out to the log before I added the drawing tool portion the message would get repeated 5 or so times each bar that the condition was true. Its like the code is iterating more than once per bar. Is there an obvious solution I am overlooking?

Thanks!

imagemultiplerectangles.jpg / V - Attached On 2015-03-13 20:38:30 UTC - Size: 11.09 KB - 372 views
[2015-03-15 17:23:11]
StevieD - Posts: 39
1) An obvious problem exists in this line of code...

if ((Hour == 8) && (Minute = 25) )

2) I use the message log for debugging and noticed that when I wrote the price levels out to the log before I added the drawing tool portion the message would get repeated 5 or so times each bar that the condition was true.

Charts update (and code runs) based on the chart update interval setting. This is true whether using auto-looping or manual looping. Your explanation indicates you are using auto-looping. Two options come to mind to control when your code runs, which would/should also create generic code usable on multiple timeframes without mod.

The first option is sc.GetBarHasClosedStatus() found here... http://www.sierrachart.com/index.php?page=doc/doc_ACSIL_Members_Functions.html#scGetBarHasClosedStatus

The second option uses a persistent variable for one-time processing per bar, found here... http://www.sierrachart.com/index.php?page=doc/doc_ACSILProgrammingConcepts.html#OneTimeProcessingperBar

Good trading to you


[2015-03-15 21:42:00]
Sierra Chart Engineering - Posts: 104368
Yes this appears to be wrong:

if ((Hour == 8) && (Minute = 25) )


It should be:

if ((Hour == 8) && (Minute == 25) )

Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-03-16 03:27:23]
WarEagle - Posts: 70
I can't believe I missed that "=="...I replaced that and all is well. Sorry for the sloppy mistake.

Thanks for your help StevieD, as a novice coder that has learned as I go I have never understood how SC processes each bar. This information was very helpful.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account