SMA/EMA crossover strategy not working as I think it should
Forums › ProRealTime English forum › ProOrder support › SMA/EMA crossover strategy not working as I think it should
- This topic has 16 replies, 3 voices, and was last updated 4 years ago by
Vonasi.
-
-
02/14/2021 at 1:32 PM #161380
Hey! I have written so much more advanced things than this so it is pretty embarrassing to write this, but part of my big code didn’t act like I wanted it and when I wrote out a sample and it still didn’t work, it is just a normal MA crossover. The buy and sell don’t appear where they are supposed to.
Please tell me what I have done wrong.
I will attach the code and also a picture of the result.
problem123456789baseline=exponentialaverage(close)[100]sma=average(close)[20]if sma crosses over baseline thenbuy 1 shares at marketendifif sma crosses under baseline thensellshort 1 shares at marketendif02/14/2021 at 1:39 PM #161381The buy and sell don’t appear where they are supposed to.
Code is good so it must be your expectations above that are misleading you?
Attach a screenshot and explain more what you expecting?
02/14/2021 at 1:41 PM #16138202/14/2021 at 1:49 PM #16138402/14/2021 at 1:52 PM #16138502/14/2021 at 1:58 PM #16138602/14/2021 at 1:58 PM #16138702/14/2021 at 2:06 PM #16138802/14/2021 at 2:09 PM #16138902/14/2021 at 2:09 PM #16139002/14/2021 at 2:10 PM #161391Have you checked your SMA and EMA settings? Perhaps you have them averaging something different or a horizontal shift added so your indicators are showing something different to your strategy code?
1 user thanked author for this post.
02/14/2021 at 2:15 PM #161393I have just done a quick test and can confirm that something is wrong. It appears to be trading when either close or high or low crosses the EMA. I will test further but there does seem to be some sort of bug.
1 user thanked author for this post.
02/14/2021 at 2:18 PM #16139502/14/2021 at 2:19 PM #16139702/14/2021 at 2:20 PM #161398 -
AuthorPosts
Find exclusive trading pro-tools on