Problem accessing data of current bar

Forums ProRealTime English forum ProBuilder support Problem accessing data of current bar

Viewing 8 posts - 1 through 8 (of 8 total)
  • #45743

    Hi,

    When defining “set stop loss x”, I can not access the data of the current bar. E.g. “range” becomes the range of the next bar and “range[1]” becomes the range of the previous bar.

    In contrary, when defining entry parameters I can access the data of the current bar.

    I am attaching the relevant code.

     

     

    Appreciate the feedback!

    #45757

    I’m not sure if I understand you correctly but PRT evaluates the code at the end of the candle. High, Close, Range and all this give you the values for the bar that just finished and not of the bar that is in the making.

    Not sure if this answered your question.

    #45764

    Thank you Despair for your input.

    Yes, PRT should evaluate the code at the end of the candle. As I have no problem with this for the rest of the code, I suspect that something within the “SET STOP LOSS X”- command might be causing the problems.

    I will add pictures describing a stop loss that has been triggered in pro backtest, consisting of:

    1. 0.2*MyATR                                        (OK. Evaluates the ATR of the signal candle, as it should do.)
    2. Range                                                   (NOT OK. Should evaluate the range of the signal candle, but evaluates the range of the next candle.)
    3. Range[1]                                              (OK. Evaluates the length of the bar previous to the signal candle bar, as it should do.)
    4. 0.2*MyATR+MyATR+Range         (NOT OK. This should give the full length of the stopp loss, evidently it does not.)

    I hope this explains the problem further.

    #45767

    Additional pictures.

    #45810

    What it all comes down to, is that I am unable to add the “range” of the signal candle to the definition of the “set stop loss x”.

    In addition, I tried to add “AverageTrueRange[1](close)” of the signal candle (which is basically the same as “range”) as the stop loss, with the same result as adding “range”. “AverageTrueRange[2](close)” has the same issue, but “AverageTrueRange[3](close)” and upwards (4, 5, 6… etc.) seems to take the data from the signal candle.

    Very strange indeed.

     

    #45813

    Try replacing your stop loss line with the following:

    Then i have a hard time following you when you write “next candle”. Next to what?

    BTW: Your post would belong in the proorder forum and not here in pro builder. This under forum is just for indicators.

    #45816

    Thanks for the feedback Despair, and thanks for the headsup. I mistook pro builder for pro order, sorry about that.

    It is a bad explanation by me, though it seems it is difficult to describe the problem.

    Thanks again and I will keep the thread updated if I come up with a solution.

     

    #45818

    I solved the problem.

    When initializing the pending stop order you have to include the stop loss in the IF-loop.

    Like this:

    ————————————————————————————————
    IF MA1h and Zone and (c1 or c2 or c3) THEN

    StopLoss=0.2*MyATR+Range+MyAtr
    BUY PositionSize CONTRACTS AT E1 STOP //Stop order valid 1 bar by default
    ENDIF


    And not like this:

    ———————————————————————————————-

    IF MA1h and Zone and (c1 or c2 or c3) THEN
    BUY PositionSize CONTRACTS AT E1 STOP //Stop order valid 1 bar by default
    ENDIF

    StopLoss=0.2*MyATR+Range+MyAtr


     

    Otherwise PRT will not interprete the stop loss right.

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

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