NexusFi: Find Your Edge


Home Menu

 





Need help in modifying stochastic for price forward projection


Discussion in Sierra Chart

Updated
    1. trending_up 1,705 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 sw88 
New Haven, CT/USA
 
Experience: Beginner
Platform: MT4, thinkorswim
Trading: stocks
Posts: 34 since Jul 2015
Thanks Given: 5
Thanks Received: 3

I want to add one dummy/future price one bar forward to the current bar. For example, if current bar with index 0 with H, L, open, last/close price, last bar with index [-1] with H, L, open, close price; then I want to create a dummy/future bar with index of 1, and assign H=L=open=last price of the current bar (index 0).

When I call stochastic indicator, I'd like the price of the dummy/future bar be used to calculate the value for the next bar based on the assumptive price of H=L=open=last price. I am not sure how to modify the existing source code, as it seems calling a systemic array of price history. Can someone help? appreciate very much!

Here is the source code for the slow stochastics.

/**********************************************************************/
SCSFExport scsf_SlowStochastic(SCStudyInterfaceRef sc)
{
SCSubgraphRef SlowK = sc.Subgraph[0];
SCSubgraphRef SlowD = sc.Subgraph[1];
SCSubgraphRef Line1 = sc.Subgraph[2];
SCSubgraphRef Line2 = sc.Subgraph[3];
SCSubgraphRef Temp4 = sc.Subgraph[4];

SCInputRef FastKLength = sc.Input[2];
SCInputRef FastDLength = sc.Input[3];
SCInputRef SlowDLength = sc.Input[4];
SCInputRef Line1Value = sc.Input[5];
SCInputRef Line2Value = sc.Input[6];
SCInputRef MovAvgType = sc.Input[7];
SCInputRef InputDataHigh = sc.Input[8];
SCInputRef InputDataLow = sc.Input[9];
SCInputRef InputDataLast = sc.Input[10];
SCInputRef UpdateFlag = sc.Input[11];

if ( sc.SetDefaults )
{
sc.GraphName = "Stochastic - Slow";

sc.ValueFormat = 2;

SlowK.Name = "Slow %K";
SlowK.DrawStyle = DRAWSTYLE_LINE;
SlowK.PrimaryColor = RGB(0,255,0);
SlowK.DrawZeros = true;

SlowD.Name = "Slow %D";
SlowD.DrawStyle = DRAWSTYLE_LINE;
SlowD.PrimaryColor = RGB(255,0,255);
SlowD.DrawZeros = true;

Line1.Name = "Line1";
Line1.DrawStyle = DRAWSTYLE_LINE;
Line1.PrimaryColor = RGB(255,255,0);
Line1.DrawZeros = true;

Line2.Name = "Line2";
Line2.DrawStyle = DRAWSTYLE_LINE;
Line2.PrimaryColor = RGB(255,127,0);
Line2.DrawZeros = true;

FastKLength.Name = "Fast %K Length";
FastKLength.SetInt(10);
FastKLength.SetIntLimits(1,MAX_STUDY_LENGTH);

FastDLength.Name = "Fast %D Length (Slow %K)";
FastDLength.SetInt(3);
FastDLength.SetIntLimits(1,MAX_STUDY_LENGTH);

SlowDLength.Name = "Slow %D Length";
SlowDLength.SetInt(3);
SlowDLength.SetIntLimits(1,MAX_STUDY_LENGTH);

Line1Value.Name = "Line1 Value";
Line1Value.SetFloat(70);

Line2Value.Name = "Line2 Value";
Line2Value.SetFloat(30);

MovAvgType.Name = "Moving Average Type";
MovAvgType.SetMovAvgType(MOVAVGTYPE_SIMPLE);

InputDataHigh.Name = "Input Data for High";
InputDataHigh.SetInputDataIndex(SC_HIGH);

InputDataLow.Name = "Input Data for Low";
InputDataLow.SetInputDataIndex(SC_LOW);

InputDataLast.Name = "Input Data for Last";
InputDataLast.SetInputDataIndex(SC_LAST);

UpdateFlag.SetInt(1); //update flag

sc.AutoLoop = true;
return;
}


sc.DataStartIndex = FastKLength.GetInt() + FastDLength.GetInt() + SlowDLength.GetInt();

sc.Stochastic(
sc.BaseData[InputDataHigh.GetInputDataIndex()],
sc.BaseData[InputDataLow.GetInputDataIndex()],
sc.BaseData[InputDataLast.GetInputDataIndex()],
Temp4, // Data member is Fast %K
FastKLength.GetInt(),
FastDLength.GetInt(),
SlowDLength.GetInt(),
MovAvgType.GetMovAvgType()
);

SlowK[sc.Index] = Temp4.Arrays[0][sc.Index];
SlowD[sc.Index] = Temp4.Arrays[1][sc.Index];

Line1[sc.Index] = Line1Value.GetFloat();
Line2[sc.Index] = Line2Value.GetFloat();

return;


}


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Datafeed for Atas
Platforms and Indicators
My Rant with AMP Futures
Trading Reviews and Vendors
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
EA
Platforms and Indicators
Trump Media to sell instant access to market-moving soci …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
Johnnys Journal
2 thanks
TopStep Trader disappointment
2 thanks




Last Updated on February 9, 2016


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts