Hello,
Here’s another strategy I was hoping I could get some help with coding.
The strategy is based on three consecutive 15 minute bars:
The 2nd bar’s low is lower than the low of the 1st bar. The volume of the 2nd bar is <= 0.85 x volume of the 1st bar. The close of the 2nd bar is below open and the difference between high and open is less than the difference between close and low.
The 3rd 15 minute bar’s high is greater than the high of the 2nd bar and closes in the upper 15% of the 2nd bar’s range or higher. The volume of the 3rd bar is >= 1.5X the volume of the 2nd bar.
If above conditions are met, give an alert on the open of the 4th bar.
Please see attachment for 15min QQQ on 6/14/2016; it's a good example of three consecutive bars meeting above conditions:
1st bar: 11:15 AM
2nd bar: 11:30 AM
3rd bar: 11:45 AM
Alert occurs on the open of the 12:00 PM bar.
Thanks in advance
Size:
Color:
In the code below I commented out your rule "The close of the 2nd bar is below open". Why? Because the difference between the close and the open of the next bar is only 1 trade, and in the case of QQQ, possibly only a microsecond had elapsed between those trades. Consequently, that rule is irrelevant and has no statistical basis for intraday trading, in my opinion. If you don't agree, just uncomment the rule.
There's a comment section that indicates the "bar" convention relative to your 1st, 2nd, and 3rd bar. In terms of WealthScript code, "bar" is always the current bar that has just completed and then we look
backwards to see what happened before. (If you look forward, that's peeking.)
CODE:
Please log in to see this code.
Size:
Color:
Hello,
Below is your strategy code. However, it's not very much different in principle from what you
requested before. If you were to leverage my previous example, it'd only require the knowledge of basic elements such as Bars and its DataSeries, bar numbers, and very simple math. After 11+ years in our community, I think this should not be difficult to you.
Here's something tried and true to start with and I hope you'll be able to come up with the code of your next 'strategy based on 4 consecutive bars' yourself :)
FAQ >
How do I get started learning Wealth-Lab?FAQ >
How do I start with C# ? I'm a Wealth-Lab 3/4 user, how to learn C# ?CODE:
Please log in to see this code.
Size:
Color:
Thank you Eugene and Cone for the codes and insights.
Eugene, I was not able to get the code working when I first signed up so I have not been active in the past 11 years. I recently have come back to try it again.
Cone, great explanation with the comments...I see now how the "bar" convention works with WealthScript code. I tried your time based exits during market hours intraday (3, 5, 15 minute) with a couple of codes. Alerts show up on strategy monitor but most alerts disappear after a few minutes. The strategies are set up with paper accounts. I brought up the paper account today and did not see any trades. Is there a way to retrieve the alerts with the time it triggered?
Thanks again
Size:
Color:
QUOTE:
I brought up the paper account today and did not see any trades.
That's right, you should not see them because it's Saturday and they didn't execute before. It's too late and expired alerts no longer make sense (although the SM keeps them for some time). Look for
new trades on Monday.
QUOTE:
I brought up the paper account today and did not see any trades. Is there a way to retrieve the alerts with the time it triggered?
Note that depending on data loading range, my code may not generate new trades because you forgot to specify an exit.
Size:
Color: