My script behaves unexpectedly
Author: alsilva86
Creation Date: 9/10/2017 7:39 AM
profile picture

alsilva86

#1
HI All!

Have you ever experienced strange behaviour of scripts?

I am facing a very strange situation, using a daily data I am buying at bar opening and selling at bar closing, until there all is fine, but according with my business rules I CAN NOT have a sell order with same price of a buy order of limit, can any of you enlight me on this?
I am attaching the results of my test and my code:

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

Eugene

#2
QUOTE:
I CAN NOT have a sell order with same price of a buy order of limit,

So the problem is what? Neither one of the 3 highlighted orders has an entry price equal to the exit price. Please clarify your rules and what price/trade you expect not to have taken place.
profile picture

Cone

#3
While waiting for your clarification, here are some coding shortcuts:

CODE:
Please log in to see this code.


profile picture

alsilva86

#4
Eugene, thanks for answering!
Its not about exit prices, but the entry ones!

CODE:
Please log in to see this code.


How is this possible? How can be possible that Close - X value be the same as Close + X value on a limit order?

i.e 10.31 - 0.31 = 10 buy @ 10

10.31 + 0.31 = 10.62 sell @ 10

This is impossible to happen.


profile picture

Eugene

#5
It would be impossible to happen if you were modifying the price and priceShort variables accordingly. However, your code does integer division:

CODE:
Please log in to see this code.


CODE:
Please log in to see this code.


For explanation and examples please see the Wiki FAQ:

I'm trying to divide two numbers and the result is zero.
profile picture

alsilva86

#6
Thanks for your info, Eugene! The values are very distant, I will keep looking into it after doing the changes you suggested.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).