Stop loss off of high – attempt and resultant weird code?

Forums ProRealTime English forum ProOrder support Stop loss off of high – attempt and resultant weird code?

Viewing 6 posts - 1 through 6 (of 6 total)
  • #88736

    Hi all,

    I have been trying to make a stop loss to recover a nominal dollar amount – to stop/exit a position if there is a >=$50k drawdown – but only if the position is > $200k profitable – and not have this mechanism activate for dollar profit amounts less than $200k.

    Sounds great already.

    An intra-bar stop would be great, though I have heard that this may not be possible?

    I wrote this code below – to try and do what I wanted above.

    Have attached 2 pictures below – “before” and “after” the code above was implemented.

    So it seems that the code is not working intra-bar – but it sells at the START of the bar that I thought it would have sold at somewhere part way through when it would have got down to its drawdown stop target.

    I don’t quite know how it works, but it seems to go back in time/doesn’t work. Be great if it did work…

    Anyways – just looking for a little help to do this dollar-target based stop loss, which only kicks in after a certain profit size, to sell after a certain quantity of drawdown. Intra-bar great, end of bar if nothing else.

    Thanks,

    Finning.

    #88860
    #88957

    You should GRAPH the value you take to put your pending orders, otherwise you’ll never understand why your orders are not exited correctly (or the way you think they should):

    When something go wrong with a code, try first to debug each variable of the program.

    #89011

    Hi Nicolas,

    yes, you were right. After reading https://www.prorealcode.com/topic/problem-with-stoploss-function/   , the function that you told me to check was a level – and not a distance – which would have caused a problem – even though the function seemed to work.

    A dollar based stop loss is a great way to think about things – however it might be simpler if I just stick to points – and it looks like https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/    does a great job. I’ll probably just use that code it seems to work well.

    I am still perplexed with the funny close outs on my initial code above. I guess I just have to not expect such results in actual trading.

    Just another question – if I did choose to try and work in dollars – and kept the function

    which graphs to be the same as your function in post #21529

    can I then use a bank of multiple (2+) sequential set stop $trailing codes?

    for example:

    The reason I’m asking is that when I seem to use these multiple stops, I get an error claiming the loss of tick by tick data – seen in the attached picture file – an error that I haven’t seen before.

    The start date of the backtest was the end of 2014 – well after the 2010 introduction of pip data.

    Many thanks,

    Finning.

     

    #89209

    This error message is about the fact that there are no ticks data at the date you want your backtest to be made/started. No ticks data means not accurate backtest, especially when using a trailing stop (exit based on prices met intra-bar).

    #89269

    I sometimes get this error during tick by tick back tests even though the start date is set correctly. If you keep trying new start dates then eventually you get the back test to run without error. I think there must be some corruption in the tick by tick data that some strategies hit on and others don’t. I’ve tried to work out what date this is but repeatedly back testing with new start dates is a very long process! I seem to recall that last time I had to set a start date in 2012 despite the fact that tick by tick data starts in 2010.

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

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