Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 06:37:09 +0000



Post From: "Hide Chart Drawings" question

[2024-10-29 12:20:03]
User676363 - Posts: 72
I'm curious about what options are available for "Hide Chart Drawings", "Erase All Text", and "Erase All Non-Text Drawings" in the cases where the ACSIL developer has used the user-drawn objects.

This type of code seems to prevent those shortcut menus from functioning:
rect.AddMethod = UTAM_ADD_OR_ADJUST;
rect.AddAsUserDrawnDrawing = 1;
rect.LockDrawing = 1;
sc.UseTool(rect)

The Lock and Hidden properties can be updated using the "Manage Chart Drawings Window" but the "Hide All Studies", erase, and hide drawings shortcuts do not seem to have any effect on studies where those user-drawn objects are left on the chart. They stay there even after the study is removed and while the objects do appear in the "Manage Chart Drawings Window" and can be deleted, I'm not seeing a way to really convert them into real user drawn objects that I can manage with the "Hide Chart Drawings" shortcut.

Can anybody explain what property the developers are failing to use in a study where drawings are left on the chart, user can manipulate them, study can be removed, and they remain, but the shortcuts distinguish them from normal drawings and fail to work?

Thank you.

Here's some code so as to not leave anybody in the dark as to an example. Hopefully the comments are clear and it will be obvious where the example has gone wrong in terms of trying to create the two types of objects. One that will hide/show with the study and one that will hide/show outside the study for the user.

#include "sierrachart.h"

SCDLLName("Four Rectangles Testing Lock and User-Drawn Settings")

SCSFExport scsf_DisplayFourRectangles(SCStudyInterfaceRef sc) {
if (sc.SetDefaults) {
sc.GraphName = "Four Rectangles Test: Lock and User-Drawn Settings";
sc.AutoLoop = 0;

// Add an input to control rectangle generation
sc.Input[0].Name = "Generate Rectangles";
sc.Input[0].SetYesNo(false); // Default to "No" to prevent repeated creation

return;
}

// Only generate rectangles if user has enabled "Generate Rectangles"
if (!sc.Input[0].GetYesNo()) return;

// Define unique positions for each rectangle to avoid overlap
int startBarIndex = sc.ArraySize - 60;
int endBarIndex = sc.ArraySize - 20;
float topPrice = sc.BaseData[SC_HIGH][startBarIndex] + 4.0f; // Higher position for top row
float midTopPrice = sc.BaseData[SC_HIGH][startBarIndex] + 2.0f; // Mid position for top row
float midBottomPrice = sc.BaseData[SC_HIGH][startBarIndex]; // Mid position for bottom row
float bottomPrice = sc.BaseData[SC_LOW][startBarIndex] - 2.0f; // Lower position for bottom row

// 1. Rectangle: LockDrawing = 0, AddAsUserDrawnDrawing = 0
s_UseTool rect1;
rect1.Clear();
rect1.Region = 0;
rect1.ChartNumber = sc.ChartNumber;
rect1.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
rect1.BeginIndex = startBarIndex;
rect1.EndIndex = (startBarIndex + endBarIndex) / 2; // Left column
rect1.BeginValue = topPrice;
rect1.EndValue = midTopPrice;
rect1.Color = RGB(0, 128, 255); // Light blue
rect1.LineWidth = 2;
rect1.AddMethod = UTAM_ADD_OR_ADJUST;
rect1.AllowSaveToChartbook = 1;
rect1.AddAsUserDrawnDrawing = 0;
rect1.LockDrawing = 0;
rect1.Text = "Lock: 0, User-Drawn: 0"; // This rectangle disappears after recalculation or if a
// Settings:Yes, Settings:Apply, Study:OK sequence is
// applied to the dialogs
sc.UseTool(rect1);

// 2. Rectangle: LockDrawing = 0, AddAsUserDrawnDrawing = 1
s_UseTool rect2;
rect2.Clear();
rect2.Region = 0;
rect2.ChartNumber = sc.ChartNumber;
rect2.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
rect2.BeginIndex = (startBarIndex + endBarIndex) / 2;
rect2.EndIndex = endBarIndex; // Right column
rect2.BeginValue = topPrice;
rect2.EndValue = midTopPrice;
rect2.Color = RGB(255, 128, 0); // Orange
rect2.LineWidth = 2;
rect2.AddMethod = UTAM_ADD_OR_ADJUST;
rect2.AllowSaveToChartbook = 1;
rect2.AddAsUserDrawnDrawing = 1;
rect2.LockDrawing = 0;
rect2.Text =
"Lock: 0, User-Drawn: 1"; // User can manipulate, unaffected by "Hide Chart
// Drawings", can be hidden using Manage Drawings or right/click
sc.UseTool(rect2);

// 3. Rectangle: LockDrawing = 1, AddAsUserDrawnDrawing = 0
s_UseTool rect3;
rect3.Clear();
rect3.Region = 0;
rect3.ChartNumber = sc.ChartNumber;
rect3.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
rect3.BeginIndex = startBarIndex;
rect3.EndIndex = (startBarIndex + endBarIndex) / 2; // Left column
rect3.BeginValue = midBottomPrice;
rect3.EndValue = bottomPrice;
rect3.Color = RGB(128, 255, 0); // Green
rect3.LineWidth = 2;
rect3.AddMethod = UTAM_ADD_OR_ADJUST;
rect3.AllowSaveToChartbook = 1;
rect3.AddAsUserDrawnDrawing = 0;
rect3.LockDrawing = 1;
rect3.Text = "Lock: 1, User-Drawn: 0"; // This rectangle disappears after recalculation or if a
// Settings:Yes, Settings:Apply, Study:OK sequence is
// applied to the dialogs
sc.UseTool(rect3);

// 4. Rectangle: LockDrawing = 1, AddAsUserDrawnDrawing = 1
s_UseTool rect4;
rect4.Clear();
rect4.Region = 0;
rect4.ChartNumber = sc.ChartNumber;
rect4.DrawingType = DRAWING_RECTANGLEHIGHLIGHT;
rect4.BeginIndex = (startBarIndex + endBarIndex) / 2;
rect4.EndIndex = endBarIndex; // Right column
rect4.BeginValue = midBottomPrice;
rect4.EndValue = bottomPrice;
rect4.Color = RGB(128, 0, 255); // Purple
rect4.LineWidth = 2;
rect4.AddMethod = UTAM_ADD_OR_ADJUST;
rect4.AllowSaveToChartbook = 1;
rect4.AddAsUserDrawnDrawing = 1;
rect4.LockDrawing = 1;
rect4.Text =
"Lock: 1, User-Drawn: 1"; // User can manipulate, unlock, but still unaffected by "Hide
// Chart Drawings". Can be manipulated with right/click
sc.UseTool(rect4);

// Set GenerateRectangles back to "No" after creation to prevent duplicates
sc.Input[0].SetYesNo(false);
}