Login Page - Create Account

Support Board


Date/Time: Mon, 25 Nov 2024 12:33:00 +0000



[User Discussion] - Dynamic Fib Retracement

View Count: 2830

[2014-01-27 05:12:45]
User29662 - Posts: 76
Is it possible programatically to create dynamic retracement wherein you choose, for instance, a swing low as Point A and then the retracement tool automatically shifts Point B to the highest high after Point A? In other words, if a new High is made, Point B of the retracement tool shifts to the new high automatically?
Has anyone made a tool like this? Can it be done using SC's programming language? If so, how hard would it be to make? Or is it not possible?

Thanks in advance for any info
[2014-01-28 10:21:17]
Sierra Chart Engineering - Posts: 104368
Have a look at this page:
https://www.sierrachart.com/index.php?l=doc/doc_DLLTools.html
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
[2014-01-28 16:00:25]
User29662 - Posts: 76
Thanks! But No Fib Fan Drawing Type?
[2014-01-28 22:59:31]
Sierra Chart Engineering - Posts: 104368
We will have to see about adding support for this from ACSIL when using sc.UseTool.
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
[2014-01-29 00:06:49]
User29662 - Posts: 76
Please with a cherry on top! That would be fantastic!
[2014-01-29 15:24:07]
Al SC Developer - Posts: 434
In ver 1087, the DRAWING_FAN_FIBONACCI will be supported from ACSIL via sc.UseTool(). For an example, see the end of the scsf_UseToolExample() in studies.cpp
[2014-01-30 04:52:56]
User29662 - Posts: 76
Awesome! Thanks!
[2014-01-30 05:36:51]
User29662 - Posts: 76
As a test for what I want to do, I tried to create a simple study that would draw a line. The start point is inputted by the user in the study settings. After that, the line is meant to be dynamically drawn/redrawn to the highest high following the start bar. The code compiled but is not drawing anything. This is my first attempt at ACSIL. Any help/advice would be appreciated. Here's the code:


#include "sierrachart.h"

SCDLLName("DLT DLL")

SCSFExport scsf_DynamicLineTest(SCStudyGraphRef sc)
{

  SCInputRef SwingLowBar = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName = "DLT";
    sc.GraphRegion = 0;
    
    sc.FreeDLL = 1;

    sc.AutoLoop = 1;
        
    SwingLowBar.Name = "SwingLowBar";
    SwingLowBar.SetInt(0);
    
    return;
  }
  
  
  int StartBar;
  int EndBar;
  float StartPrice;
  float EndPrice;
  
  StartBar = SwingLowBar.GetInt();
  
  if (sc.Index < StartBar) return;
  
  if (sc.Index == StartBar)
    {
    StartPrice = sc.Low[sc.Index];
    EndPrice = sc.High[sc.Index];
    }
  
  if (sc.Index > StartBar)
  {

  EndPrice = max(sc.High[sc.Index], EndPrice);
  
    if (EndPrice == sc.High[sc.Index])
    {
      EndBar = sc.Index;
      
      const int UniqueLineNumber =57683545;
  
      if (sc.LastCallToFunction)
      {
      sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, UniqueLineNumber + 21);
      return;
      }
      
      s_UseTool Tool;
  
  
      Tool.Clear();
      Tool.ChartNumber = sc.ChartNumber;
      Tool.DrawingType = DRAWING_LINE;
      Tool.LineNumber = UniqueLineNumber+1;
      Tool.BeginIndex = StartBar;
      Tool.EndIndex = EndBar;
      Tool.BeginValue = StartPrice;
      Tool.EndValue = EndPrice;
      Tool.Color = RGB(255,0,255);
      Tool.AddMethod = UTAM_ADD_OR_ADJUST;
      
      sc.UseTool(Tool);
    }
  }
}




[2014-01-30 07:11:14]
User29662 - Posts: 76
update: I moved the
s_UseTool Tool;
instantiation to right underneath
float EndPrice
in the code. The good news is now I am getting a line drawn. Even more good news is that it is dynamically updating. The bad news is that it seems to start at a random bar with the value of 0 and end at the high of the last bar. Well, I guess you can't have everything :) Any help would be greatly appreciated!


[2014-01-30 08:08:29]
ejtrader - Posts: 688
My suggestion would be to use mouse pointer to detect the bar.

Keyword - int toolIndex=sc.ActiveToolIndex; - You can search for the code in ACS_SOURCE directory.
[2014-01-30 08:15:12]
User29662 - Posts: 76
Thanks! I will try that although I know nothing about programming mouse actions. However, if I can get it to work, it would be even better than what I intended. Also, I think I need to use
sc.ArraySize-1
instead of
sc.Index
in the conditionals.

Thanks again!
[2014-01-30 10:47:44]
User29662 - Posts: 76
Update 2: This code actually works for an instant until there is an update to the chart after the first autoloop, wherein it goes wacky.

I believe this has something to do with the tool being adjusted. The same line number must be used and only certain members should change, but so far, I can't seem to get it to work. I tried to draw the tool once at the start bar and then just adjust the end points on new highs but nada.

However, if i set the add method to add always, I get every incarnation of a new high drawn.
Date Time Of Last Edit: 2014-01-30 12:16:50
[2014-01-30 17:33:29]
User29662 - Posts: 76
Withdrawn...
Date Time Of Last Edit: 2014-01-30 17:49:17
[2014-01-30 17:56:26]
ejtrader - Posts: 688
User29662 - Though I can help - it would be better if you learn the hard way - you would pick up more pieces along the way:

Let me give you couple of hints
- Try to use the persistent variable
- Only if the high is > that persistent variable - draw line

Pseudo code:

float& lastHigh = sc.PersistVars->f1;
....
if (sc.High[sc.Index] <= lastHigh) return;
lastHigh=sc.High[sc.Index];
drawLine;

Date Time Of Last Edit: 2014-01-30 18:10:00
[2014-01-30 18:06:40]
User29662 - Posts: 76
Thank you very much ejtrader!! I was starting to get flummoxed. I realized the variable was not being retained but I had no idea why, and quite frankly, I think I would have given up before ever coming across persistent variable, as I've never encountered such an incarnation of variable.
Date Time Of Last Edit: 2014-01-30 18:09:42
[2014-01-30 18:27:29]
User29662 - Posts: 76
BINGO! Thank you for relieving me of my misery! May you live for a thousand years!
[2014-01-30 18:33:09]
ejtrader - Posts: 688
Glad - worked out for you. Now when your time permits(and if you really want to) - try to use mouse pointer to give as an input.

int toolIndex=sc.ActiveToolIndex;
[2014-01-30 18:36:36]
User29662 - Posts: 76
Yes, I was just thinking, that is my next step, after I take a little mental break. Thanks so much!
Date Time Of Last Edit: 2014-01-30 18:36:44
[2014-01-31 08:24:39]
tobi - Posts: 351
This sounds like an interesting tool. Once it's finished, would you mind sharing the .cpp and .dll file, so the non-programmers can have a look at/use this too?
[2014-02-03 15:39:39]
tobi - Posts: 351
User29662, did you get your dynamic fib tool to work? Are you willing to share?
[2014-02-03 21:34:53]
sbsierra - Posts: 71
Sharing would be very nice!

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

Login

Login Page - Create Account