NexusFi: Find Your Edge


Home Menu

 





Compiling Error (Statement Expected)


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one sagetrade with 13 posts (0 thanks)
    2. looks_two dynoweb with 7 posts (4 thanks)
    3. looks_3 sam028 with 4 posts (1 thanks)
    4. looks_4 Big Mike with 3 posts (0 thanks)
      Best Posters
    1. looks_one Nicolas11 with 1 thanks per post
    2. looks_two bd92154 with 1 thanks per post
    3. looks_3 dynoweb with 0.6 thanks per post
    4. looks_4 sam028 with 0.3 thanks per post
    1. trending_up 8,431 views
    2. thumb_up 7 thanks given
    3. group 6 followers
    1. forum 32 posts
    2. attach_file 3 attachments




 
Search this Thread

Compiling Error (Statement Expected)

  #1 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

Hi Guys,
I get a compiling error at the end of row 4. "Statement expected".
Any idea how I can resolve?


Quoting 
void TradeSize()
{
if (Close - anaSuperTrendM11(1, 10, 5, false).StopDot[0]) != 0;
vTradeSize = RiskSize / Math.Abs(Close - anaSuperTrendM11(1, 10, 5, false).StopDot[0]);
else vTradeSize = 0;

vTradeSize = Math.Floor(vTradeSize);
TradeSize = vTradeSize;
}


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Retail Trading As An Industry
67 thanks
NexusFi site changelog and issues/problem reporting
47 thanks
Battlestations: Show us your trading desks!
43 thanks
GFIs1 1 DAX trade per day journal
32 thanks
What percentage per day is possible? [Poll]
31 thanks

  #3 (permalink)
 
Tasker_182's Avatar
 Tasker_182 
Cedar Rapids, iowa
Legendary Market Wizard
 
Experience: Intermediate
Platform: Ninjatrader
Broker: Ninjatrader - Continuum
Posts: 716 since Aug 2009
Thanks Given: 476
Thanks Received: 1,401



sagetrade View Post
Hi Guys,
I get a compiling error at the end of row 4. "Statement expected".
Any idea how I can resolve?

This if/else statement is confused, try this:

void TradeSize()
{
if
{
(Close - anaSuperTrendM11(1, 10, 5, false).StopDot[0]) != 0;
vTradeSize = RiskSize / Math.Abs(Close - anaSuperTrendM11(1, 10, 5, false).StopDot[0]);
}
else vTradeSize = 0;

vTradeSize = Math.Floor(vTradeSize);
TradeSize = vTradeSize;
}

Be yourself; everyone else is already taken. Oscar Wilde
Reply With Quote
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

Nope.
Try:
 
Code
                            
void TradeSize()

  if { (
Close anaSuperTrendM11(1105false).StopDot[0]) != ) {
    
vTradeSize RiskSize Math.Abs(Close anaSuperTrendM11(1105false).StopDot[0]); 
  }
  else 
    
vTradeSize 0;
... 
In fact your line
 
Code
                            
if (Close anaSuperTrendM11(1105false).StopDot[0]) != 0
doesn't make sense: you test a condition, but do not do anything with it.

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #5 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

Okay. I tried to translate a Function from Easy Language, which is...


Quoting 
//the Close - vSuperTrend <> 0 check avoids division by zero errors
if Close - vSuperTrend <> 0 then
vTradeSize = RiskSize / AbsValue(Close - vSuperTrend)
else vTradeSize = 0;

//round to the next lowest value
vTradeSize = Floor(vTradeSize);

... it is supposed to determine the Position Size.

Essentially, Im checking if Supertrend is unequal to zero, to determine the difference between ST's value and the current Close of the bar - then calculating the position size in relation to an input "RiskSize" and round it the next lowest value.

Would be great if you could tell me what the problem is with this if statement and how I can solve this?

Reply With Quote
  #6 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629


sagetrade View Post
Okay. I tried to translate a Function from Easy Language, which is...



... it is supposed to determine the Position Size.

Essentially, Im checking if Supertrend is unequal to zero, to determine the difference between ST's value and the current Close of the bar - then calculating the position size in relation to an input "RiskSize" and round it the next lowest value.

Would be great if you could tell me what the problem is with this if statement and how I can solve this?

You had no THEN, just an IF, and then, nothing...
It's basically, in C#:
 
Code
                            
if (my condition
  
action
or easier to read (IMHO)
 
Code
                            
if (my condition) {

  
action;


Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
  #7 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

But there is no "action" I can code, because what I want to achieve is just a definition.
The action in EL was just "begin". Whats the "begin" synonym in C# ? How does my code have to look like?

Reply With Quote
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,824
Thanks Received: 4,629

In EL your condition is

Quoting 
Close - vSuperTrend <> 0

and your action is

Quoting 
vTradeSize = RiskSize / AbsValue(Close - vSuperTrend)

Affecting a value to a variable is an action (well, this is what I meant...).

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
The following user says Thank You to sam028 for this post:
  #9 (permalink)
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11

Okay, I got that. But how does the code have to look like? How do I connect condition & action here?
If I take your code from #3, I get plenty of errors

Plz See attached pic:

Reply With Quote
  #10 (permalink)
 
bd92154's Avatar
 bd92154 
San Diego
 
Experience: Intermediate
Platform: NinjaTrader/Think or Swim
Broker: TDA/Interactive Brokers/ Data Feed TDA & IBK ( Dropped Kinetick)
Trading: Stocks NASDAQ
Posts: 1,058 since May 2011
Thanks Given: 1,542
Thanks Received: 448



sagetrade View Post
Okay, I got that. But how does the code have to look like? How do I connect condition & action here?
If I take your code from #3, I get plenty of errors

Plz See attached pic:

Best wishes at solving your coding issue.
What has worked for the little amount of coding that I have done is to tackle the errors one at a time and then recompile. Your if statement has some syntax issues that the compiler is pointing out. The curly brackets should be after your initial if statement for exactly action you want done. Here is link to online NT7 guide which may help some. NinjaTrader Version 7.

Also here is a sample if from that same guide.

---------------------------------from online guide------------------------------------
// The following code encloses two statements with curly braces
if (x == 5)
{
Print("NinjaTrader");
Print("NinjaScript");
}

You can enclose several comment lines using the "/*" characters to start the comment block and then using the "*/" characters to end the comment block.
--------------------------------------------------------------------------------------------

Still very new to C# and NT7 coding here so as far as the rest of your program I don't know. Many times clearing up initial errors will clear errors that are later on in your code though, that is why you need to start at error one.

Hope this helps some.

Visit my NexusFi Trade Journal Reply With Quote
The following user says Thank You to bd92154 for this post:





Last Updated on August 25, 2013


© 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