once function combined with a stop

Forums ProRealTime English forum ProOrder support once function combined with a stop

Viewing 13 posts - 1 through 13 (of 13 total)
  • #163141

    Hi there,

    Having trouble to understand why below code doesn’t behave like I would have it:

    Problem with above is that the stop doesn’t seem to kick in as soon as c1 and c11 are satisfied.

    C11 needs to be read only once as the stop should remain active even if c11 isn’t valid anymore. The stop needs to remain active once it has kicked in..

    Thanks for getting back to me,

    cheers.

    #163147

    ONCE means that whatever follows on the same line is evaluated only when the strategy is first executed, not next bars.

    At that time TRADEINDEX is 0.

    Next, you assign c11 a logical value of a price compared to another logical value.

    c11 will ALWAYS be false if used on most currency pairs and will ALWAYS be false with indices. That’s why the SELL pending order can’t be placed when you want to.

    What do you want to achieve with the first two lines?

     

     

    #163195

    Well, the problem I’m having right now is that the STOP that I want to put in place seems to come and go without the “assumed wrong idea of of the ONCE function above”. That’s why I thought I’d give the “assumed wrong idea above” a try.

    The idea behind the first two lines is the following:

    The first condition is there because I have different STOP levels in mind. See it as an inactivity, if TARGET PRICE is not reached within the next 45 bars then another type of STOP sets in.

    With the second (wrong) condition I wanted to prevent that the stop comes and go (which is the case without the c11 idea). I didn’t put the whole code on display in my first post but you can assume that, because of various reasons, the stop comes and goes.

    See the condition as the TRAILINGSTART part. As soon as the POSITIONPRICE + TARGET PROFIT is reached, I want the stop to kick in.

    So the second condition only needs to be satisfied once and shouldn’t be recalculated bar after bar.

    My mistake here is that I thought that the ONCE function could be used for trading strategies as well and not only for indicators (or maybe it can be but from the explanation that you gave me, I understand it can’t be used in that way?)

    #163197

    c1 should be written as:

    to make sure it’s not always evaluated.

    I still can’t understand what your goal is with:

    let’s replace it the real values (for both DAX and EUR/GBP):

     

    #163198

    Ow sorry, I meant TRADEPRICE instead of TRADEINDEX, my bad…

    I don’t know if you can understand what I mean now?

    #163209

    Your code,line 7, will only be executed when c11 is TRUE, which can be at some bar,but cannot be the following bar.

    When it’s true for the first time, you need to keep placing the stoip order, even later when the porice drops down (that’s what it’s made for).

    So you should use a flag (a variable, no matter the name, that is ised to signal something). This flag should be rest to 0 when not on market, then set to 1 whenever c11 is true.

    Then you can place the stop order while this flag os true:

     

    1 user thanked author for this post.
    #163229

    I don’t really understand the lines 5 to 7 (what is the trigger in your example that changes flag into = 1?); shouldn’t it be like below?

    But I get the overall idea of the flag!

    I’ll give it a try and let you know if I still got any questions 🙂

    #163230

    Yes, well spotted.

    I forgot to embed that within IF…ENDIF.

    #163469

    Works great!

    I got another (very silly) question though and I don’t know if there’s already a post covering this but here it goes…

    When is the cost of a guaranteed stop loss triggered? I would assume every time you use the stop function?

    Or is it only triggered when using the below kind of command:

    and not when using this kind of command

    ?

    #163475

    This is something I cannot answer. I would guess when a STOP order yields a loss, not a profit, but I am not aware of it.

    I suggest that you post this question at https://www.prorealcode.com/forum/prorealtime-english-forum/prorealtime-support/, since it’s a PRT monitored forum and someone will surely reply asap.

     

    #163476

    Not so silly after all then (I thought it would be)!

    I’ll do that and keep you updated with the publication of a link in this topic then!

    1 user thanked author for this post.
    #163479

    IG only deduct their guaranteed stops fee when a stop is hit so if you have an order on a market attached to a position to close it at a worse price than the entry price and that order is hit you will get charged the fee.

    This is only my assumption as I don’t use guaranteed stops.

    #163498
Viewing 13 posts - 1 through 13 (of 13 total)

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