The strategy I'm currently using is to buy at limit channel low, and sell at limit channel high. I would like to add a double down market buy if a current open position drops by 3%. When I drag "buy at market" into the strategy window and add a condition to buy when "price is lower by x% than it was at current position's entry bar" I get an error that reads: "there were errors attempting to compile the strategy... :error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line".
How can I setup the double down market buy correctly in the rules based strategy?
Size:
Color:
QUOTE:
error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line".
It's a bug in the condition. The companion one ("higher than") wasn't affected. Please download and overwrite the
Community.Rules library, then reopen the Rule-based Strategy window. No WLD restart required.
QUOTE:
When I drag "buy at market" into the strategy window and add a condition to buy when "price is lower by x% than it was at current position's entry bar"
Nevertheless, this is not going to work. This condition is to be attached to an Exit rule only. It's incompatible with Entries.
Size:
Color:
Thanks. I've created an account for the wiki, but I'm unable to "see" the attachment link at the top of the page. Are you able to adjust a permission that will let me access the attachment, or is there a workaround I can do on my end?
Size:
Color:
Just granted you the necessary permissions, please retry.
Size:
Color:
Thanks. I was able to access the attachment. Is there a way to set the double down buy up in a rules based strategy now that I have the new community rules library?
Size:
Color:
Not with Rules but this task can be easily accomplished in code.
Size:
Color:
It's great to hear that there's a way of doing it. Do you have any time to help me with the code? Here are the details about the strategy setup:
- Buy at limit channel low 300 during market hours from 9:30 to 3:30pm EST
- Sell at limit channel high 30
- Sell all positions with market orders at last bar of the day
- Double-down buy with market order if current position drops by X% (I would want to set up the double-down buy as a variable so I can optimize)
Size:
Color:
Here you go:
CODE:
Please log in to see this code.
Size:
Color:
Thanks so much!
Size:
Color:
Sorry I didn't think of this last time, but do you think you could make the limit buy and sell periods variables as well?
Size:
Color:
Sure I can but one of the goals is to help you make it and utilize the program to the best extent possible. Please refer to the WealthScript Programming Guide > Programming Trading Strategies > Strategy Parameters for a hands-on tutorial on creating parameters. Good luck!
Size:
Color:
I took a look at it but it's way over my head. I don't have any experience coding, unfortunately.
Size:
Color:
So it's a good time to start building some experience. And the walkthrough in Method 3 (which I was referring to) is quite visual to help this.
Size:
Color:
Hi,
the condition produces as a buy at market entry condition weird results:
1) Error message: "Error processing symbol DOW DataSeries do not have equal number of values for mathematical operation
Error processing symbol DOW DataSeries do not have equal number of values for mathematical operation"
Surprisingly, this message does not appear when you perform the strategy on a friend's computer.
2) In addition, I receive no trades when using decimal number like 0,75 as a percentage. This error only appear when the entry buy at market is combined with another condition as "CMO is oversold".
Thanks for you help!
Best
Georg
Size:
Color:
Size:
Color:
Thanks, Eugene.
I updated the data and I still get the error message. I do perform any mathematical operation. The two Entry conditions I use is "CMO is oversold" and "Price is lower by X% than it was a number of bars ago". Backtesting is performed on Dow 30 (yahoo end of day data). Please note that I restarted the WL, the computer, rebuild the strategy etc.
Re decimal number: I also tried country settings. It still does not work. Strange enough 0,5 works, 0,75 does not work.
Size:
Color:
0.75 works just fine as any other value so this is not an issue. And I did try various regional settings with different decimal/currency separators.
As for "DataSeries do not have equal number of values for mathematical operation", indeed you get it when you 1) switch from another DataSet where you executed the backtest and 2) click "Run the strategy" on Rules tab you get that message. Funny bug. Workaround: click either "Go" or "Backtest on all symbols...":
Voila.
Size:
Color:
Thanks, Eugene.
Unfortunately, the issues persist. It does not matter whether I click on "Go", "Backtest on all Symbols in Dow 30" or "Run the Strategy".
Decimal figures don`t work properly either.
I am not sure what to do now. Any idea?
Size:
Color:
You can 'Open strategy code in a new window' to attempt fix any issue there directly.
I have no idea what this means and what you did exactly: "I also tried country settings. It still does not work". Like I shown you it works with U.S. regional settings.
Size:
Color:
Unfortunetly, I cannot code.
Could you please check the code:
CODE:
Please log in to see this code.
Size:
Color:
There is nothing wrong with the code. I don't have much to suggest you but to switch to other regional settings like U.S. Make sure that both numeric and currency decimal separators in Windows (Control panel - Regional options) are set to "." (dot). You might have need to replace "," to " " (blank space) in digit grouping symbol, if applicable.
Size:
Color: