Hi Guys, Hoping you can help…….
My question is in 2 parts:
1: I enter a buy position, and i can tell what the entry is by Tradeprice(1)
Then a few bars later I enter a 2nd (cumulate) buy position.
Question: Is the 1st position still Tradeprice(1) and the 2nd position Tradeprice(2)? (or visa versa)?
2: I enter a buy position, with Take Profit (Limit) at 20 pips
Then a few bars later buy another (cumulative) position. (My 2nd added position also then automatically has a Take Profit of 20 pips).
I now have 2 positions both with a Take profit of 20 pips
Question: How do i now alter only the 1st position to take profit at a different level (ie change the limit to say 50 only on the 1st position)?
Any help is appreciated.
Hello pips_103,
- The very last position opened is tradeprice(0). So the order is in reverse from when the trades were executed.
- Maybe this thread will help: https://www.prorealcode.com/topic/stop-loss-profit-target-do-they-affect-all-positions/
Concerning 2) does this help?
Thanks Derek, appreciated
Hello Pips,
just got into this topic myself and found this in the proorder manual:
Multiple stop and target levels
Only one “Set Stop” and one “Set Target” command can be active at a time under normal circumstances. If there are successive “Set Stop” or “Set Target” commands in a code, the last command replaces the previous command.
Example:
SET STOP %LOSS 10 // Set a stop loss of 10%
SET TARGET PROFIT 50 // Set a profit target of 50 units
SET TARGET %PROFIT 5 // Removes the previous target of 50 units and replaces it with a profit target of 5%
SET STOP %TRAILING 2 // Removes the previous 10% stop loss and replaces it with a trailing stop of 2%
So, I guess the answer is “no”, unfortunately.
ah yes, your right, Thanks Derek 🙂
The very last position opened is tradeprice(0). So the order is in reverse from when the trades were executed.
Follow up on this — on a candle there could be an “buy long” order that happens as well as “trailing stop loss” order triggered exiting a previous position (or perhaps the one you just entered if it’s a long candle).
Question — in your code how do you know/determine which came first on that candle and what the value of each order was?
THank you
If you want to know if the last tradeprice is the trailing stop activated, check if the order is in profit or not.
thanked this post