Login Page - Create Account

Support Board


Date/Time: Sun, 22 Dec 2024 08:33:50 +0000



[User Discussion] - User Discussion: ACSIL for Gap studies

View Count: 2548

[2015-04-02 03:55:11]
Kiwi - Posts: 375
Do gaps matter in your tradable?

Recency often makes me think that they do for M1 HSI but a study will show you whether its true or not. Here's some code you can use in a dll (modify as you will) that shows gaps between close and the next low or high until they are filled or the day ends.

Note that you'll need to change the hours ... mine is based on 2 hsi sessions.


/***********************************************************************/
SCSFExport scsf_gap(SCStudyGraphRef sc)
{
SCSubgraphRef   gtop = sc.Subgraph[0], gbot = sc.Subgraph[1], gp = sc.Subgraph[5];
SCSubgraphRef   o0 = sc.Subgraph[7], o1 = sc.Subgraph[8];
if (sc.SetDefaults) {
    sc.GraphName="Gap";
    sc.StudyDescription="";
    gtop.Name="Gt";
    gbot.Name="Gb";
    gp.Name="Gap";
    o0.Name="0";
    o1.Name="1";
    sc.DrawZeros=0;
    sc.GraphRegion=0;
    sc.FreeDLL = 1;
    return;
  }
  
  int    i, j, gap;
  float  gaph, gapl, gapc;
  SCBaseDataRef DIn = sc.BaseDataIn;      
  int const hx = 1, lx = 2, cx = 3;

  for (i=sc.UpdateStartIndex; i < sc.ArraySize; i++) {
    gtop[i]=0; gbot[i]=0; int p=i-1;
    if((sc.BaseDateTimeIn[i].GetTime()>HMS_TIME(9,55,00) && sc.BaseDateTimeIn[i].GetTime()<HMS_TIME(12,30,00))
      || (sc.BaseDateTimeIn[i].GetTime()>HMS_TIME(14,32,00) && sc.BaseDateTimeIn[i].GetTime()<HMS_TIME(16,15,00)))
    {
      int const lookback=2;
      gap=+1;
      gapl=DIn[cx][i-lookback];
      gaph=DIn[lx][i-lookback+1];
       for(j=i;j>i-lookback;j--) { // looking for gap up
          if(DIn[lx][j]<=gapl) gap=0; else if(DIn[lx][j]<gaph) gaph=DIn[lx][j];
        }
      if(gap==0) {
        gap=-1;
        gaph=DIn[cx][i-lookback];
        gapl=DIn[hx][i-lookback+1];
        for(j=i;j>i-lookback;j--) { // looking for gap down
          if(DIn[hx][j]>=gaph) gap=0; else if(DIn[hx][j]>gapl) gapl=DIn[hx][j];
        }
      }
      
      if(gap==+1) for(j=i;j>i-lookback;j--) { gtop[j]=gaph; gbot[j]=gapl; } else
      if(gap==-1) for(j=i;j>i-lookback;j--) { gtop[j]=gapl; gbot[j]=gaph; }
      gp[i]=gap;
      if(gp[p]==+1 && DIn[lx][i]>=gtop[p]) { gtop[i]=gtop[p]; gbot[i]=gbot[p]; gp[i]=gp[p]; } else
      if(gp[p]==-1 && DIn[hx][i]<=gbot[p]) { gtop[i]=gtop[p]; gbot[i]=gbot[p]; gp[i]=gp[p]; }
    }
  }
}




Here's what it draws.

http://i.imgur.com/w9TREkG.png
[2015-04-02 05:46:17]
crazybears - Posts: 314
Hi Kiwi

thanks for your code .

is it possible to draw lines also for more than 1 day ?

i mean if there is a gap yesterday or some day ago that isn't already closed .

thanks.


[2015-04-05 07:48:57]
Kiwi - Posts: 375
Yes. You can take the code and alter it to do pretty much whatever is important to you.

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

Login

Login Page - Create Account