NexusFi: Find Your Edge


Home Menu

 





Wildcard in ASCIL


Discussion in Sierra Chart

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




 
Search this Thread

Wildcard in ASCIL

  #1 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

Hi,

I have about 10 instruments that I follow and I would like to have certain default input parameters for several studies automatically change depending on the instrument I currently have selected. For example, change Pivot point times based upon the symbol's RTH. Because the contract names change periodically I am trying to use wildcards after the first two letters of the symbols so I don't have to update the code every month.

I found a wildcard function here Wildcard string compare (globbing) - CodeProject, but I am getting errors within the function that I don't how to resolve.

Any help would be appreciated. Thank you.

 
Code
***** Starting Build of Custom Studies Source File: CCITest.cpp *****	12:33:24
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Warning! W665: col(40) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N630: col(40) source conversion type is 'int'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N631: col(40) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Error! E210: col(40) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Warning! W665: col(40) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N630: col(40) source conversion type is 'int'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N631: col(40) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Error! E210: col(40) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Warning! W665: col(24) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N638: col(24) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N630: col(24) source conversion type is 'bool'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N631: col(24) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Error! E210: col(24) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N638: col(24) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Error! E899: col(21) cannot convert expression to target type
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Note! N630: col(21) source conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Note! N631: col(21) target conversion type is 'bool'
There were compilation errors.

***** Build Failed! *****	12:33:26

 
Code
#include "sierrachart.h"

SCDLLName("CCITest") 

/*==========================================================================*/
SCFloatArrayRef wildcmp_S(const char *wild, const char *string)
	{
	// Written by Jack Handy - <A href="mailto:[email protected]">[email protected]</A>
		const char *cp = NULL, *mp = NULL;

		while ((*string) && (*wild != '*')) 
		{
			if ((*wild != *string) && (*wild != '?')) 
			{
				return 0;
			}
			wild++;
			string++;
		}

		while (*string) 
		{
			if (*wild == '*') 
				{
					if (!*++wild) 
				{
				return 1;
				}
					mp = wild;
					cp = string+1;
				} 
				else if ((*wild == *string) || (*wild == '?')) 
				{
					wild++;
					string++;
				} 
				else 
				{
					wild = mp;
					string = cp++;
				}
		}

		while (*wild == '*') 
		{
			wild++;
		}
		return !*wild;
	}

/*==========================================================================*/

SCSFExport scsf_CCITest(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Plot1 = sc.Subgraph[0];
	
	SCSubgraphRef CCI1 = sc.Subgraph[11];
	
	SCInputRef period1 = sc.Input[0];
	
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		
		sc.GraphName = "CCITest";
		sc.StudyDescription = "Testing Symbol based inputs";
						
		//During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
		sc.AutoLoop = true;
		sc.FreeDLL = 1;
				
		Plot1.Name = "Plot1";
		Plot1.DrawZeros = true;
		Plot1.LineWidth = 1;
		
		//period1.Name = "Period 1";
		//period1.SetInt(6);
		//period1.SetIntLimits(1, 10000);

		return;
	}
	
	const char* p_Symbol;
	p_Symbol = sc.Symbol.GetChars();
	
	if(wildcmp_S("CL*", p_Symbol))
	{
		period1.Name = "Period 1";
		period1.SetInt(20);
		period1.SetIntLimits(1, 10000);
	}
	else
	{
		period1.Name = "Period 1";
		period1.SetInt(6);
		period1.SetIntLimits(1, 10000);
	}

	
	// Do data processing
	sc.DataStartIndex = period1.GetInt();

	sc.CCI(sc.Close, CCI1, period1.GetInt(), 0.015f);
		
	Plot1[sc.Index] = CCI1[sc.Index];
	
}

Attached Files
Elite Membership required to download: CCITest.cpp
Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
About a successful futures trader who didnt know anythin …
Psychology and Money Management
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #3 (permalink)
 
ktrader's Avatar
 ktrader 
glostrup, denmark
 
Experience: Advanced
Platform: Custom platform
Broker: CQG
Trading: Futures, Options, Stocks
Posts: 249 since Aug 2011
Thanks Given: 152
Thanks Received: 275



vegasfoster View Post
Hi,

I have about 10 instruments that I follow and I would like to have certain default input parameters for several studies automatically change depending on the instrument I currently have selected. For example, change Pivot point times based upon the symbol's RTH. Because the contract names change periodically I am trying to use wildcards after the first two letters of the symbols so I don't have to update the code every month.

I found a wildcard function here Wildcard string compare (globbing) - CodeProject, but I am getting errors within the function that I don't how to resolve.

Any help would be appreciated. Thank you.

 
Code
***** Starting Build of Custom Studies Source File: CCITest.cpp *****	12:33:24
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Warning! W665: col(40) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N630: col(40) source conversion type is 'int'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N631: col(40) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Error! E210: col(40) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(15): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Warning! W665: col(40) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N630: col(40) source conversion type is 'int'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N631: col(40) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Error! E210: col(40) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(27): Note! N638: col(40) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Warning! W665: col(24) temporary object used to initialize a non-constant reference
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N638: col(24) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N630: col(24) source conversion type is 'bool'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N631: col(24) target conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Error! E210: col(24) returning reference to function argument or to auto or register variable
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(48): Note! N638: col(24) 'c_ArrayWrapper' defined in: sierrachart.h(1401) (col 7)
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Error! E899: col(21) cannot convert expression to target type
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Note! N630: col(21) source conversion type is 'c_ArrayWrapper<float> (lvalue)'
C:\SierraChart - Velocity\ACS_Source\CCITest.cpp(86): Note! N631: col(21) target conversion type is 'bool'
There were compilation errors.

***** Build Failed! *****	12:33:26

 
Code
#include "sierrachart.h"

SCDLLName("CCITest") 

/*==========================================================================*/
SCFloatArrayRef wildcmp_S(const char *wild, const char *string)
	{
	// Written by Jack Handy - <A href="mailto:[email protected]">[email protected]</A>
		const char *cp = NULL, *mp = NULL;

		while ((*string) && (*wild != '*')) 
		{
			if ((*wild != *string) && (*wild != '?')) 
			{
				return 0;
			}
			wild++;
			string++;
		}

		while (*string) 
		{
			if (*wild == '*') 
				{
					if (!*++wild) 
				{
				return 1;
				}
					mp = wild;
					cp = string+1;
				} 
				else if ((*wild == *string) || (*wild == '?')) 
				{
					wild++;
					string++;
				} 
				else 
				{
					wild = mp;
					string = cp++;
				}
		}

		while (*wild == '*') 
		{
			wild++;
		}
		return !*wild;
	}

/*==========================================================================*/

SCSFExport scsf_CCITest(SCStudyInterfaceRef sc)
{
	SCSubgraphRef Plot1 = sc.Subgraph[0];
	
	SCSubgraphRef CCI1 = sc.Subgraph[11];
	
	SCInputRef period1 = sc.Input[0];
	
	if (sc.SetDefaults)
	{
		// Set the configuration and defaults
		
		sc.GraphName = "CCITest";
		sc.StudyDescription = "Testing Symbol based inputs";
						
		//During development set this flag to 1, so the DLL can be modified. When development is completed, set it to 0 to improve performance.
		sc.AutoLoop = true;
		sc.FreeDLL = 1;
				
		Plot1.Name = "Plot1";
		Plot1.DrawZeros = true;
		Plot1.LineWidth = 1;
		
		//period1.Name = "Period 1";
		//period1.SetInt(6);
		//period1.SetIntLimits(1, 10000);

		return;
	}
	
	const char* p_Symbol;
	p_Symbol = sc.Symbol.GetChars();
	
	if(wildcmp_S("CL*", p_Symbol))
	{
		period1.Name = "Period 1";
		period1.SetInt(20);
		period1.SetIntLimits(1, 10000);
	}
	else
	{
		period1.Name = "Period 1";
		period1.SetInt(6);
		period1.SetIntLimits(1, 10000);
	}

	
	// Do data processing
	sc.DataStartIndex = period1.GetInt();

	sc.CCI(sc.Close, CCI1, period1.GetInt(), 0.015f);
		
	Plot1[sc.Index] = CCI1[sc.Index];
	
}


Hi,

You can change the return type of the wildcmp to int or bool:

 
Code
bool wildcmp_S(const char *wild, const char *string)
--ktrader

Reply With Quote
Thanked by:
  #4 (permalink)
 vegasfoster 
las vegas
 
Experience: Intermediate
Platform: Sierra Chart
Broker: Velocity/IB
Trading: 6E
Posts: 1,145 since Feb 2010
Thanks Given: 304
Thanks Received: 844

I actually understand that, YAY! Thanks a bunch.

Started this thread Reply With Quote




Last Updated on August 29, 2012


© 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