Login Page - Create Account

Support Board


Date/Time: Sat, 20 Apr 2024 12:23:42 +0000



[Programming Help] - Extra signals using ACSIL. Need help.

View Count: 1042

[2019-09-09 16:12:50]
User929084 - Posts: 60
1. I modified a study to give me signal when there's difference between price and delta. Meaning when price bar is up but delta is down and price is down but delta is up. Everything works fine when I put the study on historical graph. But in real time, a signal will be generated when the conditions are met while the bar is forming ( which is OK), but that signal will stay on chart even when the conditions for the signal are no longer valid.

The signal should appear above high or low of a bar, but in real time it will stay displayed even inside of body of the candle.

Also when I click on Study button and don't do anything else, just click OK to close the study menu all the extra signals disappear. And the chart looks like it should.

For reference I put Cumulative Delta blow the chart with two Color Bar Based on Alert Condition study with alert :
=AND(C<O,ID4.SG4>ID4.SG1)
=AND(C>O,ID4.SG4<ID4.SG1)
which does exactly the same thing.

2. When I try to put that study on Cumulative Delta study, and I choose to base the study on cumulative delta it will not display anything. Any help with that?

I included a pic of the problem along with the study.

Thank you.
imageExtra_signals.1.png / V - Attached On 2019-09-09 16:11:33 UTC - Size: 38.01 KB - 247 views
attachmentDeltaDivergencer.cpp - Attached On 2019-09-09 16:12:22 UTC - Size: 3.32 KB - 251 views
[2019-09-09 16:36:52]
User907968 - Posts: 802
To solve problem 1, either

- set the 'Delta_Divergence_Up' & 'Delta_Divergence_Dn' both to zero each time the study is calculated
or
- add an else to your if....else if code that zeroes the 'Delta_Divergence_Up' & 'Delta_Divergence_Dn' when the trigger conditions are not met

e.g.


  if ((sc.Close[sc.Index] > sc.Open[sc.Index]) && (sc.BaseDataIn[Up][sc.Index] < sc.BaseDataIn[Down][sc.Index]))
  {
    //if up volume is dominant then set value in up volume array to 1, this will cause the color_bar subgraph to draw
    Delta_Divergence_Up[sc.Index] = sc.Low[sc.Index] - (SignalOffset.GetInt() * sc.TickSize);
    //set down volume to 0, this is in case down volume triggered already during formation of bar
    //this is to offset signal other then "color bar", like arrow up/ down
    Delta_Divergence_Dn[sc.Index] = 0;
  }
  else if ((sc.Close[sc.Index] < sc.Open[sc.Index]) && (sc.BaseDataIn[Up][sc.Index] > sc.BaseDataIn[Down][sc.Index]))
  {
    // apply the same logic as above for down volume trigger
    Delta_Divergence_Dn[sc.Index] = sc.High[sc.Index] + (SignalOffset.GetInt() * sc.TickSize);
    //this is to offset signal other then "color bar", like arrow up/ down
    Delta_Divergence_Up[sc.Index] = 0;
  }
  else
  {
    Delta_Divergence_Dn[sc.Index] = 0;
    Delta_Divergence_Up[sc.Index] = 0;
  }

[2019-09-09 16:52:05]
User907968 - Posts: 802
Regarding problem 2, the symbols are probably being drawn, but beyond the range of the cum_delta scale as they are based on the main graph values.

To solve this you would need to base the signal offset on the high and low subgraphs of the cum_delta study bars (SG2 & SG3), rather than the main graph values.

Have a look at -
ACSIL Interface Members - sc.Input Array: sc.Input[].SetStudySubgraphValues()
&
sc.GetStudyArrayUsingID()
[2019-09-09 17:06:50]
User929084 - Posts: 60
OK so I implemented your second solution like the code snippet you provided and it works.

But how would I set the 'Delta_Divergence_Up' & 'Delta_Divergence_Dn' both to zero each time the study is calculated?

Delta_Divergence_Up[sc.Index] = sc.Low[sc.Index] - (SignalOffset.GetInt() * sc.TickSize);
Delta_Divergence_Dn[sc.Index] = 0; <----- I thought this line already takes care of that.

Could you please provide the code how it should look like?

Thank you.
Date Time Of Last Edit: 2019-09-09 17:08:05
[2019-09-09 17:18:51]
User929084 - Posts: 60
I will look into that regarding post#3.

But when I tried to put my study in cum delta study region and I selected to base it off of cum delta, nothing was displayed.

When I put my study into cum delta region based on main price graph it would display, but everything was squashed due to delta and price values differences.

Thank you.

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

Login

Login Page - Create Account