SORRY, PLEASE IGNORE THIS! I can’t see how to delete it. I think that I stopped it from running automatically, so no wonder it didn’t move the stop order.
In my PRT code I have some profit management which is meant to set a stop at breakeven, copied from a post on this forum. This works in backtesting, but today it failed when running on the real platform, so my trade lost when it would have broken even had the stop order worked. Does anyone have any ideas, please?
I’ve pasted in the profit management code below. I know that this doesn’t quite make sense with PointsToKeep being zero, but I wanted to post exactly what’s running.
You can see that PRT exits at the Breakeven level, but the trade running on the platform didn’t do this.
Profit Management code that isn't working
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
InProfit=18
InProfitShort=38
PointsToKeep=0//how many points to keep in profit above or below our entry price when the breakeven is activated (beware of spread) - optimised
PointsToKeepShort=4
//reset the breakevenLevel when no trade are on market
IFNOTONMARKETTHEN
breakevenLevel=0
ENDIF
// --- BUY SIDE ---
//test if the price has moved favourably "startBreakeven" points already
IFLONGONMARKETANDclose-tradeprice>=InProfitTHEN// price has moved up a good distance
breakevenLevel=tradeprice+PointsToKeep// move up the stop
ENDIF
//place the new stop orders on market at breakevenLevel
IFLONGONMARKETANDbreakevenLevel>0THEN
SELLATbreakevenLevelSTOP
ENDIF
graphbreakevenlevel
graphtradeprice
// --- end of BUY SIDE ---
The screenshot shows it working as designed in ProReal.
I tried to add another screenshot showing the results of the trade, but that didn’t seem to work, so I’ve pasted them in below – sorry if the formatting doesn’t come out well. The code is running in my Swiss account, which is one hour ahead of the ProReal time in the UK.
Date Summary MarketName ProfitAndLoss Open level Close level Size Currency PL Amount DateUtc OpenDateUtc
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.