Greetings
I would like to code a re-entry trade into my script when my stop loss is hit and closes a position but the instrument turns and moves back in the direction of my original logic. I only want to re-enter if my stop loss is hit not my profit target. I see that the Order Name comes our as either Profit target or stop loss when my position is closed.
Is there a way to allow my script to read the Orders and determine if a stop loss closed my position?
I found a function called PosTradeExitName that requires the Trade Number to give you the Exit Name. I think if I could get the Trade Number It would be easy to determine if the exit order was a Stop Loss. As I am typing this I am realizing that there could be multiple Trade Numbers required to exit a position. So, If anyone knows what I would put in as Trade Numbers to indicate the orders closing the last position I would appreciate it.
https://www.multicharts.com/trading-sof ... deExitName
Determining if a Profit Target or Stop Loss is fill [SOLVED]
-
- Posts: 14
- Joined: 28 Jan 2022
- Has thanked: 6 times
- Svetlana MultiCharts
- Posts: 645
- Joined: 19 Oct 2017
- Has thanked: 3 times
- Been thanked: 163 times
Re: Determining if a Profit Target or Stop Loss is fill
Hi altoncrooks,
Here is an example of the script that prints names of orders which closed the positions.
Here is an example of the script that prints names of orders which closed the positions.
Code: Select all
var: NameOfExit(""), MrkPos(0);
MrkPos = marketposition;
if (marketposition = 0) and (MrkPos[1] <> 0) then
begin
if (maxpositionsago > 1) then
begin
NameOfExit = PosTradeExitName(1,PosTradeCount(1)-1);
print("Bar = ", currentbar+MaxBarsBack:0:0, " ", NameOfExit);
end;
end;
-
- Posts: 14
- Joined: 28 Jan 2022
- Has thanked: 6 times
Re: Determining if a Profit Target or Stop Loss is fill [SOLVED]
Thank you so much Svetlana. Have a great weekend!