Dark Theme
Light Theme
Trading Articles
Article Categories
Article Tools
Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Wildcard in ASCIL
Updated August 29, 2012
trending_up
1,661 views
thumb_up
2 thanks given
group
1 followers
forum
3 posts
attach_file
1 attachments
Wildcard in ASCIL
August 29th, 2012, 03:49 PM
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
Can you help answer these questions from other members on NexusFi?
Best Threads (Most Thanked) in the last 7 days on NexusFi
August 29th, 2012, 03:58 PM
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
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
August 29th, 2012, 04:28 PM
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.
Last Updated on August 29, 2012