Is it possible to distinguish between the following 4 types of changes in position?
Long entry
Long exit (on stop)
Short entry
Short exit (on stp)
In an algo that checks for both long entry’s and short entry’s, I want only to enter a new long at a HIGHER price than the previous long entry, and a new short at a LOWER price than the previous short entry.
This may or may not be higher/lower than the previous TRADE as the last trade could be an exit on stop which in effect I want to ignore
Thanks
You can retrieve the open price of each previous trade with TRADEPRICE instruction. This way you can decide to take position higher or lower than this price.
Yes – but the question is, how do I distinguish between the different types of trades, as described above. I guess from your answer this is not possible?
What happens if the sequence of trades is 1) sell, 2) sell, 3) buy and 4) sell stopped out. I then want to sell more. How do I isolate the last sell price – tradeprice(3)? – and distinguish it from tradeprice(2) – the buy – and tradeprice(1) – the sell stopped out?
Not really sure what you mean but you don´t write “sell” when you want to short. You write it like this:
//buy long
If blabla then
buy 1 contract at market
//sell long
If blabla then
sell at market
/enter short
If blabla then
sellshort 1 contract at market
//exit short
If blabla then
exitshort at market
Try to give a variable a value when you launch a buy or a sell order, like this:
if conditionlong then
buy 1 share at market
a = 1 //trade is a buy order
endif
if conditionshort then
sellshort 1 share at market
a = -1 //trade is a sell order
endif
Then if you want to know what were the direction of the previous 3rd trade, you can access to the variable “a” with a little barindex play:
longORshort = a[barindex-tradeindex(3)]
So if “longORshort” return -1, then you know that your previous 3rd trade from now was a sell order.
I have not tested it, but it should work .. I think 🙂