I uderstand what the error says, and there are bars with zero values, BUT I'm excluding these bars from trading, so why am I still getting the error?
Here is the relevant code (there are no other buy/sell orders):
CODE:
Please log in to see this code.
The error:
(copy to clipboard would be nice for the error window):
QUOTE:
Runtime error: Basis price for Position entry cannot be zero
at WealthLab.Strategies.MyStrategy.Execute()
at WealthLab.WealthScript.ShortAtClose(Int32 bar)
at WealthLab.WealthScript.ShortAtClose(Int32 bar, String signalName)
at WealthLab.WealthScript.a(Double A_0)
Thnx
Size:
Color:
Somehow I fail to see where is the code excluding the zero value bars for bmSymb?
Size:
Color:
My appologies, I did not show the connection between bmSeries and bmSymb.
The top part of the code actually is:
CODE:
Please log in to see this code.
CODE:
Please log in to see this code.
Does that not exclude any bar containing zero, in either the active or the bmSymb?
Size:
Color:
No. Sorry if my commentary wasn't clear but what I meant to say is that you're setting context to a symbol whose bars have zero values w/o making any check:
CODE:
Please log in to see this code.
However, Wealth-Lab must use the close price to determine the basis price for the Position:
QUOTE:
Runtime error: Basis price for Position entry cannot be zero
Size:
Color:
QUOTE:
Wealth-Lab must use the close price to determine the basis price for the Position
Sorry Eugene, I still don't understand. If the close is zero, the program flow never reaches the trade code.
Are you saying, that WL need all close prices for a trade, even if not accessed by the trade?
Size:
Color:
QUOTE:
If the close is zero, the program flow never reaches the trade code.
Who knows? You didn't show the complete code as:
1. There are no exit orders,
2. The code creates impression that
bmSeries is being created on every bar.
Size:
Color:
QUOTE:
Who knows? You didn't show the complete code as:
1. There are no exit orders,
2. The code creates impression that bmSeries is being created on every bar.
OK, let me rephrase:
CODE:
Please log in to see this code.
I surrounded all
trade code with tests to eliminate the bars that contain zero. There are other ANDed conditions, but the effective code is as above.
Is there any way there could be a "Basis price ... cannot be zero" error, given the above code?
Size:
Color:
Try:
CODE:
Please log in to see this code.
Size:
Color:
I appreciate, that you're trying to give me a solution to a problem. Unfortunately, I need an answer to the question, regardless of solution. The code below is merely representative of that in the actual strategy.
CODE:
Please log in to see this code.
The zero values are not just in the first bars of one symbol, but also in multiple bars. For that reason I cannot simply start looping at the first valid value, but must test every bar.
My question remains: Is there any way that a trade within the tests for greater than zero could generate the "Basis price ... cannot be zero" error?
Size:
Color:
QUOTE:
My question remains: Is there any way that a trade within the tests for greater than zero could generate the "Basis price ... cannot be zero" error?
Before answering, let's expand your condition(s) the following way and see if it makes the error message go away:
CODE:
Please log in to see this code.
Size:
Color: