NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-01-2012, 09:50 PM   #1
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default Changing my Tradesize int

Hi ,

I am wanting to change my trade size on some trades and am using a bool set to false. Hasve searched the forum but still unsure why it wont change as shown.

Tradesize =20000 for the entry.

thanks Raef



// Condition set 1
if (SecondEntry == true)
{
Tradesize =
20000; // problem here
}
if (CrossAbove(EMA(Fema), EMA(Sema), 1))
{
EnterLong(Tradesize,
"");
}
raefon72 is offline  
Reply With Quote
Old 01-02-2012, 09:18 AM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by raefon72 View Post
Hi ,

I am wanting to change my trade size on some trades and am using a bool set to false. Hasve searched the forum but still unsure why it wont change as shown.

Tradesize =20000 for the entry.

thanks Raef



// Condition set 1
if (SecondEntry == true)
{
Tradesize =
20000; // problem here
}
if (CrossAbove(EMA(Fema), EMA(Sema), 1))
{
EnterLong(Tradesize,
"");
}
What is the error message?
koganam is offline  
Reply With Quote
Old 01-02-2012, 12:19 PM   #3
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

raefon,

If you could post more of your code it would be helpful. I don't see anything immediately wrong with this.

I look forward to assisting you.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 01-02-2012, 01:06 PM   #4
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

This forum has me limited to 10000 and wont let me post the whole script so attached as zip file


raef


privatebool secondEntry = false; // Default setting for SecondEntry
privateint tradesize = 10000; // Default setting for Tradesize
// User defined variables (add any user defined variables below)
#endregion

[Description("")]
[GridCategory(
"Parameters")]
publicbool SecondEntry
{
get { return secondEntry; }
set { secondEntry = value; }
}
[Description(
"")]
[GridCategory(
"Parameters")]
publicint Tradesize
{
get { return tradesize; }
set { tradesize = Math.Max(10000, value); }
}
#endregion
Attached Files
File Type: zip forumhelpa.zip (3.0 KB, 3 views)
raefon72 is offline  
Reply With Quote
Old 01-02-2012, 01:11 PM   #5
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

raefon,

You aren't setting the SecondEntry property to true so it won't ever change the order quantity.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
The following user says thank you to NinjaTrader_AdamP for this post:
Old 01-02-2012, 01:19 PM   #6
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
Default

Is he using it as a parameter?


Quote:
Originally Posted by NinjaTrader_AdamP View Post
raefon,

You aren't setting the SecondEntry property to true so it won't ever change the order quantity.

Please let me know if I may assist further.
sledge is offline  
Reply With Quote
The following user says thank you to sledge for this post:
Old 01-02-2012, 01:24 PM   #7
NinjaTrader_AdamP
NinjaTrader Customer Service
 
NinjaTrader_AdamP's Avatar
 
Join Date: Aug 2011
Location: Denver, CO, USA
Posts: 2,895
Thanks: 241
Thanked 375 times in 365 posts
Default

sledge,

He has "SecondEntry" setup as a user defined input but it is never changing. My impression was he wants to increase his order size after something occurs. Since nothing is setting the parameter "SecondEntry" the order quantity never changes. It will always either be 10000 or 20000 depending on what he sets the "SecondEntry" to initially.

Please let me know if I may assist further.
NinjaTrader_AdamP is offline  
Reply With Quote
Old 01-02-2012, 03:11 PM   #8
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

Hi Adam,

I am not sure what you mean.
privatebool secondEntry = false; // Default setting for SecondEntry

Its a bool at the begining of the script and can be set to true in the variables but it's default is false.

// Condition set 1
if (SecondEntry == true)
{
Tradesize =
20000;
}
if (CrossAbove(EMA(Fema), EMA(Sema), 1))
{
EnterLong(Tradesize,
"");
}
Last edited by raefon72; 01-02-2012 at 03:15 PM.
raefon72 is offline  
Reply With Quote
Old 01-02-2012, 03:28 PM   #9
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,225 times in 996 posts
Send a message via Skype™ to koganam
Default

Quote:
if (SecondEntry == true)
is a test of the SecondEntry.

Where in your code have you set SecondEntry to true, based on some condition or other? If you have not explicitly set SecondEntry to true somewhere in the code, then it has its default value, which is false, so your test condition above will never trigger.
koganam is offline  
Reply With Quote
Old 01-02-2012, 04:11 PM   #10
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

At the parameter settings I can select true or false. The strategy works as false and works as true but doesn't change my entry size. It seems to ignore the statement.
raefon72 is offline  
Reply With Quote
Old 01-02-2012, 05:21 PM   #11
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
Default

Quote:
Originally Posted by raefon72 View Post
At the parameter settings I can select true or false. The strategy works as false and works as true but doesn't change my entry size. It seems to ignore the statement.
OK - that's what I thought you were doing.

It isn't being accepted as a parameter for whatever reason.

I have not dealt with these as I don't use parameters, but please try this instead:


privatebool secondEntry ; // Default setting for SecondEntry
sledge is offline  
Reply With Quote
Old 01-02-2012, 05:53 PM   #12
raefon72
Member
 
Join Date: Jun 2010
Location: gold coast australia
Posts: 92
Thanks: 15
Thanked 6 times in 5 posts
Default

Thanks guys,

There must be somthing else wrong however i have copied the code and put it into a strategy and it seems to work ok on another strategy. There might be somthing missing on this one.

One job down and only a few to go.

Thanks again.
raefon72 is offline  
Reply With Quote
Old 01-02-2012, 06:00 PM   #13
sledge
Senior Member
 
Join Date: Aug 2010
Location: Washington, D.C.
Posts: 1,184
Thanks: 178
Thanked 301 times in 259 posts
Default

Sometimes, restarting NT clears up a lot of these odd items that work elsewhere.

Good luck!



Quote:
Originally Posted by raefon72 View Post
Thanks guys,

There must be somthing else wrong however i have copied the code and put it into a strategy and it seems to work ok on another strategy. There might be somthing missing on this one.

One job down and only a few to go.

Thanks again.
sledge is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
int to int comparison for optimization dirygoatee Strategy Development 1 11-22-2011 01:04 PM
Changing order type without changing IOrder name guillembm Miscellaneous Support 1 11-07-2011 09:23 AM
ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double s adamus Version 7 Beta General Questions & Bug Reports 9 06-28-2010 04:16 PM
Double into int Gepetto Automated Trading 5 11-18-2009 11:16 AM
double to int ? zoltran Indicator Development 3 03-14-2007 01:51 AM


All times are GMT -6. The time now is 06:56 AM.