Limit orders based on stop loss level

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #213697 quote
    Catalin
    Participant
    New

    Hi everyone.  I am very new at this, I tried and failed to set it up so I’m left with having to ask for help.

    On the close of the signal candle I’d like to place a limit order based on a stop loss level.

    For example, for a long, once the signal candle closes, I’d want my stop lets say 5 points beneath the low and would want to risk lets say 10 points.  I’d get in if the market pulls back to the level or, limit order to turn to market order if price already lower.  The option of a target would be a bonus.

    Alternatively consider the range of the signal candle and then place a limit order on a percentage retracement.

    Does anyone have the code for something like this?

    Thank you in advance,

    Catalin

    #213703 quote
    robertogozzi
    Moderator
    Master

    You wrote “I’d want my stop lets say 5 points beneath the low and would want to risk lets say 10 points“. What if the distance from the current price and the low-5 points is higher than 10 points? Would you reduce the SL or ignore the signal without opening a trade?

    Anyway, to set a stop loss 5 points beneath the low of the signal candle:

    IF MyLongConditions THEN
       BUY 1 Contract at Market
       SET STOP PRICE low - 5*PipSize
    ENDIF
    Catalin thanked this post
    #213709 quote
    ZeroCafeine
    Participant
    Senior

    I’m not sure, but when he said : “I’d want my stop lets say 5 points beneath the low and would want to risk lets say 10 points“, maybe he want to risk 2 lots : 2 x 5 pips = 10

    #213720 quote
    Catalin
    Participant
    New

    Thank you gents,

    ZeroCafeine, I spread bet and I am ok with setting the bet size.

    Roberto, is there a way to set a limit order? I attached a file hopefully making it clearer.

    Thanks,

    Catalin

    1.png 1.png 1-1.png 1-1.png
    #213728 quote
    robertogozzi
    Moderator
    Master

    There you go (not tested):

    IF OnMarket THEN
       SL = 0
    ENDIF
    IF MyLongConditions THEN
       SL    = low - 5*PipSize
       Entry = min(open,close) - 5*PipSize
       SET STOP PRICE SL
    ENDIF
    IF SL <> 0 THEN
       BUY 1 Contract at Entry LIMIT
    ENDIF
    Catalin thanked this post
    #213743 quote
    Catalin
    Participant
    New

    Thanks for your time but I can’t get it to work, most probably because I’m illiterate.

    Will keep trying 🙂

    #213770 quote
    robertogozzi
    Moderator
    Master

    Append these two lines to your code, to plot both SL and ENTRY on your chart when backtesting:

    GraphOnPrice ENTRY coloured("Blue",255)
    GraphOnPrice SL    coloured("Red",255)
    Catalin thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Limit orders based on stop loss level


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Catalin @catalin Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by robertogozzi
2 years, 9 months ago.

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