Login Page - Create Account

Support Board


Date/Time: Tue, 23 Apr 2024 15:02:05 +0000



[Programming Help] - possible bugs? 2 things - sc.GetLineNumberOfSelectedUserDrawnDrawing - @ usetool issue

View Count: 481

[2022-05-04 19:15:38]
JohnR - User831573 - Posts: 300
For those following along. My quest started here. Cut drawing object-2 items->1 UI & 1 ACSIL - one general tool request - One Doc update

I've made progress. For the "Cut" - when dealing with pitchforks, SC uses Tool.FourthIndex as the value of the bar # for the cut to take place. Placing a PF on the chart, set up some code to "get drawing by line #, step step some code and look at data returned into Tool structure. return to UI, Cut the drawing, repeat debug to see updated data in Tool. On each new cut, FourthIndex did change to the bar # confirmed on the screen as the end of tool visually.

On to the next steps. I changed my test code. It still "gets by line #" the desire object, again confirmed by looking at structure in debugger. I change the value of Tool.FourthIndex, Then call JOR_Success = UseTool (Tool).;
Stepping through the code I see I change the value and the UseTool call is successful, but the object on the screen does not move the cut point. verified by message log.

Chart: ESM22_FUT_CME[M]/MESM22_FUT_CME[M] 5 Min #1 | Study: JOR Get Existing Pitchfork | Start of Event Code of JOR_DGL | 2022-05-04 14:26:55.460 *
Chart: ESM22_FUT_CME[M]/MESM22_FUT_CME[M] 5 Min #1 | Study: JOR Get Existing Pitchfork | PitchFork >>> -12 <<< Fourth index--> 710 | 2022-05-04 14:26:55.461 *
Chart: ESM22_FUT_CME[M]/MESM22_FUT_CME[M] 5 Min #1 | Study: JOR Get Existing Pitchfork | PF#-> -12 4th Idx-> 720 Success-> 1 | 2022-05-04 14:26:55.461 *
Chart: ESM22_FUT_CME[M]/MESM22_FUT_CME[M] 5 Min #1 | Study: JOR Get Existing Pitchfork | PF#-> -12 4th Idx-> 690 Success-> 1 | 2022-05-04 14:26:55.461 *
Chart: ESM22_FUT_CME[M]/MESM22_FUT_CME[M] 5 Min #1 | Study: JOR Get Existing Pitchfork | PF#-> -12 4th Idx-> 740 Success-> 1 | 2022-05-04 14:26:55.461 *

Documentation states to set Tool.AddMethod = UTAM_ADD_OR_ADJUST; and only change the fields/properties you want to change.
DOC -> Set the other members of the s_UseTool structure that you want to modify. The structure members that you do not want to change need to be left unset. For more information, refer to AddMethod.
If the drawing is adjusted, then only the s_UseTool structure members specified will be updated in the existing Chart Drawing, the others will be left as is.

Another thing I have not been able to solve, is the function JOR_LineNum = sc.GetLineNumberOfSelectedUserDrawnDrawing(). What state of things constitutes a selected drawing? How do I get a line # to be returned. I have tried left / right / click / press and hold / release button. I have tried both within debugger and without, as the pointer switches back and forth as I step in code, thinking that might be the issue. I have also tried all 3 receive pointer event types. I do see the property Tool.IsSelected, but I am not sure how to use that.

My code in its current state has the get selected line function commented out, to work on one issue at a time.

Anyone - pointers (pun intended), help or knowledge would be greatly appreciated.

JohnR
attachmentJOR_DGL.cpp - Attached On 2022-05-04 19:12:59 UTC - Size: 3.68 KB - 104 views
[2022-05-05 21:30:55]
JohnR - User831573 - Posts: 300
So, I have modified my code to Always receive pointer events. Based on the entries in the message log, I am able to capture Pointer button Down, and correctly LineNum = 0 as long as the pointer is not over a drawn object. If I click on an object, my code never executes. I am not able to get the "Selected" user drawn object.

if (sc.PointerEventType == SC_POINTER_BUTTON_DOWN)
  {
    JOR_MessageText.Format("JOR Pointer Down Event ");
    sc.AddMessageToLog(JOR_MessageText, 1);
    JOR_LineNum = sc.GetLineNumberOfSelectedUserDrawnDrawing();
    JOR_MessageText.AppendFormat("Selected PitchFork >>> %i ", JOR_LineNum);
    sc.AddMessageToLog(JOR_MessageText, 1);
    return;
  }

I still can not get sc.UseTool to move the pitchfork cut point.

To try to further narrow down if it is my issue, Instead of changing the Tool.FourthIndex, I changed Tool.BeginIndex. This was successful, but only after I included the following logic, which I found as your answer to another user a while back trying to move a tool. If the doc states to 'not' change fields you do not want modified, why is it necessary to 'Clear' these two fields. I'm just trying to better understand.
        Tool.BeginDateTime.Clear();
        Tool.EndDateTime.Clear();

There is no Clear for Tool.FourthIndex and including the 2 above lines still did not move the cut point. It seems to me, the UseTool even though it returns 1 indicating it was executed successfully, that is not the case.

Please advise.

JohnR
Date Time Of Last Edit: 2022-05-06 12:28:41
[2022-05-06 13:38:39]
JohnR - User831573 - Posts: 300
Upon further testing. I have found the following to be true.

1 - If I select the pitchfork through the UI and then use     JOR_Success_Line = sc.GetUserDrawnChartDrawing(sc.ChartNumber, DRAWING_PITCHFORK, Tool, -1);
--- It does return the structure with the # of the drawing I previouslu clicked on. This is good. I can work with that.

--> but I still would like to understand why this did not work. sc.GetLineNumberOfSelectedUserDrawnDrawing()

2 - By using the following code, visually on the chart, I can see that I am able to modify the pitchfork, in my test it was Tool.BeginIndex - but still do not see the "CUT" Tool.FourthIndex, being changed on the screen.

----> It appears that sc.UseTool(), does not call the code needed to check for a 'cut'.

3- I still would like to know why clearing of dates is required.

// Added to see if this is needed - clearing of dates
        Tool.BeginDateTime.Clear();
        Tool.EndDateTime.Clear();
      // End of added to test code of clearing dates

        Tool.AddMethod = UTAM_ADD_OR_ADJUST;
        int JOR_Fourth = Tool.FourthIndex;
        Tool.FourthIndex = JOR_Fourth + 10;
        Tool.BeginIndex = Tool.BeginIndex - 5;
        JOR_Success_Line = sc.UseTool(Tool);
        JOR_MessageText.Format("PF#-> %i 4th Idx-> %i Success-> %i", JOR_LineNum, Tool.FourthIndex, JOR_Success_Line);
        sc.AddMessageToLog(JOR_MessageText, 1);

Hope this helps narrow the bug in the code.

JohnR
Date Time Of Last Edit: 2022-05-10 16:05:47
[2022-05-11 19:12:13]
JohnR - User831573 - Posts: 300
SC support, Please look into this.

JohnR
[2022-05-16 20:52:09]
Sierra_Chart Engineering - Posts: 14055
This is too long and complicated. You need to simplify this into a simple question.
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, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2022-05-19 21:13:49]
JohnR - User831573 - Posts: 300
First, thank you for your time to reply. There are 2 things I have problems with.

1 - The most important is Tool.FourthIndex, does not cut/move visual ending of the drawing when I changed its value before calling sc.UseTool(Tool). I am trying to change this property, as I determined it is used for "CUT" value on a pitchfork. After the successful call of UseTool, to verify the issue, I call Tool.Clear then sc.GetUserDrawnDrawingByLineNumber(sc.ChartNumber, JOR_LineNum, Tool) The property FourthIndex still equals it's original value before any of my code. In testing, I can successfully change any of the first 3 indexes / selection points. Also, I do set AddAsUserDrawnDrawing variable to 1.

2- Docs state to only modify properties you want to change. Why do I need to use these 2 statements? SC support provided them as a solution to another in the forums who had issues moving a line. After adding them to my code, I am able to modify a user drawn object. I am using bar #, not using points relative to visual chart, so I see no need for them. To better understand - What conditions must I use these statements?
  Tool.BeginDateTime.Clear();
  Tool.EndDateTime.Clear();

Thanks for your time to look into this.

JohnR

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

Login

Login Page - Create Account