Timeframe condition not working
Forums › ProRealTime English forum › ProOrder support › Timeframe condition not working
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by
robertogozzi.
-
-
09/15/2019 at 11:32 PM #107626Timeframe condition not working123456789101112131415161718192021222324252627282930313233343536373839404142434445// Definition of code parametersDEFPARAM Preloadbars = 10000DEFPARAM CumulateOrders = false // Cumulating positions deactivated//DEFPARAM FLATBEFORE = 090000//DEFPARAM FLATAFTER = 220000// indicatorstimeframe(default)rs = RSI[7](close)ema50 = ExponentialAverage[50](close)ema200 = ExponentialAverage[200](close)Positions = 1//Exit Longif longonmarket and rs crosses under 75 thensell at marketendif//Exit Shortif shortonmarket and rs crosses over 25 thenexitshort at marketendif//// Conditions to enter Long positionsTIMEFRAME (1 hour, updateonclose)a = ema50 > ema200timeframe(default)b = rs crosses over 25x1 = ema50 > ema200IF a and b and x1 THENbuy Positions shares AT MARKETENDIF// Conditions to enter Short positionsTIMEFRAME (1 hour, updateonclose)c = ema50 < ema200timeframe(default)d = rs crosses under 75x2 = ema50 < ema200//IF c and d and x2 THENsellshort Positions shares AT MARKETENDIF
anyone have any idea why not the timeframe 1hour condition not working? from the attached screen it is clearly that “c = ema50 < ema200” is not valid and still it is taking a short trade however it is valid on the 15 min timeframe that is default and it looks for me that it is following the default time frame and igonring the 1 hour timeframe.
09/15/2019 at 11:41 PM #10762809/16/2019 at 12:12 AM #107639You’re are absolutely right!
It ignores your 1-hour TF because no indicator is defined within THAT time frame. You only set conditions based on the indicators written in your default TF.
Move lines 9-11 to just after line 26.
Indicators only work in the TF they are declared, though you can read them from anywhere else.
09/16/2019 at 12:36 AM #107643i only want the ema50 and ema200 to be checked in 1 hour timeframe so it shoud be like this then?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152// Definition of code parametersDEFPARAM Preloadbars = 10000DEFPARAM CumulateOrders = false // Cumulating positions deactivated//DEFPARAM FLATBEFORE = 090000//DEFPARAM FLATAFTER = 220000// indicatorstimeframe(default)rs = RSI[7](close)Positions = 1//Exit Longif longonmarket and rs crosses under 75 thensell at marketendif//Exit Shortif shortonmarket and rs crosses over 25 thenexitshort at marketendif//// Conditions to enter Long positionsTIMEFRAME (1 hour, updateonclose)a = ema50 > ema200ema50 = ExponentialAverage[50](close)ema200 = ExponentialAverage[200](close)timeframe(default)b = rs crosses over 25x1 = ema50 > ema200IF a and b and x1 THENbuy Positions shares AT MARKETENDIF// Conditions to enter Short positionsTIMEFRAME (1 hour, updateonclose)c = ema50 < ema200ema50 = ExponentialAverage[50](close)ema200 = ExponentialAverage[200](close)timeframe(default)d = rs crosses under 75x2 = ema50 < ema200//IF c and d and x2 THENsellshort Positions shares AT MARKETENDIF//SET STOP ploss 75//SET TARGET pPROFIT 2509/16/2019 at 1:24 AM #107644Line 25 needs to be moved below line 27, before line 28.
Lines 39-40 can be removed, they are a duplicate of lines 26-27.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on