Fixing the value of the close of the current bar across subsequent bars

Forums ProRealTime English forum ProOrder support Fixing the value of the close of the current bar across subsequent bars

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

    I am not an experienced programmer – and indeed have difficulty in defining the problem, but this is what I

    am currently having problems with:

    I am trying to define a reference price level (RPL), and different things happen above and below this price point

    Let us assume the RPL is the close of the current bar

    This RPL is valid for all future bars UNTIL certain conditions are satisfied, at which point it shifts up or down

     

    My difficulty is that because it references “close”, whose value can change every bar going forward, how do

    I fix it at the closing price of that particular bar, and ensure that it doesn’t change in every subsequent bar to the

    closing price of the subsequent bar? I’m sure this is trivial but I’m far below trivial!

     

    I would appreciate any help whatsoever

    #8570

    Hello merc1203,

    I don’t know what your code is all about, but this kind of conditional statement would solve your problem:

    With this, if “certain conditions” are not met, your RPL value still have the same value than the previous bar.

     

    #8574

    Very good Matthew – thanks for your help and prompness …

    #8581

    I have just tried to ProBacktest a simple model but I get an error message …

    Syntax error. line 46 character 1

    However, Line 46 is empty, Line 45 is …

    set target Pprofit profitEntry

    Is there a protocol for ending a piece of code?

     

    Many thanks

    #8590

    Without the whole code is quiet difficult to know what cause your syntax error 🙂

    But it feels like you have forget an “ENDIF” somewhere maybe?

    #8626

    Good morning,

    The code below doesn’t seem to be doing what I want it to do

    The idea is that if the current bar closes ABOVE the lowest of the last 3 bars’ highs AND WE ARE CURRENTLY IN SELL MODE then reset RPL to equal the closing price and switch to BUY MODE.

    As soon as the current bar closes BELOW the highest of the last 3 bars’ lows AND WE ARE CURRENTLY IN BUY MODE then reset RPL to equal the closing price and switch to SELL MODE

    Don’t quite know what the code is doing but it ain’t doing that!

    Any help would be very much appreciated – many thanks in anticipation

     

     

    #8629

    You were almost right.

    With this kind of statement:

    can’t return anything since you are making a conditional instruction that never match something.

    I think this code would make what you want to do here:

     

     

    #8639

    Could someone please put me out of my misery – the code below FAILS TO TRADE AT ALL!

    I have tried substituting each individual part to try to isolate the issue but to no avail …

    The “buy side” works fine

    Many thanks in anticipation …

     

    riskEntry = 40.0
    profitEntry = 100.0
    tick = 2
    Scale = 10.0
    NofT = 5

    once BMode = 0
    once SMode = 0
    once Mode = 0

    nbH = lowest[30](high)
    nbL = highest[30](low)

    CondB = (close > nbH)
    CondS = (close < nbL)
    if CondS and Mode <> SMode then
    RPL = close
    Mode = SMode
    elsif CondB and Mode <> BMode then
    RPL = close
    Mode = BMode
    else
    RPL = RPL[1]
    Mode = Mode[1]
    endif
    CondDD = close[1]<open[1] and close[0]<open[0] and close[1]<RPL and close[0]<RPL

    CondNofT = abs(countofposition) < NofT

    CondScale = abs(close – TradePrice(1)) > Scale
    if close<RPL and CondDD and CondNofT and CondScale THEN
    SellShort 1.25 PerPoint at close – tick stop
    endif

    set stop Ploss riskEntry
    set target Pprofit profitEntry

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