Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 21:38:02 +0000



Post From: Retracement Levels not showing

[2024-02-08 02:54:18]
User895355 - Posts: 55
I can't figure out why the RetracementLevels aren't showing up. The only level that shows is the %50 level. Any help would be greatly appreciated:

#include "sierrachart.h"

SCDLLName("My Risk Reward")

SCSFExport scsf_MyRiskReward(SCStudyInterfaceRef sc)
{
// Section 1 - Set the configuration variables and defaults
{
sc.GraphName = "My Risk Reward";
sc.AutoLoop = 0;
sc.GraphRegion = 0;
sc.ReceivePointerEvents = ACS_RECEIVE_POINTER_EVENTS_WHEN_ACS_BUTTON_ENABLED;
sc.BlockChartDrawingSelection = 0;

return;
}

// Section 2 - Do data processing here
int CONTROL_BTN = 10;
int &r_MenuID = sc.GetPersistentInt(13);
int &r_CheckedMenuID = sc.GetPersistentInt(14);
int &r_GreyedMenuID = sc.GetPersistentInt(15);
int &r_HideMenuID = sc.GetPersistentInt(16);
int &r_CheckedState = sc.GetPersistentInt(17);
int &r_SeparatorMenuID = sc.GetPersistentInt(18);
int &r_LineNumber = sc.GetPersistentInt(19);

if (sc.LastCallToFunction)
{
// Set default hover text and button text.
sc.SetCustomStudyControlBarButtonHoverText(CONTROL_BTN, "");
sc.SetCustomStudyControlBarButtonText(CONTROL_BTN, "");

// be sure to remove menu items when study is removed
sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_MenuID);
sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_SeparatorMenuID);
sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_CheckedMenuID);
sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_GreyedMenuID);
sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, r_HideMenuID);

return;
}

SCString Msg;
if (sc.UpdateStartIndex == 0)
{
sc.SetCustomStudyControlBarButtonHoverText(CONTROL_BTN, "My Risk Reward");
sc.SetCustomStudyControlBarButtonText(CONTROL_BTN, "RR");

if (r_MenuID <= 0)
{
r_MenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "My Risk Reward");

// add a menu separator
r_SeparatorMenuID = sc.AddACSChartShortcutMenuSeparator(sc.ChartNumber);
}

r_CheckedState = 1;

if (r_CheckedMenuID <= 0)
{
r_CheckedMenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Checked Toggle Menu Item");
sc.SetACSChartShortcutMenuItemChecked(sc.ChartNumber, r_CheckedMenuID, true);
}

if (r_GreyedMenuID <= 0)
r_GreyedMenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Greyed When Not Checked");

if (r_HideMenuID <= 0)
r_HideMenuID = sc.AddACSChartShortcutMenuItem(sc.ChartNumber, "Hidden When Not Checked");

if (r_MenuID < 0 || r_CheckedMenuID < 0 || r_HideMenuID < 0 || r_GreyedMenuID < 0)
{
Msg.Format("Add ACS Chart Shortcut menu item failed");
sc.AddMessageToLog(Msg, 1);
}
}

s_UseTool Tool;
Tool.Clear();
if (r_LineNumber != 0)
Tool.LineNumber = r_LineNumber;

// wait for an event
if (sc.MenuEventID != 0)
{
Tool.ChartNumber = sc.ChartNumber;
Tool.DrawingType = DRAWING_PRICE_PROJECTION;
Tool.LineStyle = LINESTYLE_DASH;
Tool.LineWidth = 1;
Tool.Color = RGB(255, 0, 255); // Magenta
Tool.AddMethod = UTAM_ADD_OR_ADJUST;
Tool.ShowPrice = 1;
Tool.ShowPercent = 1;
Tool.ShowLabels = 1;
Tool.RoundToTickSize = 0;
Tool.TextAlignment = DT_VCENTER; // label vertical alignment
Tool.ExtendRight = 1;
Tool.AddAsUserDrawnDrawing = 1;

Tool.RetracementLevels[0] = 10.0f;
Tool.RetracementLevels[1] = 23.6f;
Tool.RetracementLevels[2] = 50.0f;
Tool.LevelStyle[0] = LINESTYLE_DASH;
Tool.LevelColor[0] = COLOR_WHITE;
Tool.LevelStyle[1] = LINESTYLE_DASH;
Tool.LevelColor[1] = COLOR_WHITE;
Tool.LevelStyle[2] = LINESTYLE_DASH;
Tool.LevelColor[2] = COLOR_WHITE;

if (sc.PointerEventType == SC_POINTER_BUTTON_DOWN && sc.BlockChartDrawingSelection == 0)
{
sc.BlockChartDrawingSelection = 1;

Tool.BeginDateTime = sc.BaseDateTimeIn[sc.ActiveToolIndex];
Tool.EndDateTime = sc.BaseDateTimeIn[sc.ActiveToolIndex];
Tool.BeginValue = sc.ActiveToolYValue;
Tool.EndValue = sc.ActiveToolYValue;
Tool.ThirdValue = sc.ActiveToolYValue;
Tool.ThirdDateTime = sc.BaseDateTimeIn[sc.ActiveToolIndex];
}
else if (sc.PointerEventType == SC_POINTER_BUTTON_DOWN && sc.BlockChartDrawingSelection == 1)
{

sc.BlockChartDrawingSelection = 0;
if (sc.MenuEventID == ACS_BUTTON_10)
sc.SetCustomStudyControlBarButtonEnable(ACS_BUTTON_10, 0);
sc.GetPersistentInt(19) = 0;
sc.BlockChartDrawingSelection = 0;
Tool.Clear();
}
/* else if (sc.PointerEventType == SC_POINTER_BUTTON_UP)
{
if (sc.MenuEventID == ACS_BUTTON_10)
{
sc.SetCustomStudyControlBarButtonEnable(ACS_BUTTON_10, 0);
}
} */
/* else if (sc.PointerEventType == SC_POINTER_BUTTON_UP)
Msg.Append("Pointer Up Event, "); */

else if (sc.PointerEventType == SC_POINTER_MOVE && sc.BlockChartDrawingSelection == 1)
{
Tool.ThirdValue = sc.ActiveToolYValue;
}

if (sc.MenuEventID >= ACS_BUTTON_1 && sc.MenuEventID <= ACS_BUTTON_150)
{
Msg.AppendFormat("Got button event id %i, ", sc.MenuEventID);

if (sc.PointerEventType == SC_ACS_BUTTON_ON)
{
Msg.Append("ACS Button On Event, ");

// reset button to off
/* if (sc.MenuEventID == ACS_BUTTON_10)
sc.SetCustomStudyControlBarButtonEnable(ACS_BUTTON_10, 0); */
}
else if (sc.PointerEventType == SC_ACS_BUTTON_OFF)
Msg.Append("ACS Button Off Event, ");
}
else if (sc.MenuEventID == r_MenuID)
{
Msg.AppendFormat("Got menu event id %i, ", sc.MenuEventID);
}
else if (sc.MenuEventID == r_HideMenuID)
{
Msg.AppendFormat("Got hidden menu event id %i, ", sc.MenuEventID);
}
else if (sc.MenuEventID == r_GreyedMenuID)
{
Msg.AppendFormat("Got greyed menu event id %i, ", sc.MenuEventID);
}
else if (sc.MenuEventID == r_CheckedMenuID)
{
Msg.AppendFormat("Got checked menu event id %i, CheckedState=%i, ", sc.MenuEventID, r_CheckedState);

// toggle states
if (r_CheckedState == 0)
{
r_CheckedState = 1;
sc.SetACSChartShortcutMenuItemChecked(sc.ChartNumber, r_CheckedMenuID, true);
sc.SetACSChartShortcutMenuItemEnabled(sc.ChartNumber, r_GreyedMenuID, true);
sc.SetACSChartShortcutMenuItemDisplayed(sc.ChartNumber, r_HideMenuID, true);
}
else
{
r_CheckedState = 0;
sc.SetACSChartShortcutMenuItemChecked(sc.ChartNumber, r_CheckedMenuID, false);
sc.SetACSChartShortcutMenuItemEnabled(sc.ChartNumber, r_GreyedMenuID, false);
sc.SetACSChartShortcutMenuItemDisplayed(sc.ChartNumber, r_HideMenuID, false);
}
}

sc.UseTool(Tool);

r_LineNumber = Tool.LineNumber; // Remember line number which has been automatically set
Msg.Append("Y Value=");
Msg += sc.FormatGraphValue(sc.ActiveToolYValue, sc.GetValueFormat());

Msg.Append(", Bar Index=");
Msg += sc.FormatGraphValue(sc.ActiveToolIndex, 0);

sc.AddMessageToLog(Msg, 1);
}
}

Date Time Of Last Edit: 2024-02-08 02:55:12