|
LAST ENTRY PRICE FUNCTION FOR TRADESTATION
A useful function for Tradestation programmers.
User of Tradestation's programming environment may have experienced difficulties with multiple entry price models as the built in function ENTRYPRICE(NUMBER) only refers to the entry price of a new "overall position" rather than an entry of sequence of trades which go to make up an overal position.
The software does not have a function to call the 2nd or 3rd or greater entry prices in a position where several trades are placed.
While developing a Martingale model I ended up creating a special function to do just that so it was easier to call from.
The function is called "LastEntryPrice" and will always call the most recent entryprice regardless of how many entries are employed.
So if you need a triple entry model to work you can use the regular "ENTRYPRICE" function to call the first trade and then the LASTENTRYPRICE function to call the next ones.
Sample code below
//First exit
IF currentcontracts= first_size and marketposition=-1
and ENTRYPRICE-CLOSE > 12.50
THEN BUYTOCOVER ("1st exit short") next bar on highest(high,5) stop;
//Second exit
IF currentcontracts= first_size+Second_Size
and marketposition=-1 and LASTENTRYPRICE-CLOSE > 25
THEN BUYTOCOVER ("2nd exit short") NEXT BAR AT MARKET;
This product will be available upon request on the Tradestation app store if anyone asks me for it.
Some of my other products are now listed there for sale, copy and paste the link below into your browser to see them
https://tradestation.tradingappstore.com/developers/rogermedcalf