Sum open to close of candles in a defined time range?
Forums › ProRealTime English forum › ProBuilder support › Sum open to close of candles in a defined time range?
- This topic has 10 replies, 4 voices, and was last updated 4 years ago by Kovit.
-
-
07/14/2019 at 8:15 AM #102542
I’m writing a validation indicator because the system I’m working on works off the open of the current candle, not the evaluation of it on the next candle open.
I’m using a trading session of TIME > 080000 AND < TIME 100000 and would like to total the SUM of Close-Open for long trades and Open-Close for short i.e. how many points could be made trading the open to close in the trading session for the candles that meet the criteria. Easy to do for a single candle but I’m not sure how to total them for the trading session.
So if I was trading a 2 hour session on a 30 min timeframe and only two candles meet the criteria then I only want to sum those two. The timeframe might be an odd one like 36 mins.
Some candles might be long or short in the trading session but that’s worked out on the criteria, it’s the totalling I need help with.
Is this possible please?
Thanks, Rob
07/14/2019 at 9:24 AM #102543There you go:
123456789101112131415161718ONCE StartTime = 080000ONCE EndTime = 100000ONCE BullCount = 0ONCE BearCount = 0Bullish = close > openBearish = close < openIF Time = StartTime THENBullCount = 0BearCount = 0ENDIFIF time >= StartTime AND time <= EndTime THENIF Bullish THENBullCount = BullCount + (close - open)ENDIFIF Bearish THENBearCount = BearCount + (open - close)ENDIFENDIFafter EndTime both bullish and bearish candlesticks will have been tallied.
Next day the counting will be restarded at StartTime.
1 user thanked author for this post.
07/14/2019 at 9:34 AM #102544Link to above code added to here
1 user thanked author for this post.
07/14/2019 at 10:54 AM #102545There you go:
123456789101112131415161718ONCE StartTime = 080000ONCE EndTime = 100000ONCE BullCount = 0ONCE BearCount = 0Bullish = close > openBearish = close < openIF Time = StartTime THENBullCount= 0BearCount= 0ENDIFIF time >= StartTime AND time <= EndTime THENIF Bullish THENBullCount= BullCount + (close – open)ENDIFIF Bearish THENBearCount= BearCount + (open – close)ENDIFENDIFafter EndTime both bullish and bearish candlesticks will have been tallied.
Next day the counting will be restarded at StartTime.
Hi Roberto
This is close to what I need but it adds the cumulative bullish/bearish points to the previous session. I was hoping just to capture the number of bullish/bearish points for each individual session.
Does that make sense? I’ve tried to show this in the attached image.
Thanks again
Rob
07/14/2019 at 11:51 AM #102547Please do not quote posts unless necessary.
Everyday, at StartTime, it restarts.
The candle must CLOSE at StartTime, if you want to use a custom TF, say 7 or 36 minute TF you must either:
1 – change the StartTime and EndTime
2 – replace = with < at line 7.
07/14/2019 at 12:15 PM #102548You also need to remove = from line 11 if you want the time interval to be only > than StartTime and < EndTime.
07/14/2019 at 12:23 PM #10254907/14/2019 at 12:59 PM #102550I read you could do that individually but wanted their sum,
A single candle count is easy;
1234IF time >= 080000 AND time <= 100000 THENCount = abs(close - open)ENDIFRETURNOf course you’ll have to add your conditions, other than bullish or bearish, if any, at lines 12 and 15.
My code is generic and counts all of them.
10/23/2020 at 12:22 PM #148219Hi Roberto thanks for the code listed above would it be possible to adapt it so it does a rolling count of bear and bullish candles that updates every hour ? I’ve been looking for something to help remove some losses with a long position on a 1 minute time frame and wondered if this could be adapted ? Happy to open a new thread if needed ?
Thanks in advance.
10/23/2020 at 2:01 PM #148241There you go:
123456789101112131415ONCE BullCount = 0ONCE BearCount = 0Bullish = close > openBearish = close < openIF OpenHour <> OpenHour[1] THENBullCount = 0BearCount = 0ENDIFIF Bullish THENBullCount = BullCount + (close - open)ENDIFIF Bearish THENBearCount = BearCount + (open - close)ENDIFReturn BullCount as “Bullish”, BearCount as “Bearish”1 user thanked author for this post.
10/23/2020 at 3:17 PM #148251 -
AuthorPosts
Find exclusive trading pro-tools on