Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
If I use on "Initialise" :
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" :
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
Can you help answer these questions from other members on NexusFi?
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
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).
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.
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.
You can also look at the BarsSinceEntry() method instead of using the CurrentBar - longentrybar calculation...
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