What I expected to get is the lines between every pair of buy and sell, but what I got is one continuous line connecting every single buy and sell. Any ideas to fix it?
Besides, is there a way to get a larger up or down arrows? Since I didn't find a way to set the size of arrows.
A humble request, post working code. Also, if you have borrowed code, do cite the source.
Now the problem here is that you have chosen not to disclose the critical part, that is the Buy and Short themselves.
There are system that are "Always IN Trade", which you buy-> sell and short from there.
In that case, there is nothing wrong with the output of continuous lines.
Why am I saying that? Because these variables are used without their definitions known
if (Short[i]) { . . .
if (shortIn && Cover[i]) { . . .
Another challenge is dealing with non-executable code, so if one wants to test, there is now way.
If a couple of bits are missing, maybe one will take the pain, in your case its a lot of code missing.
Let's assume your system is NOT always in the trade, then
if (ys0 && ys1)
May not be apt, with
IIf( IsNull( line )
Can the code guarantee that line variable is NULL in those segments?
Instead of using scalar variables ys0 && ys1, you could try shortIn but I guess you tried that and didn't work either., so
I'm truncating the post because I'm having too much guess work to do.
I'd rewrite those if() checks.
There is nothing wrong with the original. Its very nice.
Its only the modified one than isn't articulated well.
But to use it in my system and make it working needs to assume a lot which didn't make sense at that time.
Right click, edit formula and paste whole code that you are using else won't know.
If you want to check yourself, assuming enough data is there,
Your other code should have Plot() for candles/bars and the Buy Sell Short Cover variables defined.
If they have valid signals, the trade line will be Plot.