Stop Loss Problem

Forums ProRealTime English forum ProOrder support Stop Loss Problem

Tagged: , , ,

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

    Good morning,

    I have recently put Nicolas’s clever stop loss code :

    SET STOP LOSS abs(close – (lowest[3](low) * pipsize))

    into my code and it works beautifully.

    My problem is that when in a trade, I want to limit the maximum $ loss of any single trade to $100 and I don’t immediately see how to do this whilst retaining the recent swing high/low stop loss code above.

    I checked the forum and found reference to the following post:

    https://www.prorealcode.com/blog/learning/max-profit-loss-day-trading-strategy/

    BUT I can’t get it to work with the swing high/low code.  It’s like the system just ignores my ‘max loss’ code resulting in many losses far in excess of $100 on the backtest.

    See below for what I currently have (without my buy/sell conditions which just add clutter).  Any help much appreciated.

    Regards

    Mark

    #141046

    Actually your line SET STOP LOSS abs(close – (lowest[3](low) * pipsize)) is wrong, LOSS does not require pips, but a difference between prices.

    You could use PLOSS, instead, but in this case it should be “/ pipsize” and the closing parentheses are not in the correct place. It should be one of the following:

    But in your case you can easily use:

     

    1 user thanked author for this post.
    #141072

    @mizatt

    Where did you find the code snippet you talked about? Would be good to change it as it is not correct 🙂 If it is my fault, please accept my apologize! 😉

    #141110

    Hi Roberto,

    Thanks for clarifying that the ‘pipsize’ term can simply be removed.

    I know how to use the $LOSS  function on its own but do you have any idea how to COMBINE the

    abs(closelowest[3](low))    AND   $LOSS (max $100)

    Depending on the entry candle of my trade, if the trade moves against me then the loss can be anywhere from $50-$150 (typically).

    I would like the abs(closelowest[3](low)) code to be used as my primary stop loss wherever possible EXCEPT when the loss becomes a value >$100 which is when my secondary $LOSS code executes to get me out.

    Is this easily possible to do ?

    Regards

    Mark

    #141111

    @Nicolas

    It looks like I found it here:

    https://www.prorealcode.com/topic/stop-loss-at-last-swing-low/

    but it looks like (with hindsight) it was actually a post that Roberto was moderating.

    Apologies for the mix up.

    Regards

    Mark

    #141122

    It was NOT an error, you simply copied it wrong!

     

    #141130

    It was not copied wrong Roberto, did you check the link with your post?

    I think you’re missing the point… your code works perfectly for finding the swing low/high!  (either with the word ‘pipsize’ included or without it).

    My remaining issue however is trying to find a solution for combining the swing high/low code and a max $loss as I explained above.  Can anyone help with this issue?

     

     

     

    #141132

    @Nicolas

    As my coding issue remains unaddressed, can I pay you via Paypal for your expertise in getting this sorted quickly?

    If so, please send me an invoice or contact me at XXXXXXXXXX

    Many thanks

    Mark

    #141133

    One of the rules you should have read clearly states:

    • Do not include personal informationsuch as email addresses or telephone numbers in your posts.

    Abide by it, please.

    I removed your email address.

     

    #141134

    As for your code the line is correct, but your text is wrong, that’s what I remarked.

    You can calculate the value by using both PIPSIZE and PIPVALUE (not tested):

     

    1 user thanked author for this post.
    #141135

    Ok, many thanks for helping with this code.  Now I think I see it was just a misunderstanding.

    I’ll give it a try and fingers crossed.

    Much appreciated Roberto.

     

    #141136

    As a moderator I am supposed not to help, this can be done by anyone on this forum (myself included), but to remark what’s not correct in a post pointing out what the correct form is.

    You, as a member of this community, are supposed to abide by the rules.

    Thank you 🙂

     

    #141137

    It works Roberto!  Great work!

    Thanks again and sorry about displaying personal email address.  Will remember for future.

    Mark

    #141138

    I’m sorry if my requests have created a bit of tension between us.  Obviously my goal is simply to get my code strategy sorted and if I can call upon either you or Nicolas’s expertise then it is of great help.

    I am happy to pay for your services as I realize it takes a lot of effort and skill to acquire this knowledge which you give back freely to the community.  That is greatly appreciated and I’m sure I speak for all newbies when I say that.

    Regards

    Mark

     

     

    2 users thanked author for this post.
    #141139

    Hi Roberto,

    I think I’m nearly there with the code BUT came across a perplexing problem a bit later.

    When I apply the stop loss code on the DJI index (Wall St) in IG, it works perfectly as per your suggestion when applied to a PositionSize of £1/point.

    When I increase PositionSize to 2 (or greater), the system no longer exits trades in the correct place.

     

    P1 in pic below is the correct exit (the last swing high)

    P2 in pic below is where the exit occurs when PositionSize is increased from ‘1’ to ‘2’

    Note that when I increased the PositionSize to ‘2’, I also increased the stop loss and profit target e.g.

    Set Stop $loss min(200,S1)    //as opposed to Set Stop $loss min(100,S1)
    Set target $profit 260     //as opposed to Set target $profit 130

    but it still exits incorrectly.  Any idea what is going wrong when the PositionSize is increased?

    Regards

    Mark

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