How to detect pending Sell Stop and BuyToCover Stop orders?
Posted: Apr 05 2016
Hey,
Is there any way to detect existing/pending Sell Stop and BuyToCover stop orders?
For example, let's say a signal executed this:
Okay, so now during a short trade we've got a stop loss that is a certain distance above the entry price.
Is there any way that I can detect the existence of ANY stop loss order inside the same strategy (preferably in another signal)? What I mean by the distinction "ANY stop loss order" is that I do not need to detect the specific order itself. I just want to find out if any stop loss exists.
To illustrate the use case, let's say I wanted to put the above code in the strategy to enforce breakeven covers in certain situations. Then, as the last signal in the strategy, I want to enforce a stop loss value if no other stop loss order exists, so I write a simple signal:
Any help or direction would be greatly appreciated. I've looked through the order and strategy keywords and I'm coming up blank. I realize the solution is almost certainly there somewhere, but I'm not able to find it.
Is there any way to detect existing/pending Sell Stop and BuyToCover stop orders?
For example, let's say a signal executed this:
Code: Select all
if (MarketPosition(0) = -1) and eventBreakevenCoverTrigger then begin
BuyToCover ("BreakEven Stop") next bar at EntryPrice STOP;
end;
Is there any way that I can detect the existence of ANY stop loss order inside the same strategy (preferably in another signal)? What I mean by the distinction "ANY stop loss order" is that I do not need to detect the specific order itself. I just want to find out if any stop loss exists.
To illustrate the use case, let's say I wanted to put the above code in the strategy to enforce breakeven covers in certain situations. Then, as the last signal in the strategy, I want to enforce a stop loss value if no other stop loss order exists, so I write a simple signal:
Code: Select all
inputs:
inputDefaultStopLoss (20);
variables:
conditionStopOrderExists (False),
pipsOnePipBroker (MinMove/PriceScale * 10);
conditionStopOrderExists= *** [This is what I do not know how to do] ***
if MarketPosition(0) = -1 and conditionStopOrderExists=False then begin
BuyToCover ("Default Stop") next bar at EntryPrice + (pipsOnePipBroker * inputInitialStopLoss) STOP;
end;