Move Stop Loss to open of previous candle

Forums ProRealTime English forum ProOrder support Move Stop Loss to open of previous candle

Viewing 2 posts - 1 through 2 (of 2 total)
  • #188407

    Hi,

    I have a code that runs on a 4h chart. If previous candle is green, it enters a long. If current candle closes green then it enters another long. This carries on until a candle closes red which then closes all trades.

    It does the same for red candles, just with shorts.

    I’m trying to make add a stop loss that would be equal to the previous candle’s open (plus a small buffer), and every time a new position is added (if there are consecutive colored candles) then I want ALL stop losses to move to the previous candle’s open.

    Could anyone possibly have a look at my code below and point out where I’m going wrong with my Stop Loss instructions.

    Thank you in advance!

    Kind regards,

    Anton

     

    #188419

    It can’t work mainly because you combine a price & pips (CLOSE + N), on DOW JONES that expression will be roughly 34500 + 150, then SET STOP pLOSS will set your Stop Loss as far as 34650 pips! It can be acceoted in backtesting, while on a real account (maybe on a demo account, as well) the order would be rejected because TOO FAR from the current price and the strategy quit with an error.

    Additionally, always use the keyword PIPSIZE to convert pip values to a price scale so you don’t make some errors.

    Moreover, LOSS (and PROFIT, as well, be both of them preceded by either nothing, p,% or $) require a difference between prices, NOT a price). You can use SET STOP LOSS abs(close – low[1]) or SET STOP LOSS 150*PipSize, or SET STOP pLOSS abs(close – low[1])/PipSize or SET STOP pLOSS 150.

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

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