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,527 views
    2. thumb_up 7 thanks given
    3. group 6 followers
    1. forum 32 posts
    2. attach_file 3 attachments




 
 

Compiling Error (Statement Expected)

 
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


dynoweb View Post
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

I did that. Code now looks as follows:


Quoting 
// Position Size
int TradeSize()
{
double vTradeSize = 0;
if ((Close[0] - anaSuperTrendM11(ATRMedian, ATRMult, ATRPeriod, false).StopDot[0]) != 0)
{
vTradeSize = RiskSize / Math.Abs(Close[0] - anaSuperTrendM11(ATRMedian, ATRMult, ATRPeriod, false).StopDot[0]);
}
return (int) Math.Floor(vTradeSize);
}

It should work now :/
You have any further remarks?
@dynoweb
where in the code do i have to insert the print code of yours, that it shows me the calcs? In my output window, it doesn't show anything.


Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Futures True Range Report
The Elite Circle
ZombieSqueeze
Platforms and Indicators
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
GFIs1 1 DAX trade per day journal
19 thanks
The Program
18 thanks
 
 dynoweb 
McKinney, TX
 
Experience: Intermediate
Platform: ThinkOrSwim, NinjaTrader
Broker: TD Ameritrade (soon to be Schwab) & NinjaTrader
Trading: The indexes, ES, YM, NQ & RTY
Posts: 171 since Aug 2012
Thanks Given: 216
Thanks Received: 157


sagetrade View Post
I did that. Code now looks as follows:



It should work now :/
You have any further remarks?
@dynoweb
where in the code do i have to insert the print code of yours, that it shows me the calcs? In my output window, it doesn't show anything.

Put it just before the return so you get the same value on the console window as you are returning.

Follow me on Twitter
Thanked by:
 
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


OK, I found the problem.

It is within the Order Generation Code:


Quoting 
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])
{
EnterLong(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", "");
}

This code gives a very high TradeSize however if I change the code to..


Quoting 
protected override void OnBarUpdate()
{
// Condition set 1
if (anaSuperTrendM11(1, 10, 5, false).StopDot[2] > Close[2]
&& anaSuperTrendM11(1, 10, 5, false).StopDot[1] < Close[1])
{
EnterLong(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", "");
}
}

..it works fine.

I don't really care, because the order generating is just random, Im not going to use those Supertrend crossovers.
However, I'm still interested why the first code generates a huge order size and the second generates as expected. Seems as with the first code the supertrend-values are just too close to price-action. Any ideas on this? There must probably be a more efficient way to code Supertrend crossovers.

 
 dynoweb 
McKinney, TX
 
Experience: Intermediate
Platform: ThinkOrSwim, NinjaTrader
Broker: TD Ameritrade (soon to be Schwab) & NinjaTrader
Trading: The indexes, ES, YM, NQ & RTY
Posts: 171 since Aug 2012
Thanks Given: 216
Thanks Received: 157

You might want to check if you are already in a trade before entering another trade.

if (Position.MarketPosition == MarketPosition.Flat)
{
if (goodEntryCondition)
{
place trade order
}
}


The way you have it in your code right now is every time the bar updates and your condition is true you are hitting EnterLong(..)

You can also do a check before your long exit

if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong("Exit Long", "Buy Long"); // note the second arg is the signal name of your trade when you went long
}

Follow me on Twitter
Thanked by:
 
sagetrade
Frankfurt / Germany
 
Posts: 47 since Jul 2013
Thanks Given: 28
Thanks Received: 11


dynoweb View Post
You might want to check if you are already in a trade before entering another trade.

if (Position.MarketPosition == MarketPosition.Flat)
{
if (goodEntryCondition)
{
place trade order
}
}


The way you have it in your code right now is every time the bar updates and your condition is true you are hitting EnterLong(..)

You can also do a check before your long exit

if (Position.MarketPosition == MarketPosition.Long)
{
ExitLong("Exit Long", "Buy Long"); // note the second arg is the signal name of your trade when you went long
}

thx for the remark. It worked fine however, as I had only 1 Trade per Direction and also before a new entry condition can appear it will always be a position close first. Thx nevertheless.

Do you have any ideas on how to improve the entry condition? In terms of code I mean?

Is there another/better way to code a switch of trend in supertrend?

Btw what does this ".StopDot" stand for?

 
 dynoweb 
McKinney, TX
 
Experience: Intermediate
Platform: ThinkOrSwim, NinjaTrader
Broker: TD Ameritrade (soon to be Schwab) & NinjaTrader
Trading: The indexes, ES, YM, NQ & RTY
Posts: 171 since Aug 2012
Thanks Given: 216
Thanks Received: 157


sagetrade View Post
thx for the remark. It worked fine however, as I had only 1 Trade per Direction and also before a new entry condition can appear it will always be a position close first. Thx nevertheless.

Do you have any ideas on how to improve the entry condition? In terms of code I mean?

Is there another/better way to code a switch of trend in supertrend?

Btw what does this ".StopDot" stand for?

I'm not sure if you have access to the elite forums, but there are a lot of very experienced traders tracking their trades on a journal. Take a look at that if you have a chance.

I don't use the ana super trend indicators so I really can't say without digging into the code. But I've been working with the Stochastics indicator and using that to trigger my entries. It really can't be used by itself for auto trading since you need to know that you are in a trend and it's the first or second pull back on a trend for a trend continuation trade.

Also take a look at the Battle of the Bogs thread and inspect the code on those bots to see what they are doing.

Follow me on Twitter
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537


dynoweb View Post
I'm not sure if you have access to the elite forums

If the username in profile on left of each post is not highlighted (yellow, red) then the member is not an Elite Member.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal
 
 dynoweb 
McKinney, TX
 
Experience: Intermediate
Platform: ThinkOrSwim, NinjaTrader
Broker: TD Ameritrade (soon to be Schwab) & NinjaTrader
Trading: The indexes, ES, YM, NQ & RTY
Posts: 171 since Aug 2012
Thanks Given: 216
Thanks Received: 157


Big Mike View Post
If the username in profile on left of each post is not highlighted (yellow, red) then the member is not an Elite Member.

Mike

Hey Mike, I noticed you weren't an Elite Member, your not yellow or red

All joking aside, @sagetrade if you're serious at all about learning to trade you really need to bite the bullet and change your membership to Elite, you won't get a better value for that small amount of investment. That's your first winning trade.

Follow me on Twitter
 
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,398 since Jun 2009
Thanks Given: 33,173
Thanks Received: 101,537

Lol well two people in 50,000 are purple but yes should have included that...

Sent from my LG Optimus G Pro

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal
 
 
Silvester17's Avatar
 Silvester17 
Columbus, OH
Market Wizard
 
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527



Big Mike View Post
If the username in profile on left of each post is not highlighted (yellow, red) then the member is not an Elite Member.

Mike

something changed?

market wizards (red) didn't have to be elite members.


 



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