Suppose I had an indicator and I wanted to be long item 1 when the indicator was greater than 10, item 2 when the indicator was between 10 and -10 and item 3 when the indicator was below 10. I wrote the following, but it does not work as expected.
// symbols uppreSYM = "IBM" middleSYM = "MSFT" lowerSYM = "NVDA" // parameters -- levels upper = Param("upper level", 10); lower = Param("lower level", -10); // calc the indicator indicator = magicBoom(); // buy sell logic -- upper zone SetForeign(upperSYM); Buy = Cross(indicator, upper); Sell = Cross(upper, indicator); RestorePriceArrays(); // buy sell logic -- middle zone SetForeign(middleSYM); // enter from above Buy = Cross(upper, indicator); Sell = Cross(lower, indicator); // enter from below Buy = Cross(indicator, lower); Sell = Cross(indicator, upper); RestorePriceArrays(): // buy sell logic -- lower zone SetForeign(lowerSYM); Buy = Cross(lower, indicator); Sell = Cross(indicator, lower); RestorePriceArrays();
I suspect a case statement is going to be needed, but it is not clear to me how that should be implemented, or perhaps this is a task for some variation on rotational trading?
John -- who has yet to fully grok AB's object model