Protecting the cumulative profit target in an automated strategy - NinjaTrader Programming | futures io social day trading
futures io futures trading


Protecting the cumulative profit target in an automated strategy
Updated: Views / Replies:2,910 / 4
Created: by nanobiotech Attachments:0

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
 
Thread Tools Search this Thread
 

Protecting the cumulative profit target in an automated strategy

  #1 (permalink)
Elite Member
Brisbane, Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus/Zen-Fire
Favorite Futures: CL
 
nanobiotech's Avatar
 
Posts: 670 since Jun 2009
Thanks: 134 given, 428 received

Protecting the cumulative profit target in an automated strategy

Hi everyone

As most of you know I am very active in developing the Hurley strategy that Big Mike initiated.

The latest version of Hurley is working well. It can use up to 5 contracts per trade with each contract having a different profit target. I use an initial setstoploss for all contracts which moves to BE + half the ticks of the first target when the first target is hit. I use a variable "cumprofittarget" to define the total cumulative profit for the strategy for that session (presently $1000) and another variable, cumlosstarget, for a loss target. I use CalculateOnBarClose=true.

Have a look at the latest version: Hurley6_7a_NT or Hurley6_7a_6_5. The profit targets in ticks for Target1, Target2, Target3, Target4, and Target 5 are 20, 20, 20, 20, and 150. Therefore using Big Mikes method the actual profit targets on the CL are 20, 40, 60, 80, and $1500. The reason I like the very big last target is to extend staying in the trade to avoid re-entries with retracements.

However, I want to improve the strategy so that when cumprofittarget is exceeded when one or more contracts are still in play in a trade, the cumprofittarget is protected. For example in a long if cumprofittarget is exceeded by 20 ticks, I could reset the setstoploss to a number of ticks below the current price (eg close of the last bar). The reason for this as frequently the cumprofittarget is exceeded by a large margin after the 3rd contract is hit

This part of my code that exits when the cumulative profit or loss target is hit works OK:

if (Position.MarketPosition != MarketPosition.Flat) return;

/* Prevents further trading if the current session's cumulative profit or loss targets are realised. */
if (Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit >= cumprofittarget || Performance.RealtimeTrades.TradesPerformance.Currency.CumProfit <= -cumlosstarget)
{
return;
}


I am trying to add the code after the above to protect the cumprofittarget and have tried the following but it doesn't appear to work (beyond my current expertise):

if ((Position.MarketPosition == MarketPosition.Long)
&& ((Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) - cumprofittarget) >= 200)
{
SetStopLoss("target1", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target2", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target3", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target4", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
SetStopLoss("target5", CalculationMode.Price, Math.Min(GetCurrentBid(), - (20 * TickSize)), false);
}

if ((Position.MarketPosition == MarketPosition.Short)
&& ((Position.GetProfitLoss(Close[0], PerformanceUnit.Currency)) - cumprofittarget) >= 200)
{
SetStopLoss("target1", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target2", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target3", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target4", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
SetStopLoss("target5", CalculationMode.Price, Math.Min(GetCurrentBid(), + (20 * TickSize)), false);
}

Does anyone have any ideas?

Thanks in advance,
Nano


Last edited by Big Mike; April 1st, 2010 at 12:10 PM. Reason: moved to ninjatrader programming from elite group trading
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received


Nano,

 
Code
                            
 Math.Min(GetCurrentBid(), - (20 TickSize)) 

That is saying whatever is the lesser of GetCurrentBid or - 20 ticks. It's not valid. The command in Math.Min separates two values, like GetCurrentBid() and Close[0]. Here if bid is 82.00 you are saying, "what is less? 82.00, or - 20*ticks" the answer is always -20 ticks, the value is always -20 ticks you aren't subtracting it from anything.

If you meant to say currentbid minus 20 ticks, it would be:

 
Code
                            
SetStopLoss("target1"CalculationMode.Price, (GetCurrentBid() - (20 TickSize)), false); 

Also, if you use GetCurrentBid() on one side, you should use GetCurrentAsk() on the other side probably, to balance.

As for the Position.GetProfitLoss, I don't use that method but I believe that it is evaluated for the entire trade, not just 1 contract. So make sure that is what you were intending.

The best thing to do when running into trouble is use Print() statements. Print out the values so you can see what it is doing.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
The following user says Thank You to Big Mike for this post:
 
  #4 (permalink)
Site Administrator
Manta, Ecuador
 
Futures Experience: Advanced
Platform: My own custom solution
Favorite Futures: E-mini ES S&P 500
 
Big Mike's Avatar
 
Posts: 46,238 since Jun 2009
Thanks: 29,350 given, 83,214 received

I moved the thread to NinjaTrader programming from Elite Group Trading methods. So long as you don't post Elite code (Hurley) I think it would be best here. Your example is really non-specific to Hurley.

If you don't want it here I can move it to the general Elite area, but it shouldn't be in the group trading area.

Mike

Due to time constraints, please do not PM me if your question can be resolved or answered on the forum.

Need help?
1) Stop changing things. No new indicators, charts, or methods. Be consistent with what is in front of you first.
2) Start a journal and post to it daily with the trades you made to show your strengths and weaknesses.
3) Set goals for yourself to reach daily. Make them about how you trade, not how much money you make.
4) Accept responsibility for your actions. Stop looking elsewhere to explain away poor performance.
5) Where to start as a trader? Watch this webinar and read this thread for hundreds of questions and answers.
6)
Help using the forum? Watch this video to learn general tips on using the site.

If you want
to support our community, become an Elite Member.

Reply With Quote
 
  #5 (permalink)
Elite Member
Brisbane, Australia
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Mirus/Zen-Fire
Favorite Futures: CL
 
nanobiotech's Avatar
 
Posts: 670 since Jun 2009
Thanks: 134 given, 428 received


Big Mike View Post
I moved the thread to NinjaTrader programming from Elite Group Trading methods. So long as you don't post Elite code (Hurley) I think it would be best here. Your example is really non-specific to Hurley.

If you don't want it here I can move it to the general Elite area, but it shouldn't be in the group trading area.

Mike

No problem Mike.
Thanks
Nano

Reply With Quote

Reply



futures io > > > > > Protecting the cumulative profit target in an automated strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
profit target strategy on tradestation dirtybird EasyLanguage Programming 3 November 23rd, 2010 01:07 AM
Profit Target as Percent Gain ascr EasyLanguage Programming 4 November 17th, 2010 05:33 PM
Automated Strategy with two profit targets rexman00799 NinjaTrader Programming 6 July 23rd, 2010 10:59 PM
What is the best way to work out your profit target? pyekorn Psychology and Money Management 14 July 22nd, 2010 02:14 AM
where should profit target be placed? anniebee321 Beginners and Introductions 9 June 7th, 2010 08:38 AM


All times are GMT -4. The time now is 09:18 AM.

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-11 in 0.11 seconds with 19 queries on phoenix via your IP 54.226.227.175