I'd like to create a system that references specific conditions and adds a value, e.g. a 1 for each time such a condition is true. For example, say there are 5 conditions, price is greater than 200 day m.a., the rsi is lower than some value, the price closes three consecutive days, the day is last trading day of the month and the day is Tuesday. The value would be 5 if all conditions are true. I would buy if this value is greater than or equal to 3.
How can I write code that will do this?
Thank you..
Size:
Color:
Size:
Color:
Thank you.
Size:
Color:
I would like to use triggers as per the example you showed. Below is the code I have that I wish to make changes on. How will I get from here to a program that adds up the triggers that will then become the buy rule. E.g. if(trigger value > 3) BuyAtMarket; Right now, I'll plan on using an exit based on the code as is. I just need a starter for coding the buy rules for this system. Thank you in advance.
CODE:
Please log in to see this code.
Size:
Color:
Based on the setup requirements in the first post and the script above, here's your solution.
CODE:
Please log in to see this code.
Size:
Color:
Since the strategy clearly comes from the Rules Wizard, I wonder if it would be natural to simply adjust Required Conditions to a desired number and limit the Lookback Period to 1?
Size:
Color:
Thank you Robert. Eugene, I'm not sure I understand what you mean at this time. At the end of the day, I wish to do something similar to what Robert has provided, except I would change the weights and the conditions accordingly.
Size:
Color:
Perhaps I must have overlooked the weights.
Size:
Color:
Robert. Can you explain cntConditions++ and bcd += 1-> 1000000? I am trying to understand your methodology. Thanks.
Size:
Color:
Size:
Color:
I understand that, but why are the bcds incremented by a factor of 10? The cntConditions seems most obvious in terms of adding up to a value that would make the trade, but bcd is confusing me.
Size:
Color:
QUOTE:
why are the bcds incremented by a factor of 10?
Why not? You can assign different weights to the "bcd". For example, the DayOfWeek in Cone's code is the strongest signal.
Size:
Color:
I'm not sure why there are both cntConditions++ and bcd += . Please clarify how both of these work together?
Size:
Color:
"Not sure" is vague. And you already know that the "bcd" is weight - a double value. Assuming that you can experiment with the code, evaluating PrintDebug() output and assigning different weights while keeping a C# 101 book open as reference, I wonder what do you think requires clarification exactly?
Size:
Color:
So one is a counter and the other assigns weight. When I write if( cntConditions > = 4) Buy at Market. it seems only the cntConditions is applicable. What is happening with bcd as it relates to the buy signal?
Size:
Color:
Whatever you code. It's up to you.
Size:
Color:
Michael, the following comment is in the script explaining what bcd is:
// bcd is the "code" of the condition that is true.
Using this, you can see which conditions triggered the entry. It's informational only.
For example: 01101
The unit position "1" corresponds to (Close[bar] > ma[bar])
The hundreds position "100" corresponds to (CumDown.Value(bar, Close, 1) >= 3)
The thousands position "1000" corresponds to (Date[bar].GetRemainingTradingDays() == 0)
Size:
Color:
Ahh I understand now. Thanks Robert!
Size:
Color: