NexusFi: Find Your Edge


Home Menu

 





Big Mikes beginner Ninja Script Strategy video


Discussion in NinjaTrader

Updated
    1. trending_up 2,998 views
    2. thumb_up 2 thanks given
    3. group 2 followers
    1. forum 2 posts
    2. attach_file 0 attachments




Closed Thread
 
Search this Thread

Big Mikes beginner Ninja Script Strategy video

  #1 (permalink)
 magnumdbl 
Cranford, New Jersey, USA
 
Experience: Advanced
Platform: Tradestation, Ninja Trader
Broker: TS and MB Trading
Trading: ES, EC
Posts: 10 since Dec 2010
Thanks Given: 8
Thanks Received: 2

I typed the following into my ninja trader. Trying to follow exactly what Big Mike did in his video and it didn't compile.

Does anyone see the obvious error?

I took out a few lines of code to meet the size limits for this post.
I am getting CS1501 and 1502 errors as well as a CS1519 error on invalid token 'void' .

// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
///<summary>
/// Enter the description of your strategy here
///</summary>
[Description("Make Millions 1/16/2012")]
publicclass DLTestBigMv0 : Strategy
{
// private int smalength = 200 ; // I took these out when it didn't compile
// private int emalength = 100 ; // don't know whether he did also or not.
// private int hmalength = 34 ; // but was getting a compile error with them in.

// private int Target1 = 12 ; // Question 1: Is it OK to leave these in when
// private int Target2 = 10 ; // these are redefined? later ???
// private int Target3 = 24 ;

// private int Stop = 12 ;

// private bool be2 = False ;
// private bool be3 = False ;


///<summary>
/// This method is used to configure the strategy and is called once before any strategy method is called.
///</summary>
protectedoverride void Initialize()
{
CalculateOnBarClose =
true;
EntryHandling = EntryHandling.UniqueEntries ;
}
/// do this for each target so you know it will do all 3 and not stop after 1st one //
/// these are OCO ordrs placed right after position is entered.

private void GoLong()
{
SetStopLoss(Target1, CalculationMode.Price, Close[
0] - (Stop*TickSize), false);
SetStopLoss(Target2, CalculationMode.Price, Close[
0] - (Stop*TickSize), false);
SetStopLoss(Target3, CalculationMode.Price, Close[
0] - (Stop*TickSize), false);

SetProfitTarget(Target1, CalculationMode.Price, Close[
0] + (Target1*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[
0] + ((Target1 + Target2)*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[
0] + ((Target1 + Target2 + Target3)*TickSize));

EnterLong(
"Target1") ;
EnterLong(
"Target2") ;
EnterLong(
"Target3") ;

}

private void GoShort()
{
SetStopLoss(Target1, CalculationMode.Price, Close[
0] + (Stop*TickSize), false);
SetStopLoss(Target2, CalculationMode.Price, Close[
0] + (Stop*TickSize), false);
SetStopLoss(Target3, CalculationMode.Price, Close[
0] + (Stop*TickSize), false);

SetProfitTarget(Target1, CalculationMode.Price, Close[
0] - (Target1*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[
0] - ((Target1 + Target2)*TickSize));
SetProfitTarget(Target2, CalculationMode.Price, Close[
0] - ((Target1 + Target2 + Target3)*TickSize));

EnterShort(
"Target1") ;
EnterShort(
"Target2") ;
EnterShort(
"Target3") ;

}

private void ManageOrders() // ??? problem w/ 'void' in this statement ???
// These are only 'on close' not 'intrabar'
{
if (Position.MarketPosition == MarketPosition.Long)
{
if (BE2 && High[0] > Position.AvgPrice + (Target1*TickSize))
SetStopLoss(
"Target2", CalculationMode.Price, Position.AvgPrice, false) ;

if (BE3 && High[0] > Position.AvgPrice + ((Target1 + Target2)*TickSize))
SetStopLoss(
"Target3", CalculationMode.Price, Position.AvgPrice, false) ;
}

if (Position.MarketPosition == MarketPosition.Short)
{
if (BE2 && Low[0] < Position.AvgPrice - (Target1*TickSize))
SetStopLoss(
"Target2", CalculationMode.Price, Position.AvgPrice, false) ;

if (BE3 && Low[0] > Position.AvgPrice - ((Target1 + Target2)*TickSize))
SetStopLoss(
"Target3", CalculationMode.Price, Position.AvgPrice, false) ;
}
}


///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverride void OnBarUpdate() // This section is called at close of every bar
{
EntryHandling = EntryHandling.UniqueEntries ;

SMA SMAV = SMA(SMAlength);
EMA EMAV = EMA(EMAlength);
HMA HMAV = HMA(HMAlength);

ManageOrders() ;
// This section manages Positions and determines if new position indicated.
if (Position.MarketPosition != MarketPosition.Flat) return ; // make sure we are flat.

if (Rising(smav) && Rising(emav) && Rising(hmav))
GoLong() ;
else if (Falling(smav) && Falling(emav) && Falling(hmav))
GoShort() ;
}
#region Properties
[Description(
"")]
[GridCategory(
"Parameters")]
public int smalength
{
get { return smalength; }
set { smalength = Math.Max(1, value); }
}
[Description(
"")]
[GridCategory(
"Parameters")]
public int emalength
{
get { return emalength; }
set { emalength = Math.Max(1, value); }
}
[Description(
"")]
[GridCategory(
"Parameters")]
publicint hmalength
{
get { return hmalength; }
set { hmalength = Math.Max(1, value); }
}
// deleted from here to end to save space. errors occurred above.//

#endregion
}
}

Started this thread
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
What broker to use for trading palladium futures
Commodities
REcommedations for programming help
Sierra Chart
ZombieSqueeze
Platforms and Indicators
 
  #3 (permalink)
 
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,463 since Jun 2009
Thanks Given: 33,239
Thanks Received: 101,661


Don't put spaces before the semicolon (.

Please use the existing thread:



I think the code was posted there already, if not please re-post there.

I am closing this thread to prevent a split topic.

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
Thanked by:

Closed Thread



Last Updated on January 16, 2012


© 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