|June 29th, 2015, 05:21 AM||#1 (permalink)|
Futures Experience: Advanced
Favorite Futures: Gold
Posts: 10 since Sep 2014
Thanks: 2 given, 1 received
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?
Apologies if any of this sounds confusing.