EMA SLOPE
Forums › ProRealTime English forum › ProOrder support › EMA SLOPE
- This topic has 29 replies, 2 voices, and was last updated 7 years ago by grimweasel47.
-
-
08/30/2017 at 11:08 AM #44905
Hi All,
I’m just trying to add a line of code as per below to my ProOrder. What I want is to take long or short positions as long as ‘Close’ is >< than ema, but with a further condition that longer term ema (50 in this case) is sloping UP for longs and DOWN for shorts, but within bounds (ie not over extended either way). On backtest the results from the code below are promising but I want to check the Long and/or Short command line is correct and not overly optimized?
Thanks in Advance
12345678910// --- indicatorsema = exponentialaverage[15](close)ema2 = exponentialaverage[20](close)//change = ROC(exponentialaverage[48](close))atr = averagetruerange[24]hh = highest[15](high)ll = lowest[15](low)Slope = ema2 - ema2[6]Long = slope >0.01 and slope <2Short = slope <0 and slope >208/30/2017 at 12:12 PM #4491208/30/2017 at 4:31 PM #44947Thanks Nicolas I will adjust. But if ema-ema(4) is negative then putting >- would be a double negative ie positive no? Is there a better way of determining ma slope (ie not flat)?
Also, is there an easy way of rather than buy above ‘n’ bars low/high on chart based on bar count, can PRT determine the previous swing high/low to the left of price (ie previous HH or LL) rather than telling PRT to look for a certain amount of bars? what I have found is that the HH and LL could occur between 1-24 hours prior so using count misses some – or would n=24 only trade above/below the HH or LL in that 24hr period?
12hh = highest[a](high)ll = lowest[a](low)08/30/2017 at 5:08 PM #44948Superior to -2 is everything between 0 and -2 in your example. So I think your code is right. You can make a simple indicator that return this slope calculation to see how it goes..
If n=24,then your code will return you the real highest high and lowest low of this whole data serie (from now to 24 bars ago).
09/20/2017 at 12:11 AM #46634Thanks Nicolas
I have another issue in that PRT code is such :
123456// --- settingsbalance = 10000 //balance of the strategy when activated the first timeminlot = 1 //minimum lot size for the current instrument (example: 1 for DAX)riskpercent = 2 //risk percent per tradeactivationtime = 060000 //Close time of the candle to activate the strategyLimitHour = 130000//limit time>then later in code…
1234if time=activationtime then// case 1 : If price candle touches MA (even wicks) then look at high or low of signal candleif high>ema and low<ema thencase = 1but the system on IGindex is not respecting the activateontime instruction. It seems to be activating trades at 00:01? Is there something I am missing?
Many thanks
09/20/2017 at 7:39 AM #46643The ‘activationtime’ must be met in the timeframe that the strategy is currently running on. On a Daily timeframe, that’s impossible since the code is only read once per bar at Close. So to check if the current time is 6 o’clock in the morning, your strategy must run in a intraday timeframe.
09/20/2017 at 12:14 PM #46696Hi Nicolas -thanks for the reply. I have moved the strategy on to other pairs now using IGindex. I replicated your original code but changed the ‘activationtime’ from 070000 to ‘x’ depending on the back tests in PRT. When I took this code across to IGindex I had to make a few changes such as they report FX as 11200 instead of 1.1200 for example which changed the #floor and ceil indicator settings. These are now all working. The problem is that the TIME function is not working even on H1 timeframe. The strategy seems to be activating on the next candle when I start the automatic trading in IG. Is this because their time stamp is different?
Thanks in advance!
09/20/2017 at 12:35 PM #46699Looking at when the errant trades are happening it seems to be activating at 00:00.00hrs when the strategy has not traded for more than 2 days (it happens most over the weekend as the strategy doesn’t trade Fridays and Mondays so the opening on Tues seems to activate the trade instead of 060000hrs under command ‘activationtime = 060000’
09/20/2017 at 1:30 PM #4670209/20/2017 at 2:08 PM #46705The eurusd first-hour strategy that you coded for me privately. Should I email instead? Everything else is now working just it seems on a few pairs the trades are being taken before the activateontime =x. Could this be related to later parts of code that cause the issues if it has not traded the day before:
123if onmarket or (onmarket[1] and not onmarket) or (currentprofit<>strategy rofit) thenalreadytraded = 1endif09/21/2017 at 11:30 AM #46783As you can see from the attached, this system should not open new trades after 2100hrs each day; yet it is still opening trades at 00:00.00 hrs??
09/21/2017 at 11:32 AM #46786The part of the code that sets the pending orders shouldn’t allow trading past 2100 when Limithour = 210000
123456789while case <> 0 and daytrading=1 and time <=LimitHour doif levelhi>0 thenbuy size contract at levelhi stopendifif levello>0 thensellshort size contract at levello stopendifwendendifAny help appreciated.
09/25/2017 at 11:34 AM #47235Is the ever devout Nicolas ill or on holiday? Hope all is well?
09/25/2017 at 2:16 PM #47264I’m well but kinda overwhelm 🙂 What is the timeframe you are using for that strategy? A pending order is active during 1 bar, so set STOP orders at 210000 and they will last until the end of the bar which is 220000 if you are trading on a 1 hour timeframe for instance.
09/25/2017 at 9:22 PM #47308Ahh right, thanks Nicolas. That makes sense now. So if limithour= 1800(00) then the system would not enter any new orders after 1859(59)hrs then?
I take it that with activationtime= 0800(00) then the strategy would not take any trades until after 0800 then?
Yes, using the H1 timeframe
-
AuthorPosts