Hard stop using a candle

Forums ProRealTime English forum ProOrder support Hard stop using a candle

  • This topic has 15 replies, 4 voices, and was last updated 7 years ago by avatarEric.
Viewing 15 posts - 1 through 15 (of 16 total)
  • #22654

    Hi

    The attached code works fine except for the “stop” which closes losing trades at the end of the day using  the Flatafter condition. My intention is to place the stop 1.1 points above the high of the 8:00 am (GMT) candle. Can anyone suggest how this could be gone please? The “SellPrice” sets itself per the low of the 8:00 am candle -1.1 points correctly.

    I can graph c1 which is showing the correct value but cannot seem to work out how to link the value to the “stop”.

    Can anyone help please?

     

    #22693

     

    I’ve tried but I can’t get it to reference that first bar either :-/

    I was using this  link below.

    Hopefully Nicholas can give you some idea

    #22715

    Hi Big Hug,

    Thanks for the info. about range commands and I agree its not the solution to the problem of linking the stop to a candle.

    Nikolas may be able to help if he picks up on the problem ,if not, it seems a major restriction in the software.

    I’m sure you can use “intradayindex” to identify a particular candle although the write up if not particularly clear as the index number will be continually moving so doesn’t help.

    #22716

    I’ll have another look over the w/e possibly.

    I’m sure it can be done.

    I need a clear head !

    #22717

    Thanks for the help. I thought looking at the problem am might help but obviously not.

    #22746

    That’s because when using the “stop loss” command, you need to give your code your desired stop “distance” = the number of points between c1 and your entry, not c1 itself which is the stop “level”.

    So with “stop loss c1”  (c1 = high[0]+1.1*pointsize level), you have pushed your stop far away at “entry + c1” level (so roughly twice current price level), that’s why it’s never touched within the day, hence the defparam flatafter bringing an end to it.

    Changing your line “stop loss c1” into “stop loss (c1 – tradeprice)” should result in triggering the stop at the c1 level.

    #22765

    Thank you Noobywan for your assistance easy when you know how.

    #22766

    Great Noobywan – thank you . Now I have to understand it 🙂

     

    #22784

    I don’t agree with your line 12 “c1=C1-tradeprice”, there are two ways to do it:

    • either you can keep :

      and then the syntax for the stop would be :

    • or you can say :

      and then you can keep :

      because you have made of c1 a distance rather than a level

    Should also work with “ploss” by the way… (p for points, just like first p of pprofit)

     

    1 user thanked author for this post.
    #22830

    Hi

    I’ve substituted your second formula on my original EA and graphed C1 and the value is not what I would expect

    reference information using the DAX for 25th January:-

    8:00 High 11691.3 Low 11676.5 candle length 14.8.

    Trade was actioned on the 8:05 candle (correctly) at 11675.4.

    The stop should have been = 11691.3+1.1-11675.4 =17.0 but when I graphed the stop it came out as 179.4.

    On test this again closed out at 163000.

    I thought it might be because we need to reset C1 at the start of day but don’t think its that.

    #22835

    Do you have screen capture? If I look at the IG cfd data I don’t have these values for these times, so I can’t reproduce your backtest. I assume either you’re looking at something else than my ig dax cfd (futures?) or maybe not the 25/01? Also important, what timeframe? 5 minutes? 1 minute? or (x) minutes? Specifying timeframe might be important here because if using the “easy way” tradeprice to recover your entry, this calls the price level of the latest trade, that latest trade could be either the last trade exit if not entered a new trade yet, or the latest entry, and depending on your timeframe the code might have been setting the stop with the price level of the previous exit instead of current entry (it all depends on in what order events happen and lines are read). For example first sugestion to keep c1 like you first did but make “set stop loss c1-tradeprice” would more likely take into account the latest entry rather than last sell, whilst using the other suggestion of taking tradeprice into account when defining c1 inside that if statement with time restriction could be fine for capturing the high, but not for the tradeprice depending on what timeframe is used.

    #22840

    maybe not the best solution (and fastest) but when i do something like this i try to make an indicator first and then use it in the code by call

    indicatorlow = ? -1.1

     

    botten = CALL indicatorlow

    and the stoploss

    Sell at botten stop

     

    but if you can write it without using call its probably better

     

    #22842

    Hi

    I used the IG spreadbet account and the values and timeframe are correct. The reason I took option 2 of your suggestions was because I was going to add “buys” with an “if” statement to identify whether the trade is a “buy” or “Sell” that way I can use one EA instead of two i.e. with 2 definitions of C1.

    In fact, tradeprice may be problem with buy and sell in the same EA so may need to keep them separate.

    I’ll go and have a further think but thanks for your interest and input.

     

    #22843

    Thanks for the input Eric. Because I’m trying to identify the low/high  of a specific  5 minute candle at 8:00 a.m. UK time not sure how to pinpoint in an indicator the price at 8:00. I can get the code to work if I allow the low/high value to change with each candle.

    #22844

    Hi all

    Cracked it just set c1 = Range[0]+2.2

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

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