NexusFi: Find Your Edge


Home Menu

 





What is wrong with that ? Arraly pole1 and pole2 empty ?!?!


Discussion in Sierra Chart

Updated
      Top Posters
    1. looks_one bluewave65 with 3 posts (0 thanks)
    2. looks_two yonatan with 2 posts (1 thanks)
    3. looks_3 Quick Summary with 1 posts (0 thanks)
    4. looks_4 mkata with 1 posts (0 thanks)
    1. trending_up 1,202 views
    2. thumb_up 1 thanks given
    3. group 3 followers
    1. forum 6 posts
    2. attach_file 1 attachments




 
Search this Thread

What is wrong with that ? Arraly pole1 and pole2 empty ?!?!

  #1 (permalink)
bluewave65
CZECH REPUBLIC
 
Posts: 24 since Nov 2015
Thanks Given: 1
Thanks Received: 0

Hi, i got a simple code , but arrays pole1 and pole2 remain empty ? Why ?
Pls HELP ....

dave

p.s.: Original sierra code with
InputArray1.SetStudySubgraphValues(0,0);
sc.GetStudyArrayUsingID(

works just fine ...... i don`t get it
I just need get arrays from another chart ....



 
Code
#include "c:\uziv\trade\1510\ACS_Source\sierrachart.h"

SCDLLName("KORELACE") 

/*==========================================================================*/
SCSFExport scsf_korelace(SCStudyInterfaceRef sc)
{
	SCSubgraphRef CC1 = sc.Subgraph[0];

	SCInputRef InputArray1 = sc.Input[0];
	SCInputRef InputArray2 = sc.Input[1];

	SCInputRef Length = sc.Input[6];

	if(sc.SetDefaults)	
	{
		sc.GraphName = "KORELACE";

		sc.GraphRegion = 1;

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

					
		InputArray1.Name = "CC1 - Instrument 1";
		InputArray1.SetChartStudySubgraphValues(1, 0, 0);
		InputArray2.Name = "CC1 - Instrument 2";
		InputArray2.SetChartStudySubgraphValues(1, 0, 0);


		Length.Name = "Interval";
		Length.SetInt(200);

		sc.AutoLoop = 1;
		sc.FreeDLL = 1;
		sc.CalculationPrecedence = LOW_PREC_LEVEL;
		
		return;
	}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Definovani Poli Pro Prevzeti Dat z Externich Grafu

	sc.DataStartIndex = Length.GetInt();

	SCFloatArray pole1;
	sc.GetStudyArrayFromChartUsingID(InputArray1.GetChartStudySubgraphValues(), pole1);
	if(pole1.GetArraySize() < sc.ArraySize)
		return;

	SCFloatArray pole2;
	sc.GetStudyArrayFromChartUsingID(InputArray2.GetChartStudySubgraphValues(), pole2);
	if(pole2.GetArraySize() < sc.ArraySize)
		return;

	CC1[sc.Index] = sc.GetCorrelationCoefficient(pole1, pole2, Length.GetInt());

}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
MC PL editor upgrade
MultiCharts
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
16 thanks
  #3 (permalink)
 yonatan 
Haifa Israel
 
Experience: Beginner
Platform: sierra chart
Broker: Optimus Trading Group/Rithmic
Trading: es
Posts: 91 since Apr 2012
Thanks Given: 50
Thanks Received: 71


As you ca see here:

InputArray1.Name = "CC1 - Instrument 1";
InputArray1.SetChartStudySubgraphValues(1, 0, 0);
InputArray2.Name = "CC1 - Instrument 2";
InputArray2.SetChartStudySubgraphValues(1, 0, 0);

Both InputArray1 and InputArray2 point to Subgraph 0 of Study 0 on Chart 1.
Is this want you want? Are you using the default settings ?

Reply With Quote
  #4 (permalink)
bluewave65
CZECH REPUBLIC
 
Posts: 24 since Nov 2015
Thanks Given: 1
Thanks Received: 0

I know ... but it isn`t a problem ....
If i change it ........ no solution ........ same problem .......

Reply With Quote
  #5 (permalink)
 yonatan 
Haifa Israel
 
Experience: Beginner
Platform: sierra chart
Broker: Optimus Trading Group/Rithmic
Trading: es
Posts: 91 since Apr 2012
Thanks Given: 50
Thanks Received: 71

I added to the code a few lines that send the values of the compared 2 arrays to the message log. As you can see in the attached txt file the arrays are definitely not empty. I compared the Sp-TICK and NYSE-Tick, not CCIs.
One reason for getting zeros in the arrays is if the chart on which you apply the study has a larger sc.ArraySize (More bars) than the charts that you reference. In this case pole1[sc.Index] and pole2[sc.Index] will have zeros for sc.Index values that are larger than the last sc.Index on those charts.

p.s here is your code with the addition of the lines that send the arrays values to the message log.

#include "sierrachart.h"

SCDLLName("KORELACE")

/*=============================================*/
SCSFExport scsf_korelace(SCStudyInterfaceRef sc)
{
SCSubgraphRef CC1 = sc.Subgraph[0];

SCInputRef InputArray1 = sc.Input[0];
SCInputRef InputArray2 = sc.Input[1];

SCInputRef Length = sc.Input[6];

if(sc.SetDefaults)
{
sc.GraphName = "KORELACE";

sc.GraphRegion = 1;

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


InputArray1.Name = "CC1 - Instrument 1";
InputArray1.SetChartStudySubgraphValues(1, 0, 0);
InputArray2.Name = "CC1 - Instrument 2";
InputArray2.SetChartStudySubgraphValues(1, 0, 0);


Length.Name = "Interval";
Length.SetInt(200);

sc.AutoLoop = 1;
sc.FreeDLL = 1;
sc.CalculationPrecedence = LOW_PREC_LEVEL;

return;
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Definovani Poli Pro Prevzeti Dat z Externich Grafu

sc.DataStartIndex = Length.GetInt();

SCFloatArray pole1;
sc.GetStudyArrayFromChartUsingID(InputArray1.GetChartStudySubgraphValues(), pole1);
if(pole1.GetArraySize() < sc.ArraySize)
return;


SCFloatArray pole2;
sc.GetStudyArrayFromChartUsingID(InputArray2.GetChartStudySubgraphValues(), pole2);
if(pole2.GetArraySize() < sc.ArraySize)
return;

SCString str;
str.Format("NYSE_ Tick = %f ------ SP Tick = %f",pole1[sc.Index], pole2[sc.Index]);
sc.AddMessageToLog(str, 0);




CC1[sc.Index] = sc.GetCorrelationCoefficient(pole1, pole2, Length.GetInt());

}

Attached Files
Elite Membership required to download: KORELACE_Arrays.txt
Reply With Quote
Thanked by:
  #6 (permalink)
bluewave65
CZECH REPUBLIC
 
Posts: 24 since Nov 2015
Thanks Given: 1
Thanks Received: 0

 
Code
#include "c:\uziv\trade\1510\ACS_Source\sierrachart.h"

SCDLLName("KORELACE") 

/*==========================================================================*/
SCSFExport scsf_korelace(SCStudyInterfaceRef sc)
{
	SCSubgraphRef CC1 = sc.Subgraph[0];


	SCInputRef InputArray1 = sc.Input[0];
	SCInputRef InputIndex = sc.Input[1];
	

	SCInputRef Length = sc.Input[3];

	if(sc.SetDefaults)	
	{
		sc.GraphName = "KORELACE";

		sc.GraphRegion = 1;

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


		InputArray1.Name = "Instrument 1";
		InputArray1.SetChartNumber(1);

		InputIndex.Name = "Input Index";
		InputIndex.SetInputDataIndex(SC_LAST);


		Length.Name = "Interval";
		Length.SetInt(200);

		sc.AutoLoop = 1;
		sc.FreeDLL = 1;
		sc.CalculationPrecedence = LOW_PREC_LEVEL;
		
		return;
	}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Definovani Poli Pro Prevzeti Dat z Externich Grafu

	sc.DataStartIndex = Length.GetInt();


	SCFloatArray pole1;
	sc.GetChartArray(-InputArray1.GetChartNumber(), InputIndex.GetInputDataIndex(), pole1 );
	
	int Chart1Index = sc.GetNearestMatchForDateTimeIndex(InputArray1.GetChartNumber(), sc.Index);
	

	//CC1[sc.Index] = pole1[Chart1Index];
	CC1[sc.Index] = sc.GetCorrelationCoefficient(pole1[Chart1Index], sc.BaseDataIn[SC_LAST] , Length.GetInt());

	
}
------

I got a problem with make this function work ......

error C2664: 'float s_sc::GetCorrelationCoefficient(SCFloatArrayRef,SCFloatArrayRef,int)' : cannot convert parameter 1 from 'float' to 'SCFloatArrayRef'

Howto get a correlation coefficient from basedata and referenced sc_last ..... ?


Thanks a lot
dave

Reply With Quote
  #7 (permalink)
 mkata 
Columbus, OH
 
Experience: Intermediate
Platform: SierraChart
Trading: CL
Posts: 35 since May 2013
Thanks Given: 153
Thanks Received: 24

If you delete this [Chart1Index] from your function call it should compile.

The last line should read sc.GetCorrelationCoefficient(pole1, sc.BaseDataIn[SC_LAST] , Length.GetInt());

Reply With Quote




Last Updated on March 17, 2017


© 2024 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 - Privacy Policy - Downloads - Top
no new posts