Runtime error Bar number must be 5590 or greater at SellAtStop
Author: gfparker
Creation Date: 3/12/2018 7:20 PM
profile picture

gfparker

#1
The attached strategy crashes at the SellAtStop Signal with the following message:

Runtime error Bar number must be 5590 or greater
at WealthLab Strategies MyStrategy Execute()
at WealthLab Script SellAtStop(Int32 bar, Position pos, Double stopPrice, String signalName)
at WealthLab Script a(Int32 A_0,Int32 A_1, Int32 A_2)

For the life of me, I can't figure it out, please help. If I comment out the SellAtStop the strategy works fine.
profile picture

Eugene

#2
Hi,

Let's agree on definitions first. If you can suppress an error message and continue working in the program, it means that Wealth-Lab has not crashed. I've renamed the misleading topic title "Strategy Crashes at SellAtStop Signal".

If you wish that we take a look at your Strategy code simply paste it inside a pair of CODE tags. Indicating relevant details like symbol(s), bar scale and data loading range should help understand what goes wrong.

Searching the forum might also be a good idea:

Closing all trades: Bar number must be X or greater
Bar number must be 6 or greater
Error processing symbol XXX Bar number must be YYY or greater

P.S. Also, please do not use PDF for posting screenshots and/or error messages. If it's a modal Windows error dialog, you could strike Ctrl-C to copy the underlying error message and Ctrl-V to paste it when replying (a standard Windows shortcut). Please only attach text as text (TXT) and images as images (PNG preferred, MS Paint which is built in any Windows will do it).

profile picture

gfparker

#3
Actually what I thought was a mistake, didn't solve the problem. I looked at the other answers but they aren't shedding any light on the situation for me. Below is the code as it stands now, still getting the error message anytime I try to set the daysafterdiv parameter at more than 2

CODE:
Please log in to see this code.
profile picture

Eugene

#4
Well, your code boldly goes beyond the hard right edge:
CODE:
Please log in to see this code.

No wonder why in runtime it throws an exception suggesting that the index is out of bounds: "Bar number must be 5590 or greater".

For this to work you have to process less bars than there is, for example:
CODE:
Please log in to see this code.


P.S. While it shouldn't affect the result I'm not sure why the loop starts at bar #100 so you might make it more universal with this:
CODE:
Please log in to see this code.


And this clearly can be deleted:
CODE:
Please log in to see this code.