Stop loss below/above the open position candle

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #236933 quote
    davidator
    Participant
    Junior

    Hi,

    I’m starting to use probacktest, I can’t find a way to put the stop loss below the candle where a long position is opened, or above the candle of a short position.

    Thanks for the help!

    Dave

    #236934 quote
    robertogozzi
    Moderator
    Master

    There you go:

    IF Not OnMarket THEN
       // LONG  entry
       IF MyLongConditions THEN
          BUY 1 CONTRACT AT MARKET
          SET STOP PRICE (low - 1*PipSize)
       ENDIF
       // SHORT entry
       IF MyShortConditions THEN
          SELLSHORT 1 CONTRACT AT MARKET
          SET STOP PRICE (high + 1*PipSize)
       ENDIF
    ENDIF
    davidator and Iván González thanked this post
    #236938 quote
    JS
    Participant
    Senior

    Maybe as a supplement…

    A (classic) “Set Stop Loss” is always calculated from the (average) price at which the position is opened…

    Set Stop pLoss 10 will place a stop loss of 10 points/pips below the purchase price of your “long” position or 10 points/pips above the purchase price of your “short” position…

    If you don’t want to use points/pips but prefer a price level, you can use “Set Stop Price”…

    Set Stop Price Low will place a stop loss on the price level of the “Low” of the previous candle…

    Set Stop Price High will place a stop loss at the price level of the “High” of the previous candle…

    #236955 quote
    davidator
    Participant
    Junior
    Thank you for both messages!  Now it’s clear. I would also like to understand how to set a take profit order when a certain price level is touched and not after the bar/candle is closed. For example, I would like to set the take profit order as soon as the MA20 is touched.
    #236968 quote
    Niklas87
    Participant
    New
    Just use: “set plimit X” for a profit limit order. One thing to keep in mind tho, if you trade in IG ther are minimum stopp loss and trailing stopp so if you use “Low” and its to close to tradeprice the order will be rejected.
    davidator and Iván González thanked this post
    #236970 quote
    davidator
    Participant
    Junior
    Hi Niklas, thanks for your answer. IG minimum distance for the stop order isn’t a problem so far since I’m only using probacktest  to test strategies, I do not use automatic trading now. So, can you make an example on how to use “set plimit X” with an indicator, as an example the MA20? Also, if possible I’d like to experiment with targets which are multiples of the stop loss. For a long position that would be, assuming I enter on the close of the bar, CLOSE-LOW.  How the formula would be written in the code?
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Stop loss below/above the open position candle


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
davidator @davidator Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by davidator
1 year, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/31/2024
Status: Active
Attachments: No files
Logo Logo
Loading...