Hard coded Stop Loss becoming Trailing Stop Loss

Forums ProRealTime English forum ProOrder support Hard coded Stop Loss becoming Trailing Stop Loss

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

    Hello,

    I’ve been incorporating Nicholas’ hard coded stop loss into my systems and like the setup. I’ve noticed after much testing that when the price upon entry immediately moves into a favorable direction, then the trailing stop loss works like magic. But if the price were to instead immediately go into an unfavorable direction, then the stop loss doesn’t kick in and in my tests I rake up huge losses. Would it be possible to add a starting stop loss upon entry, and then trail from there? Using EURUSD as an example:

    If I enter Long at 1.0600 then the first stop loss would immediately be placed at 1.0580 (20 pips below entry). It’s held here until either the price drops to the stop loss thus the system exits the position, or if the price were to move in a favorable direction to say 1.0620 (20 pips above entry), the stop loss would become trailing and step up to 1.0610.

    As you can see the idea is near identical to Nicholas’ stop loss, with only the added function of the initial stop loss before it becomes trailing. I really like the idea of the hard coded stop loss as I find the built in SET STOP pTRAILING to be a little fickle at times, but I can’t figure out how to resolve the above example into code.

    Can anyone please help me?

    #28688

    Hi – If you add the stop loss at the very end of the code it will work as you want it to ie

    ……

    So if your position goes straight into a loss, given the trailing code has not yet been triggered, the hard stop loss will kick in. I’ve tested this in live and it works fine. In your example, once your position moves into 20pts profit the trailing code (if your trailing start is set to 20 as well) will then take over and replace with a new stop.

    1 user thanked author for this post.
    #28707

    @manel Thank you for a swift reply. I’ve been avoiding any built-in stop losses due to their current issues. I will try your suggestion and see what happens in a demo run, will report tomorrow!

    #28801

    I tested out the built in stop loss in conjunction with Nicholas’ Trailing Stop Loss and it appears to work. I’m going to continue testing and use it to improve my code. Thanks!

    #99156

    Hi I’ve just tried to add this into the PRT code, so normal trailing stop is hard coded in through the PRT builder system, and I’ve just literally added this into the end of the code, but it won’t let me save it saying it’s invalid – So whatever we do you can’t have a fixed stop initially which then becomes a trialing like you say..Any reason why..?

    #99158

    I’ve just tried to add this into the PRT code

    If we could see your code then likely somebody can help you?

    Otherwise we  are kinda guessing at what / how you have done?

    EDIT / PS

    You probably only need to show the last change you made (use the blue Insert PRT Code button … top right on the toolbar).

    1 user thanked author for this post.
    #99371

    Hi Grahal,

    I’ve got this far, can you advise on the next step..?

    I’ve coded the below as far as I can get but seem to be just missing one minor detail! I’m Still working on a way to combine a trailing stop with a trailing step that becomes a fixed stop – i.e Trade is a buy open with a 10pt stop, if it moves 2 up, your stop is now 8, if it moves another 2, it’s now 6 but when it gets to 10, so break even on a 1-1, it becomes fixed. Currently I only get a trailing to stop at breakeven, so still risking the full 10.

    I notice that with this although I’m getting the result of the trailing stop at breakeven which is great, the trailing stop still seems to be live with a step as the deal closes sometimes later at 25 or 35 or 45 etc…great problem to have but not what I want as I lose on bigger moves.

    Adding a trailing stop after the first one becomes fixed would be the next part, so if it moves another 30 pts you bank another 10 for example. I’m thinking this is a simple code tweak..? Code below, perhaps you can help me..?

    #99389

    If  you Graph breakevenlevel you will see that it never changes from 0 / zero … does that help you to find the Issue with your code?

    Breaklevenlevel is not defined in the code.

    #99394

    Breaklevenlevel is not a reserved word / term in the PRT coding language … maybe you thought it was??

    #99397

    For the record … Luce’s code produces a nice equity curve as shown with spread = 4, StartTime = 090000 and TS = 10.

    #99427

    Grahal, on paper yes first I had the same backtest as you, and I thought, waoou nice for a so simple code, then I realized that he is using the ptrailing function… Here the same code with a true breakeven function, and a true trailing function. Backtests are less inspiring…

     

     

     

     

     

    #99428

    then I realized that he is using the ptrailing function

    So does the PRT built in ptrailing  function not work in Realtime as it does in Backtest (with tick mode etc).

    #99430

    never really tested myself but I think remembering that indeed backtests were wrong with ptrailing. Maybe Nicolas can confirm that. In which case this ptrailing function should be deleted from the catalogue of available function by the way.

    What is dubious is that 80% of the deal wereclose within the same bar, and 20% rest only after one bar…

    #99434

    What is dubious is that 80% of the deal wereclose within the same bar, and 20% rest only after one bar…

    I was backtesting on a 1 hour bar and with ptrailing = 10 I expected above on the DJI as either the entry took off into gains or failed quickly at a loss of 10 ish points.

    Even if the ptrailing followed price upward then in no time at all there would be a retrace  of > 10 points and so entry and exit within 1 bar / 1 hour either at a small loss or a bigger (but still small) gain.

    #101013

    Hi Chaps – I wonder wether you can confirm something.

    All I want to do is to alter my code above so when you enter a position I have a security stop of 10 (which I’ve set in) and a trailing step stop which moves up in 2 steps, so let’s say trailing stop is 10 – What I want it to do is when you enter immediately if it moves 2 in your favour, your stop is now 8, if it moves another 2, it’s now 6 etc until you hit breakeven and then the step is 0 and the stop Becomes fixed. surely this can’t be a difficult thing to do – Does anyone please have any ideas here..!

    I have worked out that when you put the step to 0 then when your trailing stop hits your target (so 10) then it will stop trailing, so that works fine, what I can’t do if find a way for the stop to also work in steps until that point when it becomes fixed..!

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

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