Login Page - Create Account

Support Board


Date/Time: Sun, 24 Nov 2024 09:25:16 +0000



[User Discussion] - open range question (for users as well)

View Count: 4658

[2013-09-10 22:06:47]
M5amhan - Posts: 468
is there anyway I can use a 5 minute open range with 2.33 & -2.33 extensions from it? i know initial balance does this but it requires time and the 4 markets I trade open at different times and I use the same chart with a quote board. so would it be possible or does anyone have a study that only registers the first 5 minutes of the session no matter what time it opens? i believe i could use study subgraph multiplier at that point if i could even get that far.

anyway that would be greatly appreciated if anyone could help me out here

also my session times are set to only pit session so i would just literally need the first 5 minutes of Monday, Tuesday, etc..

thanks
[2013-10-08 12:09:56]
ganz - Posts: 1048
Trade2day1

In case you are using a time-based chart w 1- or 5- min bars then there is the simple example using sc.GetOHLCOfTimePeriod:

http://s1.ipicture.ru/uploads/20131008/JU0htnkG.png


#include "sierrachart.h"

SCDLLName("or_b1");

SCSFExport scsf_or(SCStudyInterfaceRef sc)
{
  SCSubgraphRef op_rng_h     = sc.Subgraph[0];
  SCSubgraphRef op_rng_l     = sc.Subgraph[1];
  SCInputRef   or_time     = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName       = "open range";
    sc.StudyDescription   = "open range >> beta 1 << @ganz";

    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;
    op_rng_h.PrimaryColor   = RGB(0,255,0);
    op_rng_h.LineWidth     = 2;
    
    op_rng_l.Name       = "op_rng_low";
    op_rng_l.DrawStyle     = DRAWSTYLE_DASH;
    op_rng_l.PrimaryColor   = RGB(255,0,0);
    op_rng_l.LineWidth     = 2;
    
    or_time.Name       = "Open range (seconds)";
    or_time.SetInt(299);
    or_time.SetIntLimits(0, 2123456789);
        
    sc.GraphRegion       = 0;    
    sc.AutoLoop       = 1;
    sc.FreeDLL         = 1; // set it to zero for high perf
    
    return;
  }
      
  SCDateTime dt_StartTime, dt_EndTime;
  
  dt_StartTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  dt_EndTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  
  dt_StartTime.SetTime(sc.StartTime1);
  dt_EndTime.SetTime(sc.StartTime1 + or_time.GetInt());
  

  float& High     = sc.PersistVars->f1;
  float& Low       = sc.PersistVars->f2;
  float& Open      = sc.PersistVars->f3;
  
  float Close;
  float NextOpen;  

  sc.GetOHLCOfTimePeriod(dt_StartTime, dt_EndTime, Open, High, Low, Close, NextOpen) ;
  
  op_rng_h[sc.Index] = High;
  op_rng_l[sc.Index] = Low;  
  
}


pls let me know if this is not the case
Date Time Of Last Edit: 2013-10-08 12:10:30
[2013-10-08 12:37:42]
M5amhan - Posts: 468
no im not using a time chart, i only switch to a 5 minute when i am snapping the fib retracement then i go back to my 150t.. did you get my response in the other thread?

[usr dscssn] two NICs for a Box on Ubuntu/Linux
[2013-10-08 12:50:33]
ganz - Posts: 1048
Trade2day1

yes i saw it.

ok. i'll try to improve it.
[2013-10-08 12:53:16]
M5amhan - Posts: 468
i really appreciate it.. i completely forgot about that nuance when i first asked you
[2013-10-08 13:14:39]
ganz - Posts: 1048
Trade2day1

no prblm. i'll try.

at this moment you could add a 5-min chart, link them by a Symbol and overlay or_b1.dll to the basic chart.
[2013-10-09 13:05:25]
M5amhan - Posts: 468
i will just use the retracement until i hear from you.. i still need to install the compiler and snap the open range depending on the open/close
[2013-10-11 17:49:06]
ganz - Posts: 1048
Trade2day1

hi

now we know it ACSIL memeber to access a certain file record from *.scid

so i don't know an easy way to get a Close/Opne/etc value from *.scid directly.

and this means we need 1- or 5- min chart for this study and overlay it to the basic chart

and you are able to modify *.cpp as you need it, to use subgraphs and multiply them

this is > beta 2 <


#include "sierrachart.h"

SCDLLName("or_b2");

SCSFExport scsf_or(SCStudyInterfaceRef sc)
{
  SCSubgraphRef op_rng_h     = sc.Subgraph[1];
  SCSubgraphRef op_rng_l     = sc.Subgraph[2];
  SCSubgraphRef op_open     = sc.Subgraph[0];
  SCInputRef     or_time     = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName       = "open range";
    sc.StudyDescription   = "open range >> beta 2 << @ganz";

    op_open.Name       = "op_rng_Open";
    op_open.DrawStyle     = DRAWSTYLE_DASH;
    op_open.PrimaryColor   = RGB(255,255,255);
    op_open.LineWidth     = 2;
    
    op_rng_l.Name       = "op_rng_low";
    op_rng_l.DrawStyle     = DRAWSTYLE_DASH;    
    op_rng_l.LineWidth     = 2;
    
    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;    
    op_rng_h.LineWidth     = 2;
    
    or_time.Name       = "Open range (seconds)";
    or_time.SetInt(299);
    or_time.SetIntLimits(0, 2123456789);
        
    sc.GraphRegion       = 0;    
    sc.AutoLoop       = 1;
    sc.FreeDLL         = 1; // set it to zero for high perf
    
    return;
  }
      
  SCDateTime dt_StartTime, dt_EndTime;
  
  dt_StartTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  dt_EndTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  
  dt_StartTime.SetTime(sc.StartTime1);
  dt_EndTime.SetTime(sc.StartTime1 + or_time.GetInt());  

  float& High     = sc.PersistVars->f1;
  float& Low       = sc.PersistVars->f2;
  float& Open      = sc.PersistVars->f3;  
  float& Close    = sc.PersistVars->f4;
  
  float NextOpen;  

  sc.GetOHLCOfTimePeriod(dt_StartTime, dt_EndTime, Open, High, Low, Close, NextOpen) ;
  
  // reverse colors for High and Low if Close > Open and vice versa

  if ( Close >= Open ) { op_rng_h.PrimaryColor = RGB(0,255,0); op_rng_l.PrimaryColor   = RGB(255,0,0); }
  else { op_rng_h.PrimaryColor = RGB(255,0,0); op_rng_l.PrimaryColor   = RGB(0,255,0); }
  
  op_open [sc.Index] = Open;
  op_rng_h[sc.Index] = High;
  op_rng_l[sc.Index] = Low;  
  
}


[2013-10-11 17:57:16]
M5amhan - Posts: 468
awesome, i can open up a 1min and just have it tucked away. installing the compiler now, will let you know when i get it up and running
[2013-10-11 19:03:24]
M5amhan - Posts: 468
http://www.sierrachart.com/image.php?l=1381517057292.png = ganz open range

http://www.sierrachart.com/image.php?l=1381517238592.png = Fibonacci grid
http://www.sierrachart.com/image.php?l=1381517660399.png = color coded grid to see easier

i got it working, a few things though

1) i cant figure out at all how to make the extensions (study subgraph multiply/add/divide/std dev none of those work correctly).. the extensions in the initial balance study would work if they knew which side to plot on.. i could use 1.33, 2.82, etc for positive side and -2.33, -3.82, etc. for negative side

2) it looks like if the extensions did work, they wouldn't be able to differentiate between a positive/negative 5 min open range to know which side they should plot on.. if i am wrong plz explain to me what to do

thanks again for your patience


[2013-10-11 19:19:23]
ganz - Posts: 1048
Trade2day1

thnx 4 the explanation. now i can see as it should be.
i'm interested to get it working and i'll be back w the >beta 3<
[2013-10-11 19:23:20]
M5amhan - Posts: 468
haha ok, you're awesome

it is a great tool to use for targets and trend bias, even support/resistance sometimes
[2013-10-11 19:48:51]
ganz - Posts: 1048
Trade2day1

:)

try this >beta 3<


#include "sierrachart.h"

SCDLLName("or_b3");

SCSFExport scsf_or(SCStudyInterfaceRef sc)
{
  SCSubgraphRef op_rng_h     = sc.Subgraph[1];
  SCSubgraphRef op_rng_l     = sc.Subgraph[2];
  SCSubgraphRef op_open     = sc.Subgraph[0];
  
  SCSubgraphRef op_rng_2h     = sc.Subgraph[3];
  SCSubgraphRef op_rng_3h     = sc.Subgraph[4];
  SCSubgraphRef op_rng_5h     = sc.Subgraph[5];
  
  SCSubgraphRef op_rng_2l     = sc.Subgraph[6];
  SCSubgraphRef op_rng_3l     = sc.Subgraph[7];
  SCSubgraphRef op_rng_5l     = sc.Subgraph[8];
    
  SCInputRef     or_time     = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName       = "open range";
    sc.StudyDescription   = "open range >> beta 3 << @ganz";

    op_open.Name       = "op_rng_Open";
    op_open.DrawStyle     = DRAWSTYLE_DASH;
    op_open.PrimaryColor   = RGB(255,255,255);
    op_open.LineWidth     = 2;
    
    op_rng_l.Name       = "op_rng_low";
    op_rng_l.DrawStyle     = DRAWSTYLE_DASH;    
    op_rng_l.LineWidth     = 2;
    
    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;      
    op_rng_h.LineWidth     = 2;
    
    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;      
    op_rng_h.LineWidth     = 2;
    
    op_rng_2h.Name       = "op_rng_233";
    op_rng_2h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_2h.LineWidth   = 2;
    
    op_rng_3h.Name       = "op_rng_382";
    op_rng_3h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_3h.LineWidth   = 2;
    
    op_rng_5h.Name       = "op_rng_512";
    op_rng_5h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_5h.LineWidth   = 2;
    
    op_rng_2l.Name       = "op_rng_(233)";
    op_rng_2l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_2l.LineWidth   = 2;
    
    op_rng_3l.Name       = "op_rng_(382)";
    op_rng_3l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_3l.LineWidth   = 2;
    
    op_rng_5l.Name       = "op_rng_(512)";
    op_rng_5l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_5l.LineWidth   = 2;
    
    or_time.Name       = "Open range (seconds)";
    or_time.SetInt(299);
    or_time.SetIntLimits(0, 2123456789);
        
    sc.GraphRegion       = 0;    
    sc.AutoLoop       = 1;
    sc.FreeDLL         = 1; // set it to zero for high perf
    
    return;
  }
      
  SCDateTime dt_StartTime, dt_EndTime;
  
  dt_StartTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  dt_EndTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  
  dt_StartTime.SetTime(sc.StartTime1);
  dt_EndTime.SetTime(sc.StartTime1 + or_time.GetInt());  

  float& High     = sc.PersistVars->f1;
  float& Low       = sc.PersistVars->f2;
  float& Open      = sc.PersistVars->f3;  
  float& Close    = sc.PersistVars->f4;
  float NextOpen;
  float& OpRange    = sc.PersistVars->f5;

  sc.GetOHLCOfTimePeriod(dt_StartTime, dt_EndTime, Open, High, Low, Close, NextOpen) ;  
  
  OpRange = High - Low;
  op_open [sc.Index] = Open;
  op_rng_h[sc.Index] = High;
  op_rng_l[sc.Index] = Low;
  
  if ( Close >= Open) {    
    op_rng_2h[sc.Index] = High + OpRange*2.33;
    op_rng_3h[sc.Index] = High + OpRange*3.82;
    op_rng_5h[sc.Index] = High + OpRange*5.12;
  
    op_rng_2l[sc.Index] = High - OpRange*2.33;
    op_rng_3l[sc.Index] = High - OpRange*3.82;
    op_rng_5l[sc.Index] = High - OpRange*5.12;        
  }
  else {
    op_rng_2h[sc.Index] = Low + OpRange*2.33;
    op_rng_3h[sc.Index] = Low + OpRange*3.82;
    op_rng_5h[sc.Index] = Low + OpRange*5.12;
  
    op_rng_2l[sc.Index] = Low - OpRange*2.33;
    op_rng_3l[sc.Index] = Low - OpRange*3.82;
    op_rng_5l[sc.Index] = Low - OpRange*5.12;    
  }  
}


[2013-10-11 20:02:59]
M5amhan - Posts: 468
that is exactly right! thanks a ton

i just need two more extensions 7.86 and 12.18
Date Time Of Last Edit: 2013-10-11 20:10:26
[2013-10-11 20:16:55]
ganz - Posts: 1048
Trade2day1

+7.86
+12.18

> beta 4<


#include "sierrachart.h"

SCDLLName("or_b4");

SCSFExport scsf_or(SCStudyInterfaceRef sc)
{
  SCSubgraphRef op_rng_h     = sc.Subgraph[1];
  SCSubgraphRef op_rng_l     = sc.Subgraph[2];
  SCSubgraphRef op_open     = sc.Subgraph[0];
  
  SCSubgraphRef op_rng_2h     = sc.Subgraph[3];
  SCSubgraphRef op_rng_3h     = sc.Subgraph[4];
  SCSubgraphRef op_rng_5h     = sc.Subgraph[5];
  SCSubgraphRef op_rng_7h     = sc.Subgraph[6];
  SCSubgraphRef op_rng_12h     = sc.Subgraph[7];
  
  SCSubgraphRef op_rng_2l     = sc.Subgraph[8];
  SCSubgraphRef op_rng_3l     = sc.Subgraph[9];
  SCSubgraphRef op_rng_5l     = sc.Subgraph[10];
  SCSubgraphRef op_rng_7l     = sc.Subgraph[11];
  SCSubgraphRef op_rng_12l     = sc.Subgraph[12];
    
  SCInputRef     or_time     = sc.Input[0];

  if (sc.SetDefaults)
  {
    sc.GraphName       = "open range";
    sc.StudyDescription   = "open range >> beta 4 << @ganz";

    op_open.Name       = "op_rng_Open";
    op_open.DrawStyle     = DRAWSTYLE_DASH;
    op_open.PrimaryColor   = RGB(255,255,255);
    op_open.LineWidth     = 2;
    
    op_rng_l.Name       = "op_rng_low";
    op_rng_l.DrawStyle     = DRAWSTYLE_DASH;    
    op_rng_l.LineWidth     = 2;
    
    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;      
    op_rng_h.LineWidth     = 2;
    
    op_rng_h.Name       = "op_rng_high";
    op_rng_h.DrawStyle     = DRAWSTYLE_DASH;      
    op_rng_h.LineWidth     = 2;
    
    op_rng_2h.Name       = "op_rng_233";
    op_rng_2h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_2h.LineWidth   = 2;
    
    op_rng_3h.Name       = "op_rng_382";
    op_rng_3h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_3h.LineWidth   = 2;
    
    op_rng_5h.Name       = "op_rng_512";
    op_rng_5h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_5h.LineWidth   = 2;
    
    op_rng_7h.Name       = "op_rng_786";
    op_rng_7h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_7h.LineWidth   = 2;
    
    op_rng_12h.Name      = "op_rng_1218";
    op_rng_12h.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_12h.LineWidth   = 2;
            
    op_rng_2l.Name       = "op_rng_(233)";
    op_rng_2l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_2l.LineWidth   = 2;
    
    op_rng_3l.Name       = "op_rng_(382)";
    op_rng_3l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_3l.LineWidth   = 2;
    
    op_rng_5l.Name       = "op_rng_(512)";
    op_rng_5l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_5l.LineWidth   = 2;
    
    op_rng_7l.Name       = "op_rng_(786)";
    op_rng_7l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_7l.LineWidth   = 2;
    
    op_rng_12l.Name      = "op_rng_(1218)";
    op_rng_12l.DrawStyle   = DRAWSTYLE_DASH;      
    op_rng_12l.LineWidth   = 2;    
        
    or_time.Name       = "Open range (seconds)";
    or_time.SetInt(299);
    or_time.SetIntLimits(0, 2123456789);
        
    sc.GraphRegion       = 0;    
    sc.AutoLoop       = 1;
    sc.FreeDLL         = 0; // set it to zero for high perf
    
    return;
  }
      
  SCDateTime dt_StartTime, dt_EndTime;
  
  dt_StartTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  dt_EndTime.SetDate(sc.GetTradingDayDate(sc.BaseDateTimeIn[sc.Index]));
  
  dt_StartTime.SetTime(sc.StartTime1);
  dt_EndTime.SetTime(sc.StartTime1 + or_time.GetInt());  

  float& High     = sc.PersistVars->f1;
  float& Low       = sc.PersistVars->f2;
  float& Open      = sc.PersistVars->f3;  
  float& Close    = sc.PersistVars->f4;
  float NextOpen;
  float& OpRange    = sc.PersistVars->f5;

  sc.GetOHLCOfTimePeriod(dt_StartTime, dt_EndTime, Open, High, Low, Close, NextOpen) ;  
  
  OpRange = High - Low;
  op_open [sc.Index] = Open;
  op_rng_h[sc.Index] = High;
  op_rng_l[sc.Index] = Low;
  
  if ( Close >= Open) {    
    op_rng_2h[sc.Index] = High + OpRange*2.33;
    op_rng_3h[sc.Index] = High + OpRange*3.82;
    op_rng_5h[sc.Index] = High + OpRange*5.12;
    op_rng_7h[sc.Index] = High + OpRange*7.86;
    op_rng_12h[sc.Index]= High + OpRange*12.18;
    
    op_rng_2l[sc.Index] = High - OpRange*2.33;
    op_rng_3l[sc.Index] = High - OpRange*3.82;
    op_rng_5l[sc.Index] = High - OpRange*5.12;
    op_rng_7l[sc.Index] = High - OpRange*7.86;
    op_rng_12l[sc.Index]= High - OpRange*12.18;
            
  }
  else {
    op_rng_2h[sc.Index] = Low + OpRange*2.33;
    op_rng_3h[sc.Index] = Low + OpRange*3.82;
    op_rng_5h[sc.Index] = Low + OpRange*5.12;
    op_rng_7h[sc.Index] = Low + OpRange*7.86;
    op_rng_12h[sc.Index]= Low + OpRange*12.18;
  
    op_rng_2l[sc.Index] = Low - OpRange*2.33;
    op_rng_3l[sc.Index] = Low - OpRange*3.82;
    op_rng_5l[sc.Index] = Low - OpRange*5.12;
    op_rng_7l[sc.Index] = Low - OpRange*7.86;
    op_rng_12l[sc.Index]= Low - OpRange*12.18;    
  }  
}


Date Time Of Last Edit: 2013-10-11 20:17:19
[2013-10-11 20:18:13]
M5amhan - Posts: 468
awesome thanks again man
[2013-10-11 20:27:46]
ganz - Posts: 1048
Trade2day1

it was interesting.

good luck.
[2013-10-12 19:33:17]
User76055 - Posts: 18
Sorry a newbie here but can this study be available to use.

Thanks!
[2013-10-12 19:36:18]
M5amhan - Posts: 468
it is available, you need to install the compiler through Analysis > Build Custom Studies DLL > Install Compiler then when it has completed downloading follow the instructions on this page: http://www.sierrachart.com/index.php?l=doc/doc_BuildCustomStudiesDLL.html

also i can give you a few pointers when you get it up and running if you'd like ;D
[2013-10-12 20:06:44]
User76055 - Posts: 18
Trade2day1

Got it working! I've also looked at NQ for these setups and has done well, knowing my luck it will fail when I go live lol...cheers!
Date Time Of Last Edit: 2013-10-12 20:08:02
imageTF 5min Open Range Chart.png / V - Attached On 2013-10-12 20:07:56 UTC - Size: 40.04 KB - 700 views
[2013-10-12 20:13:03]
M5amhan - Posts: 468
well thanks to ganz for being so awesome, i was able to run statistics on the probabilities of price hitting these extensions during the pit session. they are very compelling, of course you still need an entry system to compliment these targets.

http://www.sierrachart.com/image.php?l=1381542568892.png = crude oil
http://www.sierrachart.com/image.php?l=1381542885143.png = russell 2000
http://www.sierrachart.com/image.php?l=1381543389587.png = S&P 500

i knew how high the probability was of hitting these targets already just from using it for a while, but seeing it visually like this really should hold you accountable to hold your winners and trail stops in a way to give price a chance to hit the targets

a tip on the time frame, if you are using tick charts it will only calculate correctly using 1000t or less.. i don't know why, but that's what i found out


Date Time Of Last Edit: 2015-04-20 16:49:07
Private File
Attachment Deleted.
[2013-10-12 20:40:24]
User76055 - Posts: 18
Thanks ganz!

Stop entries 1 tick above/below bars with a stop below the 5 min bars is what I was using on manual lookbacks, proble is on some occasions, the move may be fast so may miss at times if entering slow on stop entries right after the close of the 5min bar...work in progress!

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

Login

Login Page - Create Account