Help for creating slow stochastic in reference to High instead of Low - Sierra Chart Programming | futures io social day trading
futures io futures trading


Help for creating slow stochastic in reference to High instead of Low
Updated: Views / Replies:282 / 2
Created: by sw88 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Help for creating slow stochastic in reference to High instead of Low

  #1 (permalink)
Elite Member
New Haven, CT/USA
 
Futures Experience: Beginner
Platform: MT4, thinkorswim
Favorite Futures: stocks
 
Posts: 34 since Jul 2015
Thanks: 5 given, 3 received

Help for creating slow stochastic in reference to High instead of Low

The stochastic indicator is in reference to the last N period low. I want to create another one to reference to the last N period high. I tried to modify the existing stochastic code. Cannot get it work. Can anyone help me to get it right? Many thanks!

// Windows header file
#include <windows.h>

#include "sierrachart.h"
#include "scstudyfunctions.h"

SCDLLName("Stochastic Slow to High")

void (SCDLLCALL* InternalStochasticHigh2)(SCFloatArrayRef InputDataHigh,

SCFloatArrayRef InputDataLow, SCFloatArrayRef InputDataLast, SCFloatArrayRef

FastKOut, SCFloatArrayRef FastDOut, SCFloatArrayRef SlowDOut, int Index, int

FastKLength, int FastDLength, int SlowDLength, unsigned int MovingAverageType);

void (SCDLLCALL* InternalStochasticHigh)(SCBaseDataRef BaseDataIn, SCFloatArrayRef

FastKOut, SCFloatArrayRef FastDOut, SCFloatArrayRef SlowDOut, int Index, int

FastKLength, int FastDLength, int SlowDLength, unsigned int MovingAverageType);


float GetHighest(SCFloatArrayRef In, int StartIndex, int Length);
float GetLowest(SCFloatArrayRef In, int StartIndex, int Length);

void StochasticHigh(SCBaseDataRef BaseDataIn, SCFloatArrayRef FastKOut,

SCFloatArrayRef FastDOut, SCFloatArrayRef SlowDOut, int Index, int FastKLength, int

FastDLength, int SlowDLength, unsigned int MovingAverageType);

void StochasticHigh2(SCFloatArrayRef InputDataHigh, SCFloatArrayRef InputDataLow,

SCFloatArrayRef InputDataLast, SCFloatArrayRef FastKOut, SCFloatArrayRef FastDOut,

SCFloatArrayRef SlowDOut, int Index, int FastKLength, int FastDLength, int

SlowDLength, unsigned int MovingAverageType);


/*==========================================================================*/
void StochasticHigh(SCBaseDataRef BaseDataIn, SCFloatArrayRef FastKOut,

SCFloatArrayRef FastDOut, SCFloatArrayRef SlowDOut, int Index, int FastKLength, int

FastDLength, int SlowDLength, unsigned int MovingAverageType)
{
StochasticHigh2(BaseDataIn[SC_HIGH], BaseDataIn[SC_LOW], BaseDataIn[SC_LAST],

FastKOut, FastDOut, SlowDOut, Index, FastKLength, FastDLength, SlowDLength,

MovingAverageType);
}

/*==========================================================================*/
void StochasticHigh2(SCFloatArrayRef InputDataHigh, SCFloatArrayRef InputDataLow,

SCFloatArrayRef InputDataLast, SCFloatArrayRef FastKOut, SCFloatArrayRef FastDOut,

SCFloatArrayRef SlowDOut, int Index, int FastKLength, int FastDLength, int

SlowDLength, unsigned int MovingAverageType)
{
float High = GetHighest(InputDataHigh, Index, FastKLength);
float Low = GetLowest(InputDataLow, Index, FastKLength);

float Range = High - Low;
if (Range == 0)
FastKOut[Index] = 100.0f;
else
FastKOut[Index] = 100.0f * (High - InputDataLast[Index]) / Range;

MovingAverage_S(FastKOut, FastDOut, MovingAverageType, Index, FastDLength);
MovingAverage_S(FastDOut, SlowDOut, MovingAverageType, Index, SlowDLength);
}

/****************/
SCSFExport scsf_SlowStochasticHigh(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 = "StochasticHigh - 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.StochasticHigh(
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;


}

Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
New Haven, CT/USA
 
Futures Experience: Beginner
Platform: MT4, thinkorswim
Favorite Futures: stocks
 
Posts: 34 since Jul 2015
Thanks: 5 given, 3 received


Please ignore the above request. I found a much simpler roundabout. It's just 100-stochastic

Reply With Quote

Reply



futures io > > > > > Help for creating slow stochastic in reference to High instead of Low

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Creating Percent off High Indicator eclipsemf ThinkOrSwim Programming 3 November 4th, 2015 10:21 AM
Help! 20 day High Low, 50 day high low indicator mrxdaviepoo NinjaTrader 14 July 8th, 2015 04:49 PM
Despite High Demand, Some Builders Slow Production Quick Summary News and Current Events 0 April 25th, 2013 02:20 PM
NinjaTrader strategy. how to reference lowest low fiki NinjaTrader Programming 5 March 29th, 2010 12:15 AM
3 bar high/low entry maintain active order until 3 bar high/low in opposite direction mrticks NinjaTrader Programming 8 November 13th, 2009 08:44 PM


All times are GMT -4. The time now is 05:54 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-17 in 0.09 seconds with 19 queries on phoenix via your IP 54.163.210.170