Dynamic StopLoss following an indicator

Dynamic StopLoss following an indicator

Hi everybody!

In this example we are following a position with Parabolic SAR indicator.

Each new candle will be updating STOPLOSS to the new Parabolic SAR position.


Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

New! PRC is also now on YouTube, subscribe to our channel for exclusive content and tutorials

  1. gm74 • 04/28/2016 #

    This has changed my life. Thank you!!!!!

  2. gm74 • 04/28/2016 #

    I might have spoken too soon. Could you possibly shed some light? I am wanting to set dynamic stop losses based on my profit. In effect a highly customisable trailing stop.Take the following for example. if the trade is 250 points in profit, I would like to set a stop loss at 100 points profit. Look at the following example for if I were in a short trade:
    //Current trade points in profit profits=positionperf*tradeprice

    if shortonmarket then
    if profits>250 then
    exitshort at tradeprice-100 stop
    endifif profits>400 thenexitshort at tradeprice-350endifendif
    However, this does not give me the desired result. Do I also have to open the short in the same way? As I am currently opening the short as follows: 
    sellshort at market
    I do not wish to use trailing stops, as I want the freedom to adjust the stop trailing steps at various intervals. Ie, if 250 points in profit, exit if drop to 100 BUT if 400 points in profit, exit if drop to 350.
    Any help would be appreciated. 

  3. Madrosat • 04/28/2016 #

    Quelqu’un pourrait il répondre à cette question restée sans suite???

  4. denmar • 04/28/2016 #


    Could somebody please enlighten me how this code operates. I wish to use the code (is this an indicator?) as a mechanism to automatically adjust my stop once in a trade. Can one invoke this once one has opened a position manually? If so, how is this done. Is it simply a matter of attaching the “indicator” [My experience is limited to Metatrader where there was a difference between indicator and things called scripts] This being the case could I split the code and have one for long – including lines 19 -27 and one for short – including lines 29-37.

    Thank you

  5. denmar • 04/28/2016 #

    Testing email notification to Denmar

Register or


avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
mlouys Bjr, j ai lu effectivement que le système était long only, mais je crois qu on peut aussi l ...
bertrandpinoy bonsoir Nicolas est il possible de voir cet indicateur évoluer dans un TF bas pour une aide ...
max-trading Bonjour, C'est bizarre, quand j'installe cet indicateur mon graphique des prix se resserr...
Nicolas Dans les paramètres du prix, il faut choisir la mise à l'échelle basée sur le prix uniquement.
Nick FX Junkie Good evening all, Is there any way this indicator can be transferred into a strategy code?
Jan Wind Thanks for sharing ! The Gain/Loss ratio is a bit low, 1,16, hardly offset the risks take...
drive whats the period ?
Nicolas Use the color variables R and G to test if the trend is bullish (R=0) or bearish (R>0).
s00071609 Where can i find the syntax to test the colour of the line, I am calling the indicator value...
Nicolas You should open a new topic to discuss about the strategy and its coding.
bertrandpinoy hello juanj, can you send the code repair by your good care to try scalping please?
rama what is the buy condition or sell condition for this can you suggest a code k1=1 buy and k1...
rama I would like to know at point 1 an alert or binary indicator so that I can place order
nfulcher Please could someone explain how the following code is calculated:- iDI = TEMA[3](DI[DI2]...
oakenstream Jan, I find sometimes that the priceexit variable is never set. It seems to happen when the ...
Matt66612 I do not understand the first time I launch the backtest I got the same result as you. but ...
Marcel The line is just a moving average line. The indicator reacts on the Parabolic SAR dots.
Mattzi I dont get the dots! What am i doing wrong? :)
Mattzi Ignore this comment ;)
joobeng Sorry, I solved the problem. I have add the CBL indicator using the spanner icon on the pric...
Nicolas Adjust the price settings for the Y Axis to use the price only.
XXXXVII Hello Your indicator is interesting. However, I can't see the orange line. Do you have ...
Nicolas Should not if adxlen variable is superior to 0.
AussieTrader Nicolas, Can you explain the numerator logic - e.g. Line 35 is (sTR[1] - sTR[1]) which wo...
Nicolas You are right, this is useless. Since I converted it from another programming language, I a...
Nicolas Definition of CustomClose: https://www.prorealcode.com/documentation/customclose/ [2] means...
Bard Just wondered Nicolas, say you had set DEFPARAM CumulateOrders = True, is there anyway for t...
Bard Sorry pls ignore last image, try this - it actually has the Dev Stop indicator! https://www...
juanj DevLongC and DevShortC keeps track of the number of bars that the DevStops are either long o...
juanj C = Count
Bard Thanks for the explanation. I couldn't get it to load anyway.
Caribeengeek Bonjour j’avais vu que vous proposiez d’écrire des codes pour ceux qui s’y connaisse pas Mai...
Caribeengeek Les devises unité
Nicolas Merci d'utiliser le forum pour les demandes de programmation personnalisée
jebus89 Big thanks for sharing this :) Seems to work as expected, good stuff.
GraHal Please forgive the daft question, but why is 3-bars-trailing-stop-williams-3.itf included a...
Kris75 Hi, Seems great but what would be the code for a stock ? Thanks, Chirs
oakenstream Paul, what is the best way in your opinion to know if I have over optimized?
Mr_Balagan Bonjour, j'ai quelques questions concernant cette combinaison d'indicateurs qui à l'air inté...
larouedegann STE : Fonction statistique "erreur standard" de séries temporelles de N périodes pour le pri...
Mr_Balagan Merci pour ces informations précieuses larouedegann. J'y vois plus clair. Encore joli boulot
Paul Good work ! I was looking for way to maximise profits and this serves it's purpose well !
gabri Thanks!!
Kris75 Hi Gabri I launched a very simple strategy based on the 3 bars trailing stop that you cre...
3 years ago
Loop Hi All! Would it be possible to have the same indicator with the MACD calculated with the DE...
Nicolas Why not, but do you think it would make such a noticeable difference?
Loop Good question Nicolas! That's why I was curious to check it! MACD based on DEMA is usually m...
Nicolas Rien, il faut l'appliquer sur la charte. Soit le mettre sur le graphique du prix, à l'aide d...
signorini Merci pour votre réponse. Je l'applique sur la charte, j'utilise la petite clé pour effacer ...
signorini Je vous remercie, Nicolas. C'est fixé. Très bon week-end.