Help on strategy stoploss - NinjaTrader Programming | futures io social day trading
futures io futures trading


Help on strategy stoploss
Updated: Views / Replies:3,259 / 6
Created: by mea109 Attachments:1

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
 

Help on strategy stoploss

  #1 (permalink)
Elite Member
france
 
Futures Experience: Beginner
Platform: nt
 
mea109's Avatar
 
Posts: 201 since Oct 2009
Thanks: 1,776 given, 50 received

Help on strategy stoploss

Hello,

I've coded a few indicators but this is my first strategy. Please excuse me if my question feels basic.

What I'm trying to achieve ...in picture.

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


If I use on "Initialise" :
 
Code
private int stp=10;
SetStopLoss("Entry1", CalculationMode.Ticks, stp, true);
That is not what I want since the stop stance will be impacted by the entry slippage from the market order, which is precisely what I want to avoid ...

Then I've tried to use on "OnBarUpdate" :
 
Code
if(BarsSinceEntry("Entry1")==0) SetStopLoss("Entry1", CalculationMode.Price, Close[0]-stp*TickSize, true);
This takes the Close from the signal bar (bar 1) which is about the Open price from the entry bar (bar 2) ..but not quite on every single trade Worse than that, it creates a random behavior on my stops.

Could you please help me to simply code : set stoploss to real Open price from entry bar (without slippage impact from market entry order) - 10 ticks ??
That stoploss needs to be set once (just after entry) and should not be moved afterwards.

Thank you très beaucoup

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)
Elite Member
Lubbock TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Stage 5 Trading
Favorite Futures: CL
 
MWinfrey's Avatar
 
Posts: 1,879 since Jul 2009
Thanks: 1,449 given, 3,306 received


set the stoploss the same time you enter the market...forget the if(BarsSinceEntry...

 
Code
EnterLong("Entry1");
SetStopLoss("Entry1", CalculationMode.Price, Close[0]-stp*TickSize, true);
That should do the trick...

Reply With Quote
The following user says Thank You to MWinfrey for this post:
 
  #4 (permalink)
Elite Member
france
 
Futures Experience: Beginner
Platform: nt
 
mea109's Avatar
 
Posts: 201 since Oct 2009
Thanks: 1,776 given, 50 received

Thanks MWinfrey

If I write this it takes into account the Close from the signal bar but not the Open from the entry bar (the next bar) which is what I want to achieve.

My goal is to set the stop from the Open of the entry bar because often in a 2 bar sequence Open[0] and Close[1] are not properly equal on minutes charts. Can it be done ? Thanks again

Reply With Quote
 
  #5 (permalink)
Elite Member
france
 
Futures Experience: Beginner
Platform: nt
 
mea109's Avatar
 
Posts: 201 since Oct 2009
Thanks: 1,776 given, 50 received

Maybe I'm forced to set it to the Close of the signal bar beecause that's the best I can do ...and move it to the Open of the entry bar the bar after ?

I'm interested to make it work in a live situation. I don't care about running it as a backtest (I have a panel indicator planned for live backtest tracking).

Reply With Quote
 
  #6 (permalink)
Elite Member
Lubbock TX
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Stage 5 Trading
Favorite Futures: CL
 
MWinfrey's Avatar
 
Posts: 1,879 since Jul 2009
Thanks: 1,449 given, 3,306 received


mea109 View Post
Thanks MWinfrey

If I write this it takes into account the Close from the signal bar but not the Open from the entry bar (the next bar) which is what I want to achieve.

My goal is to set the stop from the Open of the entry bar because often in a 2 bar sequence Open[0] and Close[1] are not properly equal on minutes charts. Can it be done ? Thanks again

Try this...haven't tested but it should work. The problem is when using COBC = true which is the default, all code is executed at the open of the next bar. However, as you know the entry price is the open of the next bar but the stoploss is the close of the signal bar. So, what you can do to overcome this is to set the stop at the same time as you enter the market and then reset it at the close of the next bar. The only problem that I can think of is if the first bar is long enough to hit your stop before you can reset the stop. Maybe others have a better idea than this. Again, I haven't tested this but believe it will work.

put this in your variable declarations area.
 
Code
private int longentrybar = 0;
put this in OnBarUpdate...also notice the parentheses I placed around (stp*TickSize). I notice you have the simulated parameter set to true. Be sure you know what that means before using it.
 
Code
if <long entry rules are met>
{
   EnterLong("Entry1");
   SetStopLoss("Entry1", CalculationMode.Price, Close[0]-(stp*TickSize), true);
   longentrybar = CurrentBar;
}

if (CurrentBar - longentrybar == 1)
   SetStopLoss("Entry1", CalculationMode.Price, Open[0]-(stp*TickSize), true);
You can also look at the BarsSinceEntry() method instead of using the CurrentBar - longentrybar calculation...

Reply With Quote
The following user says Thank You to MWinfrey for this post:
 
  #7 (permalink)
Elite Member
france
 
Futures Experience: Beginner
Platform: nt
 
mea109's Avatar
 
Posts: 201 since Oct 2009
Thanks: 1,776 given, 50 received

Your code works as described! I believe it's the closest one can accomplish although it is in fact a handicap to keep the risk of the stoploss unproperly set on the signal bar while waiting for the next one. At the same time, I tried to play with COBC=False with no more success.

I used BarsSinceEntry since I manage too many separate orders that I can declare variables for. I build my position from multiple fractions of futures contracts via CFDs so I use a loop condition in OnBarUpdate instead.

I did read about the simulated parameter but it seems like I did not understand it right. Thanks for having put my attention on it ! That's part of education

Reply With Quote
The following user says Thank You to mea109 for this post:

Reply



futures io > > > > > Help on strategy stoploss

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
stoploss to breakeven to trailing stephenszpak NinjaTrader Programming 13 October 13th, 2014 04:30 PM
stoploss and swinghigh/low indicator Blackburn NinjaTrader Programming 2 September 21st, 2011 04:08 AM
StopLoss as fraction of ATR FArias NinjaTrader Programming 5 February 23rd, 2011 03:45 PM
Help Coding Trailing stoploss in Strategy Darshiit NinjaTrader Programming 3 June 25th, 2010 10:45 AM
How to override Stoploss generated by a strategy in Superdom puppeye NinjaTrader Programming 9 February 27th, 2010 01:14 AM


All times are GMT -4. The time now is 02:15 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 20 queries on phoenix via your IP 54.226.34.209