Variable for the price of current forming candlestick
Forums › ProRealTime English forum › ProOrder support › Variable for the price of current forming candlestick
- This topic has 10 replies, 4 voices, and was last updated 1 month ago by shabib.
-
-
09/09/2024 at 1:39 PM #237389
I need your support to define veriable for the price of current forming candlestick
As I know
“Close” means the close price of the candlestick
Also ‘’Close’’ means the movment price of the current forming candlestick.
When I use close in my code the system gives me the close price of candlestick
What I want is to get the current price of the candlestick in my code.
What I want to say
When the current price touch the lowest low point of of previous predefined lowest low point buy one share at the market.I really appreciate your support
09/09/2024 at 1:39 PM #237376Hi Team,
Thia topic opened 4 years ago I hope the current price can be defined by a clear veriable.
I know
The “close” means the close price of the bar
Also “close” means the real – time price of the current forming candle.
When I use close in the code it gives me the close price of the bar and I don’t know how to get the veriable of the real- time price of the current forming candle.
What I want to tell
When current price touch the lowest low buy 1 share at the market.
Anyone can help?
09/09/2024 at 3:04 PM #237390Hi,
What you can do, as a workaround, is to use Multiple TimeFrames (MTF), on this forum there is a lot of information about this:
https://www.prorealcode.com/topic/multi-timeframe-mtf-indicators-for-prorealtime/
For example:
TimeFrame(1 hour)
Conditions
TimeFrame(1 minute)
Orders09/09/2024 at 3:06 PM #237391CLOSE is the current price.
When a bar closes it is, for that single microsecond, registered as te closing price, then it copntinues to retain the current price in the new bar being formed.
This is true for indicators and screener.
Staretegy ONLY run at the closing of each bar, not while it’s forming, so in that case CLOSE is both the CLOSING and the CURRENT price, as the newly forming bar can’t be accessed.
As to your question “When current price touch the lowest low buy 1 share at the market“, what LOW are you talking about, of which bar?
1 user thanked author for this post.
09/09/2024 at 4:03 PM #237402Thanks Reberto for your comment
My idea is to implement a code to identify the highest high of uptrend and lowest low of down trend of previous 15 hours ( starting from 01:00 am t0 04:00 pm) . No entry positions before 4 pm.
after 4 pm it allowed to enter position after it already calculated the highest high and lowest low , the entry position conditions are :
buy when the current price = lowest low
sell when the current price = highest high
this is my code , run in 1 hour time frame
// Reset for a new day
if intradaybarindex = 0 then
HighestHigh = 0
LowestLow = 0
endif// the caculation of highest high price and lowest low price would be during stratitime = 01:00 am to endtime 4:00pm
startime = 010000
endtime = 160000
// allow the code to enter a position until 10:00 pm
lasttime = 220000// start to caculate the highest high and lowest low of the previous 15 bars when reach bar index 15 of 1 hour timeframe
// calculate the last 15 hours , at 4pm
c1 = intradaybarindex = 15 // this number to be change according to time frame e.g 30 min time frame (for previous 15 hours should be (30 bars)// Calculate highest high and lowest low of the last 15 hours , at 4:00 pm
IF c1 then
HighestHigh = highest[15](close)
LowestLow = lowest[15](close)
ENDIF// Conditions to enter long positions
// enter long position after 4pm , and if the current price equal to lowestlow
IF NOT LongOnMarket AND Time > endtime AND Time < lasttime AND close= LowestLow THEN
BUY 1 CONTRACTS AT MARKETENDIF
// Conditions to exit long positions
If LongOnMarket AND close= HighestHigh THEN
SELL AT MARKET
ENDIF// Conditions to enter short positions
// enter shortposition after 4pm , and if the current price equal to highesthigh
IF NOT ShortOnMarket AND Time > endtime AND Time < lasttime AND close = HighestHigh THEN
SELLSHORT 1 CONTRACTS AT MARKET
ENDIF// Conditions to exit short positions
IF ShortOnMarket AND close = LowestLow THEN
EXITSHORT AT MARKET
ENDIF
(close) keyword gave me the closing price of candle , while I want the current price to compare it with the value of highest and lowest.
which keyword should I use instead?
09/09/2024 at 4:11 PM #237403Hi,
if you want to consider values of highest HIGH and lowest LOW, not the highest close and lowest close, then you should first replace:
HighestHigh = highest[15](close)
LowestLow = lowest[15](close)by:
HighestHigh = highest[15](high)
LowestLow = lowest[15](low)and take it from there to further debug the overall code if needed
09/09/2024 at 4:32 PM #237410Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Thanks 🙂
I merged your questions from the forum https://www.prorealcode.com/topic/how-do-you-define-the-current-price-in-pro-order/.
09/09/2024 at 5:16 PM #237419Thank you. I’m new in this forum. Its lesson learns for me 🙂
@ JC_Bywan Thank you my dear
When I’m using the below it shown for me NO DATA.
HighestHigh = highest[15](high)
LowestLow = lowest[15](low)09/09/2024 at 6:17 PM #237423Ok, now that the first issue is fixed, which was in fact about defining highesthigh and lowestlow, you can move on to a second issue: you talked about the “last 15 hours” (this would include the latest one), but what you want is the previous 15 hours not including the latest one (the one just closed when strategy code is read, before next one not started yet), so as long as you define them in lines earlier than when they are used, you want to offset them by 1 candle to the left:
HighestHigh = highest[15](high)[1]
LowestLow = lowest[15](low)[1]Because if you don’t, your subsequent “if…then…” statements defining order conditions, including “…AND close= LowestLow then”, “…AND close = HighestHigh THEN” would only be true when that latest candle closes itself on the highest high or the lowest low, which would be rare (hence high probability of no data). With this offset of 1 candle, you make sure your compare that latest close with a highest high and lowest low built from the candles preceding it, not including it.
Then, process repeated of running again to check still bugging or not, until no bug vs result expected.
1 user thanked author for this post.
09/10/2024 at 9:42 AM #237442When I’m using the below it shown for me NO DATA.
HighestHigh = highest[15](high)
LowestLow = lowest[15](low)it can’t show any data because you are uysing
12AND close = LowestLowAND close = HighestHighas it’s almost impossible that a price is EQUAL to another price ina different moment. It may happens, if ever, once in a couple of decades!
Replace “=” by “>=” and “<=”, or use pending orders to enter at the exact price:
123456789101112131415161718192021222324252627282930313233// Conditions to enter long positions// enter long position after 4pm , and if the current price equal to lowestlowIF NOT LongOnMarket AND Time > endtime AND Time < lasttime THENIF close > LowestLow THENBUY 1 CONTRACTS AT LowestLow LIMITELSIF close < LowestLow THENBUY 1 CONTRACTS AT LowestLow STOPELSEBUY 1 CONTRACTS AT MarketENDIFENDIF// Conditions to exit long positionsIf LongOnMarket AND close >= HighestHigh THENSELL AT MARKETENDIF// Conditions to enter short positions// enter shortposition after 4pm , and if the current price equal to highesthighIF NOT ShortOnMarket AND Time > endtime AND Time < lasttime THENIF close > HighestHigh THENSELLSHORT 1 CONTRACTS AT HighestHigh STOPELSIF close < HighestHigh THENSELLSHORT 1 CONTRACTS AT HighestHigh LIMITELSESELLSHORT 1 CONTRACTS AT MarketENDIFENDIF// Conditions to exit short positionsIF ShortOnMarket AND close <= LowestLow THENEXITSHORT AT MARKETENDIF09/14/2024 at 6:01 PM #237579 -
AuthorPosts
Find exclusive trading pro-tools on