Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
I'm new to EasyLanguage (although am a professional programmer), and I can't find how to determine the price of a Buy command. Buy has no return value, and I don't see a keyword or function which lets me see this value.
I'm setting up a strategy on simulated trading (to not use real money yet), and the basic algorithm I'm trying to construct (for learning purposes) is:
if(buyprice = 0)
{
buyprice = buy 1 share next bar at market;
}
else If Close > buyprice
{
sell 1 share next bar at market;
buyprice = 0;
}
I found "EntryPrice" but that doesn't seem to get what the buy actually executed at for the "market" price. What I would like to know is how to get what the "buyprice" would be from the above pseudocode.
Can you help answer these questions from other members on NexusFi?
Once you are filled EntryPrice should give you access to the price the trade was filled, but without seeing your code it's hard to tell why it did not work. What value is returned on your end?
Hi ABCTG,
It looks like the EntryPrice might equal the price of the most recent buy, but it doesn't appear to be guaranteed to do that. For example, if I give a command "buy next bar at market", the EntryPrice is the current price, and not the price of the next bar.
Furthermore, since bars occur in discrete time intervals, it's possible there is a trade between my buy and when the EntryPrice is evaluated (which occurs on those time intervals), which would render the EntryPrice inaccurate (unless all such trades were at exactly the same price).
Is there a way to query exactly what the last buy price occurred at? I assume this is recorded somewhere, but I can't find where that is. Alternately, if there's a way to get a list of all trades made I could have the code search through that.
Thanks,
EyesOnly
ABCTG
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627
EyesOnly,
how do you define the price of a buy command exactly? Is this your fill price or the price at which your order command was issued? There are no reserved words that store the price at the moment you issued an order, but you can store this yourself within a variable or list in case you require values from previous instances. For the fill prices you can use EntryPrice or store each fill in a list within a StrategyHost object yourself for example.
Regards,
ABCTG
EyesOnly
Seattle Washington
Posts: 4 since Apr 2019
Thanks Given: 1
Thanks Received: 0
Thanks for sending over that PDF - reading through it helped me get what I needed. The "GetOpenPositionPL" already had the data I was trying to calculate.
To answer my original post, it looks like the price it was bought at is:
BoughtPrice = EntryPrice - GetOpenPositionPL;
ABCTG
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627
EyesOnly,
I would suggest using the Print reserved word to check the values for BoughtPrice, EntryPrice and GetOpenPositionPL throughout your code. As EntryPrice is a static value for every entry, the value for BoughtPrice for the same entry will change with the open positions's profit/loss.