Stoploss not put in place

Viewing 15 posts - 1 through 15 (of 37 total)
  • Author
    Posts
  • #225513 quote
    ashehzi
    Participant
    Average
    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.

    NoStopLossPutInPlace.png NoStopLossPutInPlace.png NoStopLossPutInPlace_PRT.png NoStopLossPutInPlace_PRT.png
    #225518 quote
    GraHal
    Participant
    Master

    Does it work correctly with …

    SET Stop PLOSS sDistance
    #225520 quote
    ashehzi
    Participant
    Average

    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.

    #225547 quote
    Jean FX
    Moderator
    New

    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”

    #225563 quote
    ashehzi
    Participant
    Average

    Is there a way to enable tracing in the product or have a look at the logs without contacting PRT support?

    #225567 quote
    justisan
    Participant
    Junior

    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.

    ashehzi thanked this post
    #225568 quote
    justisan
    Participant
    Junior

    …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…

    ashehzi thanked this post
    #225572 quote
    ashehzi
    Participant
    Average

    Thanks. I am testing both (SET TARGET PLOSS & SET STOP PLOSS) to see the results.

    #225579 quote
    Wim
    Participant
    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).

    #225583 quote
    PeterSt
    Participant
    Master

    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)

    #225589 quote
    Wim
    Participant
    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.

    PeterSt and ashehzi thanked this post
    #225594 quote
    ashehzi
    Participant
    Average

    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.

    #225595 quote
    ashehzi
    Participant
    Average

    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

    ShortOrder-NoSLNoTP.png ShortOrder-NoSLNoTP.png ShortOrder-NoSLNoTP_PRT.png ShortOrder-NoSLNoTP_PRT.png
    #225601 quote
    JS
    Participant
    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)

    #225607 quote
    ashehzi
    Participant
    Average
    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.
Viewing 15 posts - 1 through 15 (of 37 total)
  • You must be logged in to reply to this topic.

Stoploss not put in place


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ashehzi @ashehzi Participant
Summary

This topic contains 36 replies,
has 8 voices, and was last updated by ashehzi
2 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/20/2023
Status: Active
Attachments: 12 files
Logo Logo
Loading...