- ago
Hello, in C# Wealth-Lab it is possible to use the function exitSignal = "Sell afer 8 bars" in the position column to output the exit signal when the trade is closed.
Here are the standard strategy parameters are output e.g. by
ClosePosition(foundPosition0, OrderType.Market, 0, "Sell after 8 bars");


Question: Is it also possible to store the preferred values of the respective stock as a variable here, so that it does not draw the standard values from the standard strategy parameters (e.g. Sell after 8 bars) but as an example with AAPL stored preferred values the value 3?


I can also program a little C#, so if the solution here is easier, I would be grateful for an idea or a suggested solution.


Kind regards
Chris

0
210
Solved
2 Replies

Reply

Bookmark

Sort
- ago
#1
For the example you gave with AAPL, presuming you want to show "Sell after 3 bars", because that's what AAPL has for a preferred value then do this...

Assume you have a Parameter type property in your class named ParamSellAfterNBars.

Assume you have an int type property in your class named SellAfterNBars that is used to store the ParamSellAfterNBars parameter's value, and your code properly initializes it from the ParamSellAfterNBars parameter (e.g. SellAfterNBars = ParamSellAfterNBars.AsInt;). Assume you are running your strategy using preferred values. Then...

ClosePosition(foundPosition0, OrderType.Market, 0, $"Sell after {SellAfterNBars} bars");

Albeit, I may have misunderstood your requirement.

If you want to use blocks, then I don't know how that's done, because I never use them. C# strategies offer far more power and flexibility.
2
Best Answer
- ago
#2
Thanks paul1986, this helps a lot.

Regards Chris
0

Reply

Bookmark

Sort