I've got a weird problem in my strategy that I cannot fathom as to what's happening with it. My strategy takes a trade in a certain direction - for this example I'll use a long trade.
Enter long position ( long NQ at 16000 )
Use SetProfitTarget to set my target to 20 ticks. ( NQ 16005 )
The trade wins.
NEXT TRADE.......
Enter long position ( long NQ at 17000 )
Trade instantly exits usually for a tick or 2 loss
Script tries to SetProfitTarget to my target of 20 ticks. ( NQ 17005 )
Script errors because the position has already closed due to the trade exiting immediately.
When I look into what's happened, as soon as it's taken the new position, there's an entry in the log that says it's setting the Profit Target to 16005, which is below the currently price, so it instantly closes the position - if you remember, the previous trade had a profit target of 16005! This happens over and over and I can't fathom why! ... I'm only ever using SetProfitTarget to 8 ticks in my script, but it's somehow using the value from the previous trade????
myEntryOrder = EnterLong(1, "MyScriptEntry");
SetProfitTarget("MyScriptEntry", CalculationMode.Ticks, 20);
Here is line by line log of an actual trade that worked out, but can you see it falsely sets the target at first ... as you can see, highlighted in red, it immediately sets a target of 16787(Which was the previous trades target). Luckily in this example, the previous target of 16787 was actually higher than the entry price of 16784.75 so it didn't close instantly, you can then see the script changing the profit target to the correctly value by the a "Change submitted" line, which is modifying the profit target to what is should be(16789.75)
Hope that makes sense!
Thanks
Andy

Comment