NexusFi: Find Your Edge


Home Menu

 





Determining the price of a Buy


Discussion in EasyLanguage Programming

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




 
 

Determining the price of a Buy

 
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.


Can you help answer these questions
from other members on NexusFi?
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
REcommedations for programming help
Sierra Chart
Exit Strategy
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
Better Renko Gaps
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
30 thanks
Spoo-nalysis ES e-mini futures S&P 500
28 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
20 thanks
GFIs1 1 DAX trade per day journal
16 thanks
 
 ABCTG   is a Vendor
 
Posts: 2,433 since Apr 2013
Thanks Given: 481
Thanks Received: 1,627


Hi EyesOnly,

welcome to futures.io. You might find the free EL Essentials PDF helpful as it covers the basics of EasyLanguage including strategies.
https://uploads.tradestation.com/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 Twitter
Thanked by:
 
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

 
 ABCTG   is a Vendor
 
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

Follow me on Twitter
 
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   is a Vendor
 
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.

Regards,

ABCTG

Follow me on Twitter
Thanked by:

 



Last Updated on May 17, 2019


© 2024 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 - Privacy Policy - Downloads - Top
no new posts