Delta Reversal Bars Coding Help - futures io
futures io



Delta Reversal Bars Coding Help


Discussion in Sierra Chart

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




Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Delta Reversal Bars Coding Help

(login for full post details)
  #1 (permalink)
Luda Chris
Buffalo, NY
 
 
Posts: 6 since May 2021
Thanks: 12 given, 5 received

I'm trying to code a custom chart bar study using the Sierra provided CustomChartBars_Example. I've compiled and tried the volume example and it looks like that works like it should.

My goal is to create a bar type that prints a new bar after delta has reversed from it's min/max value by x amount. I use a 1-10 point and figure on regular candles and I'd like the same idea applied to delta instead. The problem is I'm not sure on the logic (or anything code related), right now it's just printing new bars instantly for the most part. My DeltaReversalInput is set default to 250, but changing it doesn't do anything, new bars just print instantly.

I'm assuming the problem is on a new bar print the min and max are 0, so any delta move in the right direction is going to just make a new bar. Any help is greatly appreciated!


 
Code
		
		SCInputRef DeltaReversalInput = ChartBarInterface.GetInput(0);
		const uint64_t CurrentBarAskVol = (uint64_t)ChartBarInterface.GetChartBarValue(SC_ASKVOL, ChartBarInterface.CurrentBarIndex);
		const uint64_t CurrentBarBidVol = (uint64_t)ChartBarInterface.GetChartBarValue(SC_BIDVOL, ChartBarInterface.CurrentBarIndex);
		const uint64_t minDelta = (uint64_t)ChartBarInterface.GetChartBarValue(SC_ASKBID_DIFF_LOW, ChartBarInterface.CurrentBarIndex);
		const uint64_t maxDelta = (uint64_t)ChartBarInterface.GetChartBarValue(SC_ASKBID_DIFF_HIGH, ChartBarInterface.CurrentBarIndex);
		int direction = GetRangeBarDirection(ChartBarInterface, ChartBarInterface.CurrentBarIndex);
		float& r_BarHigh = ChartBarInterface.GetChartBarValue(SC_HIGH, ChartBarInterface.CurrentBarIndex);
		float& r_BarLow = ChartBarInterface.GetChartBarValue(SC_LOW, ChartBarInterface.CurrentBarIndex);
		float& r_BarOpen = ChartBarInterface.GetChartBarValue(SC_OPEN, ChartBarInterface.CurrentBarIndex);
		float& r_BarLast = ChartBarInterface.GetChartBarValue(SC_LAST, ChartBarInterface.CurrentBarIndex);
		
		if (direction == 1)// Up
		{
			ChartBarInterface.NewRecordToInsert.High = r_BarHigh;
			ChartBarInterface.NewRecordToInsert.Close = r_BarLast;
			
			if (CurrentBarAskVol-CurrentBarBidVol < (maxDelta - DeltaReversalInput.GetInt()))
			{
				ChartBarInterface.StartNewBarFlag = 1;
				return;
			}
			
		}
		else// Down
		{			

			ChartBarInterface.NewRecordToInsert.Low = r_BarLow;
			ChartBarInterface.NewRecordToInsert.Close = r_BarLast;
			
			if (CurrentBarAskVol-CurrentBarBidVol > (minDelta + DeltaReversalInput.GetInt()))
			
			{
				ChartBarInterface.StartNewBarFlag = 1;
				return;
			}

 
Code
SCSFExport scsf_CustomChartBarsExample(SCStudyInterfaceRef sc)
{
	SCInputRef Input_DeltaReversal = sc.Input[0];

	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		sc.GraphRegion = 0;
		sc.GraphName = "Delta Reversal Bars";
		sc.UsesCustomChartBarFunction = 1;

		// This function is called from another thread.
		sc.fp_ACSCustomChartBarFunction = CustomChartBarBuildingFunction;

		sc.AutoLoop = 0;//Always use manual looping.

		//sc.MaintainAdditionalChartDataArrays = 1;
		//sc.AllocateAndNameRenkoChartBarArrays = 1;

		Input_DeltaReversal.Name = "Delta Reversal Amount";
		Input_DeltaReversal.SetInt(250);
		Input_DeltaReversal.SetIntLimits(250, INT_MAX);

		return;
	}


	int& r_ChartDataReloadedFlag = sc.GetPersistentInt(CUSTOM_CHART_BAR_RELOAD_FLAG_KEY);

	if (r_ChartDataReloadedFlag == 0)
	{
		sc.FlagToReloadChartData = true;
		r_ChartDataReloadedFlag = 1;
	}

	// It is necessary for the study function which creates custom chart bars to detect changes with its own input settings and flag to reload data.

	const int DeltaReversal = Input_DeltaReversal.GetInt();

	int& r_PriorDeltaReversal = sc.GetPersistentInt(1);

	if (r_PriorDeltaReversal!= 0 && r_PriorDeltaReversal != DeltaReversal)
		sc.FlagToReloadChartData = true;

	r_PriorDeltaReversal= DeltaReversal;

	// Set the graph name for this custom bar type.
	if (sc.IsFullRecalculation)
		sc.GraphName.Format("Custom Chart Bar Volume = %d", DeltaReversal);
}

Reply With Quote

Can you help answer these questions
from other members on futures io?
NT8 - Footprint Chart adding on code
NinjaTrader
Learning Day Trading, need some advice on approach advice
Traders Hideout
 
 
(login for full post details)
  #2 (permalink)
Nobreceara
Dublin Ireland
 
 
Posts: 3 since Feb 2022
Thanks: 0 given, 2 received

Hi,

Did you manage to figure out the issue?

I'm going to take a look soon on this.

regards,

Nobre

Reply With Quote
The following user says Thank You to Nobreceara for this post:
 
(login for full post details)
  #3 (permalink)
Luda Chris
Buffalo, NY
 
 
Posts: 6 since May 2021
Thanks: 12 given, 5 received



Nobreceara View Post
Hi,

Did you manage to figure out the issue?

I'm going to take a look soon on this.

regards,

Nobre

Thanks for the response, the project has been put on the backburner, it's above my skillset at the moment. Instead I've modified the cumulative delta bars study with a new option to reset on alert condition. This has allowed me to reset the cumulative delta to 0 automatically from specific events from other subgraphs. This is kind of on the same page as my original idea but the bar type would be very cool to study.


The delta reversal bar type ideally would take a "max" input for the absolute value of the difference between the ask volume and the bid volume, say 200, and then a second input for the reversal amount, let's say 100.

Min/Max Absolute Value = 200
Reversal amount = 100

Then a bar would print until the delta is either 200 or -200, at which point the min/max threshold would be hit. After that any further delta movement would make a new min/max until ultimately delta reverses and falls away from the min/max.

For an example let's say the bar's delta rises steadily with no major reversing to 378 for a max, and then starts to fall again.

Once delta reverses the reversal amount of 100 from it's max of 378 to 278, then a new bar prints.

Reply With Quote


futures io Trading Community Platforms and Indicators Sierra Chart > Delta Reversal Bars Coding Help


Last Updated on April 20, 2022


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2022 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), 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