Stop / close Position on close bar or alert with trigger too close

Forums ProRealTime English forum ProOrder support Stop / close Position on close bar or alert with trigger too close

Viewing 15 posts - 1 through 15 (of 15 total)
  • #113324

    Hi guys,

    it happens sooooooo often that i set a stop e.g. under a support with 20 or more points (depending on volume) below but then the price hits the stop and went then dircetly up for 100 points or more in seconds. I am wondering if i am the only one, who would like to have an option for a stop or a close position trigger in the alert on close bar not when hitting the line or price. Is there any option to achieve this???

    I tried it with the alert trigger. It closes the position when i set the opposite order and not foreced open is activated, BUT it opens a new posistion. This is not what i want or am i doing sth. wrong?

    I just want to close the position on close bar! Any options, or ideas?

    Thank you for any help

     

    #113335

    To accomplisg that you need not use STET STOP LOSS, but use code, instead:

    this will only exit your trade AFTER a bar closes at or under your SL level. The only drawback is that it can be UNDER, the advantage is that your SL line may be hit, but a price retracement may spare you from a losing position if the prices later goes up again and hits your TP.

    #113336

    Well… not setting a SL may make your broker apply higher margin requirements for that trade, so you could use a huge fake SL before line 7, such as:

     

    #113339

    Thank you robertogozzi for your code snipet. I will give it a try. I add this in automatic trading, yes?

    #113344

    Yes.

    #113348

    Added as Log 187 to here

    Snippet Link Library

    1 user thanked author for this post.
    #113358

    Roberto’s code does not allow for gaps between the close and the open of the next candle which is the price you will actually be buying at. This code does:

    You have to be aware that by only closing a trade at the close of a candle (open of the next in reality) you are leaving yourself open to price blowing straight through your stop loss value and falling massively lower before you sell which could equal a very big loss compared to your stop loss value.

    #113361

    Roberto’s code does not allow for gaps between the close and the open of the next candle which is the price you will actually be buying at.

    Yes Vonasi, but your code, in case the price drops will cost 20 more pips than the previous closing price. If there’s a 30-pip gap my code will make the trade lose 30 pips, your code may cost 50 pips!

    #113368

    Not sure that I understand your maths Roberto – then again I have had a couple of glasses of wine!

    Your code would assume that if the close was at a price of 1000 then the stop should be set at 980 but if there was a 19 pip gap down and the next open was at 981 then you would buy at 981 and set a stop loss at 980. You will lose money pretty much every time! However with my code if the close price was 1000 and the next open that you bought at was 980 then the stop would be at 960 and you would benefit from a low buy price and have a stop loss at a sensible level from it. If the gap was a big gap up then your code would leave a very big drop to the stop loss value whereas mine would be just the expected 20 pips.

    Note: My code assumes just one position open at a time.

    #113377

    Yes, but your LongOnMarket status would only be true at the closure of next candle, maybe too late to set a 20-pip SL.

     

    #113378

    The long on market status is from your original code. The first time either of our codes checks to see if it should sell in a loss is at the end of close of the bar that we bought at the open of. Your code sets a stop loss based on the close of the previous bar and mine sets it based on the actual price that we bought at.

    Topic moved to ProOrder forum as I think that is a better place for it.

    #113380

    My code did not set an SL after checking LongOnMarket.

     

    #113392

    Your code calculates the SL level at the close of a bar, then enters at the open of the next bar and then checks to see if we are below the level at the close of that bar.

    My code enters at the open of the next bar and then calculates the SL level and checks to see if we are below that level at the close of that bar.

    The only difference is the time that the stop loss level is calculated so that mine can be calculated when we know what price we entered at whereas yours assumes that the open of the next candle is the same as the close of the one we decided to open a trade from.

     

    #113394

    👍🏻

    #113395

    For me and my usecases the probability to be stopped too early and having a rebound is much higher then losing some pips because of a gap or for e.g. a very fast rise.  Everything has its risk, but of 10 stops i maybe have only 1 gap. With this ratio i can live very well 🙂 In case of a very fast rise, i will enhance the code with sth. watching when the traded volume is rising fast to make then a direct stop.

    Thank you guy for your support!

Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login