Noob here. Trying to figure out how to do the following. I want to scan for stocks that meet the following criteria:
Previous Bar: DMI (-) is greater than DMI (+)
Current Bar: DMI (+) is greater than DMI (-) and DMI (+) is greater than a value such as 25.
I have not had any luck figuring out how to make TradeStation’s scanner look back to previous bars. Is this even possible via Scanner? Is it possible using a custom indicator?
I couldn't find right away how to reference the previous bar in the scanner, maybe someone else knows. However you can use this custom indicator I created for you to do the testing. When your scan conditions are met it will return +1 and 0 if not. So you need to display those symbols that return 1 in the scanner.
You can reference previous bar's values with brackets and the number within the brackets is how many bars back you want to go back from the current bar. So oDMIPlus[1] in the code below would be the value for DMI(+) from the previous bar.
Have a great weekend.
Regards,
ABCTG
The following 4 users say Thank You to ABCTG for this post:
The first thing I did was remove the ADXTrend and UpperThreshold inputs, and replaced UpperThreshold in the conditions area with the value 25. Although I don't really know if this had much, if any, effect.
What seemed to have the most effect was in the Scanner, changing the "Load Additional Data" value from 1 to 300. As soon as I did that, I was starting to see some "1s". I didn't bother to go back and change the code to the original code...at least not yet.
Thanks again.
The following user says Thank You to 10handles for this post:
thanks for the feedback. Loading Additional Data is what did the trick. The reason is that the indicator needs a certain amount of data to properly calculate. If you load less than the needed amount Tradestation will not plot anything.
In the case of the ADX at least an amount equal to the Length input is needed to give a result.
Regards,
ABCTG
The following user says Thank You to ABCTG for this post:
I've been trying to adapt your code to work with other indicators but I am not having any luck.
What I'd like to do is scan for the MoneyFlow indicator turning down (or up). If I can get this working for one indicator such as MoneyFlow then I imagine it would not be too difficult to adapt the code to work for other indicators as well. Was hoping to piggy back off the DMI indicator code but that hasn't worked. Is this something you might be able to help me with? Thanks in advance.
you are trying to call the Moneyflow results from a function that computes the ADX. Take a look at the build in Moneyflow indicator that gives you a good idea on how to call the moneyflow function and use the value later in your code.
In Easylanguage you can reference values from previous bars by adding a square bracket to your variable. The number within the brackets is the number of bars you want to go back where 0 is the current bar.
So oMoneyFlow[1] would be the value from the previous bar. You will need to use this to check if the moneyflow is rising or falling.