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)
buy next bar... and set stop immediately and not for the bar after
Hi,
i was reading your post here and got surprised by the standard MC stoploss function:
inputs: StopLossPct( .05 ) ;
SetStopShare ;
if MarketPosition = -1 then
SetStopLoss( EntryPrice * StopLossPct )
else Buy To Cover ( "PctStopSX-eb" ) next bar at Close * ( 1 + StopLossPct ) stop ;
Basically it looks the function sens a BUY to cover even if no position is open and when a position is open it changes it with a setstoploss.
I am confused.
My target is to have a stop loss that acts on the same bar of the entry but at the same time i can't use barmagnifier (i use a continuos future and it is not allowed in MC).
What's the best way to achieve this?
If write this generic stoploss function does it make sense?
SetStopShare;
if (MarketPosition = 1) and (LXStopLossPct > 0) then SetStopLoss(EntryPrice * LXStopLossPct * mlt);
if (MarketPosition = -1) and (SXStopLossPct > 0) then SetStopLoss(EntryPrice * SXStopLossPct * mlt);
if (MarketPosition = 0) and (LXStopLossPct > 0) then Sell ( "PctStopLX-eb" ) next bar at EntryPrice * ( 1 - (LXStopLossPct * mlt)) stop;
if (MarketPosition = 0) and (SXStopLossPct > 0) then Buy To Cover ( "PctStopSX-eb" ) next bar at EntryPrice * ( 1 + (SXStopLossPct * mlt)) stop;
In my view this make not much sense but the standard MC function looks similar to this.
Can you help answer these questions from other members on NexusFi?
you should try your code on a simulation account to see how it works. I would slightly rewrite it to this (note that I didn't check/test your code, it's just a modification of what you wrote). There is a difference in both codes in that yours does only send the buy to cover or sell order for Marketposition = 0.
Without the BarMagnifier and depending on the resolution you work with, the results shouldn't be trusted and carefully checked with simulted (at least, live would be better) forward testing! There is simply too much information missing in bar and the program tends to make wrong assumptions then - for example was a stop hit first before the target was reached or vice versa.