Compiling Error (Statement Expected) - NinjaTrader Programming | futures io social day trading
futures io futures trading


Compiling Error (Statement Expected)
Updated: Views / Replies:2,842 / 32
Created: by sagetrade Attachments:3

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 3  
 
Thread Tools Search this Thread
 

Compiling Error (Statement Expected)

  #11 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received

ok guys, thx for the support. Now fixed the error but having two new ones ;(
It tells me that vTradeSize has first to be specified and that operator "-" can not be used for
"if ((Close[0] - anaSuperTrendM11(1, 10, 5, false).StopDot[0]) != 0) "


Would be great if someone could take a look at my code below:



Quoting 
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
/// Hi This is My Description
/// </summary>
[Description("Hi This is My Description")]
public class SageTestStrat : Strategy
{
#region Variables
// Wizard generated variables
private int trueFalse = 1; // Default setting for TrueFalse

// User defined variables (add any user defined variables below)
private double RiskSize = 1000; // Risk Value
private double vTradeSize = 1; // TradeSize Value
#endregion

/// <summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
/// </summary>
protected override void Initialize()
{

CalculateOnBarClose = true;
}

/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
// Condition set 1
if (anaSuperTrendM11(1, 10, 5, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(1, 10, 5, false).StopDot[0] < Close[0])
{
TradeSize();
EnterLong((int)TradeSize, "Buy Long");
}

// Condition set 2
if (Position.Quantity > 0
&& anaSuperTrendM11(1, 10, 5, false).StopDot[1] < Close[1]
&& anaSuperTrendM11(1, 10, 5, false).StopDot[0] > Close[0])
{
ExitLong("Exit Long", "");
}
}


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

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



#region Properties
[Description("")]
[GridCategory("Parameters")]
public int TrueFalse
{
get { return trueFalse; }
set { trueFalse = Math.Max(0, value); }
}
#endregion
}
}



Last edited by sagetrade; August 10th, 2013 at 11:29 AM.
Reply With Quote
 
  #12 (permalink)
Administrator: Retired Backtester
 Vendor: speedytradingservers.com 
Rennes France
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: IB/Kinetick
Favorite Futures: Futures
 
sam028's Avatar
 
Posts: 3,366 since Jun 2009
Thanks: 3,573 given, 3,982 received

Hmm, how did you get anaSuperTrendM11 , as downloads are only available for Elite members ?

Success requires no deodorant! (Sun Tzu)
Reply With Quote
 
  #13 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received



sam028 View Post
Hmm, how did you get anaSuperTrendM11 , as downloads are only available for Elite members ?

From the author himself.

Have you got an idea left on how to solve my code issue?

Reply With Quote
 
  #14 (permalink)
Elite Member
McKinney, TX
 
Futures Experience: Intermediate
Platform: Think or Swim, NinjaTrade
Favorite Futures: The indexes, ES, YM, NQ & RTY
 
Posts: 152 since Aug 2012
Thanks: 213 given, 125 received

There are several problems with your code.

First your TradeSize method is not returning anything. So I changed it as shown below

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

You were using TradeSize "TradeSize = vTradeSize;" like a variable but it's the name of your function. My change returns the results of the calculation.

I changed your long code to use this function

if (anaSuperTrendM11(1, 10, 5, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(1, 10, 5, false).StopDot[0] < Close[0])
{
EnterLong(TradeSize(), "Buy Long");
}

and I remove the double vTradeSize from your variable list.

Reply With Quote
The following user says Thank You to dynoweb for this post:
 
  #15 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received


dynoweb View Post
There are several problems with your code.

First your TradeSize method is not returning anything. So I changed it as shown below

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

You were using TradeSize "TradeSize = vTradeSize;" like a variable but it's the name of your function. My change returns the results of the calculation.

I changed your long code to use this function

if (anaSuperTrendM11(1, 10, 5, false).StopDot[1] > Close[1]
&& anaSuperTrendM11(1, 10, 5, false).StopDot[0] < Close[0])
{
EnterLong(TradeSize(), "Buy Long");
}

and I remove the double vTradeSize from your variable list.

thx dynoweb. I followed your steps, but it still won't compile :/

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).


Last edited by sagetrade; August 11th, 2013 at 09:57 AM.
Reply With Quote
 
  #16 (permalink)
Elite Member
near Paris, France
 
Futures Experience: Beginner
Platform: -
Favorite Futures: -
 
Nicolas11's Avatar
 
Posts: 1,070 since Aug 2011
Thanks: 2,232 given, 1,729 received

Hi,

I suggest that you move the "return" line between current lines 74 and 75.

Nicolas

Sent from my mobile phone with Tapatalk

Reply With Quote
The following user says Thank You to Nicolas11 for this post:
 
  #17 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received


Nicolas11 View Post
Hi,

I suggest that you move the "return" line between current lines 74 and 75.

Nicolas

Sent from my mobile phone with Tapatalk

thx so much guys - code compiled now.

I have however the problem that TradeSize is mysteriously high!

I have an example trade on the chart.

The calculation should be as follow:


Quoting 
vTradeSize = RiskSize / Math.Abs(Close[0] - anaSuperTrendM11(1, 3, 10, false).StopDot[0]);

RiskSize / Floor(Close - Supertrend) = TradeSize
So the calculation for a RiskSize of 100 should be:

100 / (1345 - 1270) = 1

and for a RiskSize of 200 it should be:
200 / (1345 - 1270) = 2

However as can be seen on the chart, Contracts traded are 28 for a RiskSize of 100.

Please register on futures.io to view futures trading content such as post attachment(s), image(s), and screenshot(s).

Reply With Quote
 
  #18 (permalink)
 Vendor: www.traderwerks.com 
Taipei Taiwan
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: Optimus
Favorite Futures: TW
 
Posts: 693 since Jun 2009
Thanks: 440 given, 440 received


sagetrade View Post
From the author himself.

Have you got an idea left on how to solve my code issue?

Since the author anaSuperTrendM11 is a good programmer and he is in your time zone, have you contacted him yet ?

Math. A gateway drug to reality.
Reply With Quote
 
  #19 (permalink)
Trading Apprentice
Frankfurt / Germany
 
Futures Experience: Intermediate
Platform: NT, MC
Favorite Futures: Stocks, Futures
 
sagetrade's Avatar
 
Posts: 47 since Jul 2013
Thanks: 28 given, 10 received


traderwerks View Post
Since the author anaSuperTrendM11 is a good programmer and he is in your time zone, have you contacted him yet ?

first check if anyone else from the forum has help on this, before bothering admins!

Reply With Quote
 
  #20 (permalink)
Elite Member
McKinney, TX
 
Futures Experience: Intermediate
Platform: Think or Swim, NinjaTrade
Favorite Futures: The indexes, ES, YM, NQ & RTY
 
Posts: 152 since Aug 2012
Thanks: 213 given, 125 received



Nicolas11 View Post
Hi,

I suggest that you move the "return" line between current lines 74 and 75.

Nicolas

Sent from my mobile phone with Tapatalk

Really you should have deleted lines 71-74 since they are after the return statement.

vTradeSize is a variable with a scope inside the TradeSize method. It's initialized to 0 so if that if condition doesn't run this method will return 0. If the if condition is true, the it will return the vtradeSize value of non-zero.

You can also print the values to be sure your calculations are as you expect, look in the console window for the output.

Print("Returning " + (int) Math.Floor(vTradeSize);
Return (int) Math.Floor(vTradeSize);


Rick


Last edited by dynoweb; August 14th, 2013 at 01:37 PM.
Reply With Quote
The following user says Thank You to dynoweb for this post:

Reply



futures io > > > > > Compiling Error (Statement Expected)

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trade Size Analyzer compiling error sudhirc The Elite Circle 1 March 16th, 2012 01:26 PM
Error compiling indicators rltheg NinjaTrader Programming 13 March 29th, 2011 05:10 PM
NT7 audio alert - statement expected? subterfuge NinjaTrader Programming 2 March 17th, 2011 10:55 AM
NT indicator script compiling issuses / error while importing skyfly NinjaTrader Programming 8 July 20th, 2010 01:56 AM
C# Math.net and compiling tinkerz NinjaTrader Programming 1 April 6th, 2010 06:33 PM


All times are GMT -4. The time now is 03:09 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.15 seconds with 20 queries on phoenix via your IP 54.145.16.43