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)
Is there anything wrong with the following code?
What Im trying to do is as follows.
1. Send a long order based on required conditions.
2. Set a breakeven stop if position moves up x number of pips.
3. Set a jump signal (sort of a big one time trailing stop) if position moves certain number of pips in profit.
4. Set a regular stop loss in case position goes into a loss.
5. Set a target profit.
Breakevenstop = 20 pips above entryprice
JumpLong = if price moves 40 pips above entryprice, and JumpLong Stop is set at 30 pips above entryprice at 1.1130
LSVal = 40 pips below entry
CloseLong = 100 pips above entry
So if i buy EUR/USD at 1.1100, and market moves to 1.1120, Breakeven stop is set at entryprice.(1.1100)
If market moves up to jump stop level at 1.1140, Jumplong stop is posted at 1.1130.
If market moves down 40 pips below, LSVal stop is triggered at 1.1060.
If market continues moving up, profit target is hit at 1.1200.
A few issues.
1. However, when I run a backtest on it, it triggers orders sporadically. At times it misses the jumpstop, and eventually goes on to hit the stoploss, even though the jump opportunity came first.
2. I want to use my own code instead of reserved functions (setstoploss, setbreakeven, etc), as I want to add more functionality to my stops. Seems like it this is that is causing the randomness of order triggers. What can i do/change to avoid that?