SELLSHORT 1.0 CONTRACTS AT myLevel limit
SellPrice = TRADEPRICE
SET TARGET PLOSS sDistance
SET TARGET PPROFIT pDistance
I’ve above code in an algo and short trade just got executed. It set the profit but not stoploss. It has done both in the past so wondering how such msgs between IG and PRT get lost or not fired by PRT. You can see in the attached images.
Does it work correctly with …
SET Stop PLOSS sDistance
In general, it works with
SET TARGET PLOSS sDistance
I will change to
SET STOP PLOSS sDistance
but the same issue can happen randomly. I am not sure if it is related to TARGET instead of STOP but as I said, it works generally.
I think you could send a technical report to PRT :
– As soon as you encounter the issue, go to the “Help” menu on the ProRealTime toolbar.
– Please assure that the window concerned by this issue is open.
– Click on “Help center”, then on “I have a technical problem”
– Choose the category “Automatic trading”
– Give the name of the code you are referring to.
– To benefit from a technical help, it i necessary to authorize the access to the crypted code. To give them a temporary access, please check the box “I authorize the decryption of the codes (…)”
– Give as many details as possible, explain the issue you are having in the text box and mention
– Click “Send report”
Is there a way to enable tracing in the product or have a look at the logs without contacting PRT support?
hi, I did not know that one can place an order for limiting the losses with a “set target ploss” command, it must be something relatively new. yet I was now opening the programming manual and wow – in fact this possibility is offered. but I think one needs to read the description very carefully, it tells:
It is also possible to limit losses with a target order when a position is currently losing. The limit is then placed in the direction of the loss of the position:
SET TARGET LOSS x: A limit is placed at x units from the position entry price.
so, it might be very important – that hint to “when a position is currently losing…” – that could mean that corresponding order is issued not at the same time when position is opened, but “later” – at the time when open position runs into losses. I did not test it, it’s only my thinking/guessing.
…while with the command “set stop loss” the stop loss order is really always placed at the time of position opening. at least myself I really never experienced a case after (thousands of trades executed) that it was not placed…
Thanks. I am testing both (SET TARGET PLOSS & SET STOP PLOSS) to see the results.
WimParticipant
Junior
There is also the effect that the LAST “set target x y” cancels the previous “set target a b”. As far as I know it’s always the last “set stop…” or “set target…” that’s active. That explains to me why in your first example the stop wasn’t active (any more).
As far as I know it’s always the last “set stop…” or “set target…” that’s active.
Wim, do you mean that a set stop will cancel a set target and vise versa ?
(this is not really clear and I like to know, not having the experience this time)
WimParticipant
Junior
Nope. A “set stop” cancels the previous “set stop”, and you need another “set target” to make forget the previous “set target”. It’s like fratricide 🙂
I almost always use a combination of a set stop and a set target, works flawlessly.
So you’re telling me below code must leave an order with target profit and stop loss
IF NOT LONGONMARKET AND LongCondition THEN
BUY 1.0 CONTRACTS AT myLevel limit
SET STOP PLOSS lossDistance
SET TARGET PPROFIT profDistance
ENDIF
I am not sure it is doing all the time. I am still testing. My understanding any time above code gets executed, it must leave an order with stop loss and target profit limit and should not leave just an order without stop loss and target profit limit because it can adverse effects when the market moves fast.
I’ve below code running since yesterday. It left an order earlier in the day without stop loss and profit:
IF NOT ShortOnMarket AND TIMEOPERATE AND (BARINDEX > 1000) AND (ordersCount < maxOrders) THEN
SELLSHORT 1.0 CONTRACTS AT myLevel limit
SellPrice = TRADEPRICE
SET STOP PLOSS myStopLoss
SET TARGET PPROFIT myTargetProfit
ENDIF
Please see attached
JSParticipant
Senior
According to your screenshots, the order is still “pending”…
If your order has not been executed, there is no associated Stop Loss and Take Profit…
I tried your code and after the order was executed, the Stop Loss and Take Profit were immediately placed…
(Protection Stops and Target orders are linked to an open position and valid until the close of that position)
I get your point regarding the sequential nature of the steps. But if I leave a guaranteed order, it shows stop loss and target profit evening in pending state. Same is true for manual order placement but why not for algo order without guaranteed stop. Why it is not an anomaly? It guarantees slippage in news related movement where a second difference between 1st order placement and then stop loss placement can cause big losses.