Close of cross-over candle
Forums › ProRealTime English forum › ProOrder support › Close of cross-over candle
- This topic has 7 replies, 3 voices, and was last updated 8 years ago by Attienel.
-
-
11/08/2016 at 8:16 PM #16206
Hallo there,
Please help me.
123indicator1 = Average[8](close)indicator2 = Average[24](close)c1 = (indicator1 CROSSES OVER indicator2)I want to calculate the Close of the candle (c1 above) when the cross-over occurred (or just after the cross-over occurred). I want to enter a trade once a candle following the cross-over closes above the close of the cross-over candle.
11/09/2016 at 10:40 AM #16220You need here to store the Close value when your condition c1 occurred:
1234c1 = (indicator1 CROSSES OVER indicator2)if c1 thenval = CloseendifThen you can test if the next Closes will cross over this value. But it’s also possible that the price is already above this level .. so you have to deal with this too.
1c2 = Close crosses over val11/09/2016 at 12:40 PM #16226Thank you Nic, you’ve put me on the path to success.
I amended my code but now don’t get any Long entries. Can you possibly see what is wrong with my code?
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[8](close)indicator2 = Average[24](close)c1 = (indicator1 CROSSES OVER indicator2)if c1 thenval = Closeendifc2 = Close crosses over valc3 = Average[8](close) > Average[24](close)IF c1 THENWHILE c3IF c2 THENBUY 1 CONTRACT AT MARKETENDIFWENDENDIF// Conditions to exit long positionsindicator3 = Average[24](close)c4 = (close < indicator3)IF c4 THENSELL AT MARKETENDIF// Conditions to enter short positionsindicator4 = Average[8](close)indicator5 = Average[24](close)c5 = (indicator4 CROSSES UNDER indicator5)IF c5 THENSELLSHORT 1 CONTRACT AT MARKETENDIF// Conditions to exit short positionsindicator6 = Average[24](close)c6 = (close > indicator6)IF c6 THENEXITSHORT AT MARKETENDIF// Stops and targetsSET STOP %LOSS 211/09/2016 at 2:14 PM #1623711/09/2016 at 2:36 PM #1624211/09/2016 at 4:54 PM #16243Hi, me again,
I amended the code but it still doesn’t create Long positions. After the initial cross-over, I wait for confirmation (c2 and c3), which could be a few candles down the line, before I enter a trade (post confirmation). Does my code reflect this?
123456789101112131415161718192021222324// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivated// Conditions to enter long positionsindicator1 = Average[8](close)indicator2 = Average[24](close)c1 = (indicator1 CROSSES OVER indicator2)if c1 thenval = Closeendifc2 = Close crosses over valc3 = Average[8](close) > Average[24](close)IF c1 THENWHILE c3 DOIF c2 THENBUY AT MARKETENDIFWENDENDIFGRAPH val coloured(255,0,0)GRAPH close coloured(0,200,20)11/09/2016 at 5:44 PM #16250> For clarity of messages on ProRealCode’s forums, please use the “insert code PRT” button to separate the text of the code part! Thank you! <<
Did you learn something while debugging with GRAPH? Do the “val” variable correctly stored? Do the Close cross above it sometimes? ..
11/09/2016 at 9:37 PM #16259Hi Nic,
I will comply with the “insert code PRT” requirement. Thanks for pointing that out.
The “val” variable and Close variables are correctly stored and displayed on the graph. If I look at my chart, there are many instances where a candle following the cross-over candle closes above “val” but the code doesn’t trigger the respective entries so I can’t do proper debugging. Please see attached screen dump.
Thanks
-
AuthorPosts
Find exclusive trading pro-tools on