Support Board
Date/Time: Sun, 24 Nov 2024 09:29:52 +0000
Post From: open range question (for users as well)
[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; } } |