Moving Stop Loss once based on condition

Forums ProRealTime English forum ProOrder support Moving Stop Loss once based on condition

Viewing 5 posts - 1 through 5 (of 5 total)
  • #238717

    Hello, first post on this forum so hopefully I have not misinterpreted any rules. I have for many hours tried to create a moving stop loss that should only move once and based on a condition. But with all my tries it mostly just exit price at the opening of the candle rather than moving the stop loss. What I want is: if a fractal low is created after the opening of my trade, I want to trail my stoploss to that low, thus tightening the Stoploss. But I only want it to be done once.

     

    when running this it just closes at the open of the next candle when the signal is given instead of moving the stop loss to the lowest low (-5 pips) of the last five candles. the code is essentially just as this snippet:

     

    Anyone who has any advice would be greatly appreciated.
    Regards
    Jonathan

    #238732

    Try this one:

     

    2 users thanked author for this post.
    #238735

    thanks roberto, its unfortunately reacting in the same manner and closes upon the opening of the next candle

    i have added a printscreen below from my PRT just visually describing the issue if its any help

    if you have any other suggestions i would appreciate it very much

    #238750

    Roberto’s code seems correct. Maybe you should check CP1, CB1H1 or moveSL.
    i suggest work with graphonprice and graph in order to check exactly what is going on.
    Here you have an example of code with StopLoss changing to breakeven.

    1 user thanked author for this post.
    #238826

    Hey Ivan

    Thanks for the advice of graphing the indicators, I have found a solution, I am not entirely sure of the logic of the solution though haha

    The CB1H indicator only returns a value in one candle(green spikes in the picture added), which seems to affect the stoploss function to return a value (just speculating). If you have any insight for me to learn, that would be greatly appreciated

    //Also Robertos code does also work I when the signal occurs I noticed, but only when I write it a flat value in the stoploss, like this:

     

    IF Not OnMarket THEN
    SetStop = 1
    ENDIF

    IF longonmarket and SetStop then
    if BARINDEX-TRADEINDEX(1)>1 and CB1H and close > entry1 THEN
    set stop loss 30
    SetStop = 0
    endif
    endif

    //cannot manage to write this part as code here for some reason, sorry haha

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

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