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)
Im trying to plot a trailing stop on my chart of the current open trade. I need to find the Max profit that was achieved with the aim of closing the trade when 50% of the open profit is lost. I have tried OpenEntryMaxProfitPerContract and MaxContractProfit but its not getting the result I hope for. It appears to be using the second last bar, not the last bar to work out the Max Profit (I think).
If you have bars with minute time stamps (HHmm, for example 8:09 am) then LastBarOnChart is triggered on the last bar. However, if you have bars with seconds time stamps (HHmmss, 8:09:34 am), then LastBarOnChart_s should be used.
Btw, just always use LastBarOnChart_s since that also works correctly with minute bars.
Btw 2, if you intend to backtest this code, it might be advisable to use MarketPosition instead of LastBarOnChart_s. Something like this:
Im using the code in a Signal and test MarketPosition(0) = 1.
I think the problem is Im using it on Daily Bars only. I dont have access to intra day data as Im still evaluating Multicharts (for the last 2 weeks). I will be backtesting on intra day data once I buy Multicharts.
Perhaps this problem I am coming up with is a limitation which is exposed only on Daily Data. On an intra day Signal test I would be using 5min and 1hr charts and then the issue is not such a big deal.
Your thoughts?
P.S I have been reading some of your replies last night. Your obviously a very good programmer.
That's possible; I've also experienced problems with the last daily bar not being evaluated by the code. It turned out that I had the wrong session template with an instrument with a exchange time zone that was different from mine.
You can change the session template by double-clicking on the instrument, tab Settings, and then Sessions.
Btw, you can easily test if the code processes all bars (including the last) with:
The information in the PowerLanguage Editor output log will then show for the last bar the same date time as on the chart. If that's not the case, you may need to change your session settings.
The last bar Date printed was the second last bar Date not the last bar Date (today). Changing session template or timezone didnt help either. Im from Australia and testing on the XJO daily data. Thanks for the help though.
Hi NW27
High will give you the high of the second last bar in a Signal. Obviously in an Indicator it will give you the last bar.
Again its looking at the second last bar even though the Last bar (today) is higher.
I think its how the Multicharts backtesting engine works. It will give the correct signal on the next bar as it assumes you cant give a signal until the bar is closed AND the next bar is opened. Like setting a buy / sell on next bar. eg sell ("Above 3 Week 50% Stop") next bar at (MyWeekly50 - 10) Stop;
BTW NW27. I have been reading this forum for a few weeks and notice you trade SPI. I want to get historical SPI data and a live data feed. Any hints? ( I have been using IG Markets for a few years but want to backtest and auto execute).