Variation from candle high to low and low to high
Forums › ProRealTime English forum › ProOrder support › Variation from candle high to low and low to high
- This topic has 7 replies, 2 voices, and was last updated 6 years ago by jbyrne.
-
-
02/05/2018 at 3:09 PM #61568
Hi,
I can’t find out how to use the ‘variation’ function to start counting from the candle high, and stop at the candle low and vise versa.
I want to measure the price difference between a candle high and another candles low(or vise versa) over a period of time. I have been using the summation function as well to do this. Here’s the line of code that I’m using for context if needed;
1234567891011121314151617RISE = 0FOR y = 2 to 120 DOif (summation[y](Variation(close))>=1) THENRISE = RISE + 1ELSEBREAKENDIFNEXTFALL = 0FOR y = 2 to 120 DOif (summation[Y](Variation(close))>=-1) THENFALL = FALL + 1ELSEBREAKENDIFThanks in advance
02/05/2018 at 3:54 PM #61569You have mixed 2 different ways to make your calculation. However, I don’t understand the code you made because of your RISE and FALL variables? Do you only want to know the price distance in percentage between 2 bars or counting how many times the price has ascended and declined?
02/05/2018 at 3:58 PM #61570The code that’s shown is just code I’ve put together myself using examples found in the PRT documentation. I would actually like for the code to return the distance between high and low but don’t know how to do that either. So just ignore the RISE and FALL, I only put the code in the post incase it wasn’t clear what I was talking about.
02/05/2018 at 4:38 PM #61579Ok, so the variation between two Closes could be programmed as follows:
1var = (high[1]-low[120])/close*100It measures the distance in percentage between the High of the previous bar to the Low of the 120th one before the current period.
1 user thanked author for this post.
02/05/2018 at 8:08 PM #6159102/05/2018 at 8:23 PM #6159202/05/2018 at 8:34 PM #61593I better start copy pasting then! But before I do, how can I get it so that a position is opened once half of the distance from high to low is reached? So then my system is complete and I don’t have re-do all 240 different cases in the near future.
02/06/2018 at 10:44 AM #61649I used the code you just gave me and I doesn’t seem to work. The code runs but doesn’t work as intended, any ideas why?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364defparam CUMULATEORDERS = falseIF (CurrentTime >= 150000) THENSleep = 1ELSESleep = 0ENDIFIF (CurrentTime = 160000) THENEOD = 1ELSEEOD = 0ENDIFIF (CurrentTime < 083000) THENWakeUp = 1ELSEWakeUp = 0ENDIFIf (WakeUp = 0) and (Sleep = 0) THENTTime = 1ELSETTime = 0ENDIFRISE = 0FOR y = 2 to 120 DOif ((high[1]-low[y])/close*100)> 0.01 THENRISE = RISE + 1ELSEBREAKENDIFnextFALL = 0FOR y = 2 to 120 DOif ((low[1]+high[y])/close*100)> 0.01 THENFALL = FALL + 1ELSEBREAKENDIFnextPercentage = 3Bull = close > (DClose(1) * (1 + (Percentage/100)))Bear = close < (DClose(1) * (1 - (Percentage/100)))IF BULL and FALL and TTime = 0 THENBUY 1 Contract AT MarketENDIFIF BEAR and RISE and TTime = 0 THENSELLSHORT 1 Contract AT MarketENDIFIF EOD and Longonmarket thensell at marketendifIf EOD and Shortonmarket thensellshort at marketendif -
AuthorPosts
Find exclusive trading pro-tools on