NexusFi: Find Your Edge


Home Menu

 





Determining the price of a Buy


Discussion in EasyLanguage Programming

Updated
    1. trending_up 5,427 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
EyesOnly
Seattle Washington
 
Posts: 4 since Apr 2019
Thanks Given: 1
Thanks Received: 0

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.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Roland Garros Final Day: $3M on Zverev at 80.5% -- Leban …
Prediction Markets & Event Contracts
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Warsh Rate Hike at 40%, Iran June 15 Expires Tonight at …
Prediction Markets & Event Contracts
June 15 Peace Odds Surge From 3.6% to 12.25% After Trump …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
BERN ALGOS algo trading journal
8 thanks
Volume Indicators
8 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642


Hi EyesOnly,

welcome to NexusFi. You might find the free EL Essentials PDF helpful as it covers the basics of EasyLanguage including strategies.
https://uploads.tradestation.com:443/uploads/EasyLanguage-Essentials.pdf

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?

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
EyesOnly
Seattle Washington
 
Posts: 4 since Apr 2019
Thanks Given: 1
Thanks Received: 0

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


Reply With Quote
  #5 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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


Follow me on X Reply With Quote
  #6 (permalink)
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;


Reply With Quote
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,448 since Apr 2013
Thanks Given: 494
Thanks Received: 1,642

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.

Regards,

ABCTG


Follow me on X Reply With Quote
Thanked by:




Last Updated on May 17, 2019


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts