NexusFi: Find Your Edge


Home Menu

 





strategy development


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one kavin729 with 6 posts (0 thanks)
    2. looks_two bill897 with 3 posts (3 thanks)
    3. looks_3 zeller4 with 1 posts (0 thanks)
    4. looks_4 Trader.Jon with 1 posts (1 thanks)
      Best Posters
    1. looks_one bill897 with 1 thanks per post
    2. looks_two Trader.Jon with 1 thanks per post
    3. looks_3 DavidHP with 1 thanks per post
    4. looks_4 MotoMoto with 1 thanks per post
    1. trending_up 6,873 views
    2. thumb_up 6 thanks given
    3. group 5 followers
    1. forum 14 posts
    2. attach_file 4 attachments




 
Search this Thread

strategy development

  #1 (permalink)
kavin729
 
Posts: 8 since Jan 2010
Thanks Given: 8
Thanks Received: 0

Hi friends I have created this strategy after seeing big mike video.
Please help me fix its errors,Targets and stoploss not working properly
I want to enter 10 lots
target 1 : book 6 lots
target 2 : book 2 lots
target 3 ; book 2 lots

want to keep initial stoploss below low or high of entry bar
then after target 1 ,moved below low or high of target 1 bar then to target 2 bar .
cheers
 
Code
                            
//#region Variables
        
private int        smalength        200;
        private 
int        emalength        100;
        private 
int        hmalength        40;
        
        private 
int        target1            100;
        private 
int        target2            200;
        private 
int        target3            300;
        
        private 
int        stop            500;
        
        private 
bool    be2                true;
        private 
bool    be3                true;
        
        
        
//#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;
            
EntryHandling        EntryHandling.UniqueEntries;
            
            
Add(SMA(Close,HMAlength));
            
Add(EMA(Close,HMAlength));
            
Add(HMA(Close,HMAlength));
            
        }
        
        private 
void GoLong()
        {
            
SetStopLoss("target1"CalculationMode.PriceClose[0] - (Stop*TickSize), false);
            
SetStopLoss("target2"CalculationMode.PriceClose[0] - (Stop*TickSize), false);
            
SetStopLoss("target3"CalculationMode.PriceClose[0] - (Stop*TickSize), false);
            
            
SetProfitTarget("target1"CalculationMode.PriceClose[0] + (Target1*TickSize));
            
SetProfitTarget("target2"CalculationMode.PriceClose[0] + ((Target1+Target2)*TickSize));
            
SetProfitTarget("target3"CalculationMode.PriceClose[0] + ((Target1+Target2+Target3)*TickSize));
            
            
EnterLong("target1");
            
EnterLong("target2");
            
EnterLong("target3");
            
            
        }
        private 
void GoShort()
        {
            
SetStopLoss("target1"CalculationMode.PriceClose[0] + (Stop*TickSize), false);
            
SetStopLoss("target2"CalculationMode.PriceClose[0] + (Stop*TickSize), false);
            
SetStopLoss("target3"CalculationMode.PriceClose[0] + (Stop*TickSize), false);
            
            
SetProfitTarget("target1"CalculationMode.PriceClose[0] - (Target1*TickSize));
            
SetProfitTarget("target2"CalculationMode.PriceClose[0] - ((Target1+Target2)*TickSize));
            
SetProfitTarget("target3"CalculationMode.PriceClose[0] - ((Target1+Target2+Target3)*TickSize));
            
            
EnterShort("target1");
            
EnterShort("target2");
            
EnterShort("target3");
            
            
        }
        
        private 
void ManageOrders()
        {
            if (
Position.MarketPosition == MarketPosition.Long)
            {
                if (
BE2 && High[0] > Position.AvgPrice + (Target1*TickSize))
                    
SetStopLoss("target2"CalculationMode.PricePosition.AvgPricefalse);
                
                if (
BE3 && High[0] > Position.AvgPrice + ((Target1+Target2)*TickSize))
                    
SetStopLoss("target3"CalculationMode.PricePosition.AvgPricefalse);
            
            }
            if (
Position.MarketPosition == MarketPosition.Short)
            {
                if (
BE2 && Low[0] < Position.AvgPrice - (Target1*TickSize))
                    
SetStopLoss("target2"CalculationMode.PricePosition.AvgPricefalse);
                
                if (
BE3 && Low[0] < Position.AvgPrice - ((Target1+Target2)*TickSize))
                    
SetStopLoss("target3"CalculationMode.PricePosition.AvgPricefalse);
            
            }
            
        }

        
/// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        
protected override void OnBarUpdate()
        {
            
EntryHandling        EntryHandling.UniqueEntries;
            
            
SMA        smav        SMA(SMAlength);
            
EMA        emav        EMA(EMAlength);
            
HMA        hmav        HMA(HMAlength);
            
            
ManageOrders();
            
            if (
Position.MarketPosition != MarketPosition.Flat) return;
            
            if (
Rising(smav) && Rising(emav) && Rising(hmav))
                
GoLong();
            else
            if (
Falling(smav) && Falling(emav) && Falling(hmav))
                
GoShort();
            
        }

        
//#region Properties
        
[Description("")]
        [
Category("Parameters")]
        public 
int SMAlength
        
{
            
get { return smalength; }
            
set smalength Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int EMAlength
        
{
            
get { return emalength; }
            
set emalength Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int HMAlength
        
{
            
get { return hmalength; }
            
set hmalength Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int Target1
        
{
            
get { return target1; }
            
set target1 Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int Target2
        
{
            
get { return target2; }
            
set target2 Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int Target3
        
{
            
get { return target3; }
            
set target3 Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
int Stop
        
{
            
get { return stop; }
            
set stop Math.Max(1value); }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
bool BE2
        
{
            
get { return be2; }
            
set be2 value; }
        }
        [
Description("")]
        [
Category("Parameters")]
        public 
bool BE3
        
{
            
get { return be3; }
            
set be3 value; }
        }
        
        
        
//#endregion
    
}


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Trade idea based off three indicators.
Traders Hideout
Better Renko Gaps
The Elite Circle
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
22 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #3 (permalink)
 zeller4 
Orlando Florida
 
Experience: Intermediate
Platform: NT8
Trading: CL, NQ, ES, RTY
Posts: 477 since Jun 2009
Thanks Given: 1,416
Thanks Received: 404


Which NT version are you using?

Reply With Quote
  #4 (permalink)
kavin729
 
Posts: 8 since Jan 2010
Thanks Given: 8
Thanks Received: 0


zeller4 View Post
Which NT version are you using?

zeller it is 6.5,but can use 7 also

Reply With Quote
  #5 (permalink)
MotoMoto
Australia (ex UK)
 
Posts: 25 since Aug 2010
Thanks Given: 14
Thanks Received: 27

I am a complete novice programmer, but could it be that the names target1, target2....etc
are repeated for longs and shorts..... and when trying to work out a target for a long v a short, one is above the market, the other below the market, which stuffs up future max, and min calculations.

Try calling them LongTarget1, ShortTarget1 see if that makes a difference.

Reply With Quote
Thanked by:
  #6 (permalink)
kavin729
 
Posts: 8 since Jan 2010
Thanks Given: 8
Thanks Received: 0


MotoMoto View Post
I am a complete novice programmer, but could it be that the names target1, target2....etc
are repeated for longs and shorts..... and when trying to work out a target for a long v a short, one is above the market, the other below the market, which stuffs up future max, and min calculations.

Try calling them LongTarget1, ShortTarget1 see if that makes a difference.

qty done ,someone please help me with trailing stoploss

Reply With Quote
  #7 (permalink)
 
Trader.Jon's Avatar
 Trader.Jon 
Near the BEuTiFULL Horse Shoe
 
Experience: Beginner
Platform: NinjaTrader
Broker: MBTrading Dukascopy ZenFire
Trading: $EURUSD when it is trending
Posts: 473 since Jul 2009
Thanks Given: 401
Thanks Received: 184


kavin729 View Post
qty done ,someone please help me with trailing stoploss

Have you looked at other strategies posted in the elite downloas? I think the hurley might be modified to do what you are doing ... but I could be wrong as it sbeen awhile since I looked at it in detail

Jon

Reply With Quote
Thanked by:
  #8 (permalink)
kavin729
 
Posts: 8 since Jan 2010
Thanks Given: 8
Thanks Received: 0


Trader.Jon View Post
Have you looked at other strategies posted in the elite downloas? I think the hurley might be modified to do what you are doing ... but I could be wrong as it sbeen awhile since I looked at it in detail

Jon

don't have access to elite circle
don't want to donate cash but want to learn, share, contribute and help so that some day I am considered worthy enough to be given access to elite circle to enhance my knowledge amongst the best traders of bigmiketrading forum

kavin

Reply With Quote
  #9 (permalink)
 bill897 
U.S.A.
 
Experience: Advanced
Platform: NinjaTrader
Posts: 19 since May 2010
Thanks Given: 5
Thanks Received: 11

Kevin,

This is only 50 bucks to join the Elite! I believe this is an investment in your learning. Look at as buying a
book or buying a beginning education. I've never done subroutines in C Sharp. Try writing this all in one
mainline.

Reply With Quote
Thanked by:
  #10 (permalink)
 bill897 
U.S.A.
 
Experience: Advanced
Platform: NinjaTrader
Posts: 19 since May 2010
Thanks Given: 5
Thanks Received: 11


Kavin,

I tested another strategy that I hope you will enjoy using your code and adding breakeven, trailing stop
routine I copied from somewhere else here at Big Mike's. This strategy tests out at 39.81% and has a profit
of $31,440. You can probably perfect it. I'd like to see what you can do with it as follows:

Attached Thumbnails
Click image for larger version

Name:	bg_Main.jpg
Views:	134
Size:	540.1 KB
ID:	26638  
Attached Files
Elite Membership required to download: Strat1.cs
Reply With Quote
Thanked by:




Last Updated on May 6, 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