Support Board
Date/Time: Sun, 22 Dec 2024 05:40:57 +0000
Post From: Hint needed to code study involving volume at price
[2015-07-29 21:53:39] |
norvik_ - Posts: 106 |
#include "C:\SierraChart\ACS_Source\sierrachart.h"
SCDLLName("PointOfControlPriceOfBar") const int free_dll = 1; SCSFExport scsf_VolumeAtPrice(SCStudyInterfaceRef sc) { SCSubgraphRef POCPrice = sc.Subgraph[0]; SCSubgraphRef temp_POCPrice = sc.Subgraph[1]; SCSubgraphRef POCVolume = sc.Subgraph[2]; SCInputRef maLength = sc.Input[0]; SCInputRef UseMA = sc.Input[2]; SCInputRef Type = sc.Input[3]; SCInputRef FastSmoothConstant = sc.Input[4]; SCInputRef SlowSmoothConstant = sc.Input[5]; if (sc.SetDefaults) { sc.AutoLoop = 1; // true sc.GraphRegion = 0; sc.FreeDLL = free_dll; sc.StudyDescription = "This study indicate Price Of POC Of Bar."; sc.AutoLoop = 1; FastSmoothConstant.Name = "FastSmoothConstant"; FastSmoothConstant.SetFloat(2.0); SlowSmoothConstant.Name = "SlowSmoothConstant"; SlowSmoothConstant.SetFloat(7.0); maLength.Name = "MovAvg Length"; maLength.SetInt(3); maLength.SetIntLimits(1,100); Type.Name = "Type"; Type.SetMovAvgType(MOVAVGTYPE_SIMPLE_SKIP_ZEROS); sc.MaintainVolumeAtPriceData = 1; // true UseMA.Name = "Using Simple MA Or Adaptive "; UseMA.SetCustomInputStrings("Not Use;Use Simple MA;Use MA Adaptive"); UseMA.SetCustomInputIndex(0); UseMA.SetIntLimits(0,2); POCPrice.Name = "POC Volume"; POCPrice.DrawStyle = DRAWSTYLE_LINE; POCPrice.LineWidth = 2; POCPrice.PrimaryColor = RGB(0,255,255); return; } if ((int)sc.VolumeAtPriceForBars->GetNumberOfBars() < sc.ArraySize) return; unsigned int VolumeAtPriceLevel = 0; unsigned int pVolume = 0; float Price = 0.0; float pocPrice = 0.0; s_VolumeAtPriceV2 *p_VolumeAtPriceAtIndex; int Count = sc.VolumeAtPriceForBars-> GetSizeAtBarIndex(sc.Index); for (int ElementIndex = 0;ElementIndex < Count; ElementIndex ++) { sc.VolumeAtPriceForBars->GetVAPElementAtIndex(sc.Index, ElementIndex, &p_VolumeAtPriceAtIndex); if (p_VolumeAtPriceAtIndex) { VolumeAtPriceLevel = p_VolumeAtPriceAtIndex->Volume; Price = p_VolumeAtPriceAtIndex->PriceInTicks * sc.TickSize; } if (VolumeAtPriceLevel > pVolume) { pVolume = VolumeAtPriceLevel; pocPrice = Price; } } temp_POCPrice[sc.Index] = pocPrice; switch(UseMA.IntValue) { case 0:POCPrice[sc.Index] = temp_POCPrice[sc.Index];break; case 1:sc.MovingAverage(temp_POCPrice, POCPrice , Type.GetMovAvgType(), maLength.GetInt());break; case 2:sc.AdaptiveMovAvg(temp_POCPrice, POCPrice, maLength.GetInt(),FastSmoothConstant.GetFloat(),SlowSmoothConstant.GetFloat());break; } POCVolume[sc.Index] = pVolume; } I code it several years ago, may be it help. |