Sorry to say this solution will not work with the conditional orders. This solution uses recursion, which is not permitted in the conditional orders (at this time). Please check the new answer I provided on 5/23/18.
This is really a great question. I can see how you would think the condition you created would do the trick. But there are some missing elements and I will explain everything.
First, let’s take a look at the code generated from your Conditional Order:
close crosses above high
And we can see that your Conditional Order is set to the 1 min time frame.
In English this is stating: “when the close of the current one min bar crosses above the high of the current one min bar”
That, is completely impossible. The close of the bar can never cross above the high of the same bar. They can be equal. But the close can never be above the high, of the same bar. So we need to add a bit to this code to get the current high of the day. And we need to do this so that we exclude the current bar. Because we only want this to be true when the close of the current bar has crossed above the “previous” daily high.
So we employ a few tricks that are compatible with the Conditional Order:
def newDay = GetDay() <> GetDay()[1];
rec highOfDay = if newDay then high else if high > highOfDay[1] then high else highOfDay[1];
plot trigger = close > highOfDay[1];
Line 1 checks the current day of each bar on the chart, and when the first bar of the day appears on the chart it equals true.
Line 2 is recursive and first checks if newDay is true and assigns the high of that bar. Next, it checks if the high of any given bar is higher than the previous value of highOfDay. So this variable always contains the highest high for the day up to that point.
Line 3 is the trigger. This checks that the close of the current bar is higher than the highOfDay of the previous bar. When this evaluates to true, you have the close crossing above the previous daily high.
Screenshot below shows what this looks like on a chart. So you can see exactly where and when the trigger is going to be true. Be sure to unchecked the Ext Hours box. Unless you want to include extended hours trade. If you do use extended hours trade, the premarket high can become the high of the day.
Ah so much for the Automation!!, They do have an API interface, but that’s too much for me, Thanks for the quick reply on this one.
Hello Pete,
I contacted their Scrip support and they come up with following script, but when i added this to conditional order its not working, any idea what might be causing the problem. ( each def statement start on a new line but somehow lines are not breaking and it all wrapped up in a paragraph)
Thanks.
Thanks for getting in touch with me. Below is an example script that I think accomplishes what you’re looking for. Please carefully review and test this script to be sure it’s working the way you want and expect it to and feel free to make any necessary adjustments.
#assumes no right expansion
def today = getyyyymmdd() == highestall(getyyyymmdd());
def excludecurrent = barnumber() < highestall(barnumber()); def conditionalhigh = if today and excludecurrent then high else double.nan; def condtodayhigh = highestall(conditionalhigh); plot data = high > condtodayhigh;
Have you tried to plot it on a chart to see what it’s doing?
I still struggle with entire premise of your quest here. The issue is easily addressed by placing a buy stop order one tick above the previous day’s high. There is no need for a conditional order at all. Perhaps you can explain why this is needed?
I will say that the script you got from support has shown me a unique way of getting around the recursion limits. I will not forget this little trick.