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)
EasyLanguage: Changing the StopLoss after Reaching a Target
I'm trying to create my own stop loss strategy where an initial take profit order and stop loss order are set upon entering the trade and triggered when either "ProfitTarget" or "StopLoss" are reached.
However, I want my stop loss to move to a pre-determined level ("StopLossAdj") once the price reaches a certain threshold ("RatchetAmt") above the EntryPrice.
The code below works fine for most trades but not for others and I don't understand why. I join two screenshots taken from the exact same 2000 tick chart. All trades have the same signals applies to them.
On the first screenshot, we see the code working as expecte: the stoploss on the left trade is moved to 1 below entry price after ratchetAmt 3 is reached. On the right side, the ratchetAmt is never reached so the price stops out at StopLoss 6 points below EntryPrice.
Yet, on the following trade (second screenshot), the price does reach ratchetAmt 3 but the stop is apparently not moved to the level 1 point below EntryPrice. It should have triggered there.
I'm relatively new to learning EasyLanguage. I've spent two days trying to work it out. Thank you for your help.
you are using "SetStopLoss" twice in your code. The first one is valid on every bar and the second one would only be used on bars where "High >= (EntryPrice + RatchetAmt )", but not on later bars where High < (EntryPrice + RatchetAmt ), even if the condition was met on a prior bar. On those bars only the first stop would be used according to your code, which appears to be what you are seeing on the chart, too.
You could consider using the reserved word SetStopLoss once only at the end of the code and using a variable that holds the stop amount.
If you are flat you would reset the variable (let's call it myStopAmount for this example) to myStopAmount = StopLoss* BigPointValue and in case High >= (EntryPrice + RatchetAmt ) while you are in a position you would set it to myStopAmount = StopLossAdj * BigPointValue.
At the end of the code you would issue the stop using SetStopLoss( myStopAmount ).