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
- This topic has 7 replies, 2 voices, and was last updated 8 years ago by merc1203.
-
-
06/01/2016 at 10:44 AM #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
06/01/2016 at 11:17 AM #8570Hello merc1203,
I don’t know what your code is all about, but this kind of conditional statement would solve your problem:
12345if certainconditions=1 thenRPL = closeelseRPL = RPL[1]endifWith this, if “certain conditions” are not met, your RPL value still have the same value than the previous bar.
06/01/2016 at 12:25 PM #857406/01/2016 at 1:16 PM #8581I 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
06/01/2016 at 3:03 PM #859006/02/2016 at 8:07 AM #8626Good 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
123456789101112131415161718once BMode = 0once SMode = 0once Mode = 0nbH = lowest[3](high)nbL = highest[3](low)CondB = (close > nbH)CondS = (close < nbL)if CondB and Mode <> BMode thenRPL = close and Mode = BModeif CondS and Mode <> SMode thenRPL = close and Mode = SModeelseRPL = RPL[1]Mode = Mode[1]endifendif06/02/2016 at 10:27 AM #8629You were almost right.
With this kind of statement:
1RPL <span class="token operator">=</span> <span class="token keyword">close</span> <span class="token keyword">and</span> Mode <span class="token operator">=</span> BModecan’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:
1234567891011121314151617181920once BMode = 0once SMode = 0once Mode = 0nbH = lowest[3](high)nbL = highest[3](low)CondB = (close > nbH)CondS = (close < nbL)if CondB and Mode <> BMode thenRPL = closeMode = BModeelsif CondS and Mode <> SMode thenRPL = closeMode = SModeelseRPL = RPL[1]Mode = Mode[1]endif06/02/2016 at 1:02 PM #8639Could 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 = 5once BMode = 0
once SMode = 0
once Mode = 0nbH = 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]<RPLCondNofT = 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
endifset stop Ploss riskEntry
set target Pprofit profitEntry -
AuthorPosts
Find exclusive trading pro-tools on