NexusFi: Find Your Edge


Home Menu

 





Coding a "Highest High of an open position"


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one ABCTG with 14 posts (9 thanks)
    2. looks_two djvie11 with 13 posts (0 thanks)
    3. looks_3 SMCJB with 2 posts (4 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 8,719 views
    2. thumb_up 13 thanks given
    3. group 4 followers
    1. forum 29 posts
    2. attach_file 0 attachments




 
Search this Thread

Coding a "Highest High of an open position"

  #1 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1

Hi there!

I was wondering if anyone could point me in the right direction here. I'm looking to code something that references the highest high or lowest low price of an open position.

I know there's
 
Code
Highest (Price, Length) & Lowest (Price, Length)
and then
 
Code
MaxPositionProfit
, but the first references "x number of bars ago," and the 2nd references profit, not the "high/low price" of a currently open position.

Any advice or tips would be greatly appreciated! Much thanks - Brandon

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Better Renko Gaps
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Build trailing stop for micro index(s)
Psychology and Money Management
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
25 thanks
The Program
20 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #3 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623


Brandon,

you could convert the MaxPositionProfit back to a price value for example, as you know the point value of the symbol, your position size and the entry price for each trade. This could become problematic in case you scale in and out of positions.
In that case you would have to track the high your self with a variable. You would have to reset the variable when you are flat or once at the beginning of each trade. Then while you are in a trade and every time the high is higher than the value stored in your variable, you would update the variable to store the high.

Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #4 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

Alternatively have a bar counter, every time you enter a trade/send a market order reset the counter, and then just calculate highest(high,barcounter)?

Reply With Quote
Thanked by:
  #5 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1

Just to revisit this idea, would making the "Highest High or Lowest Low" of a position a variable work? Below is meant to show the Highest or Lowest price of an open position.

ex:
 
Code
Variables:
ioHighestHigh (0),
ioLowestLow   (0);

ioHighestHigh  = Highest (H, EntryPrice) ;
ioLowestLow   = Lowest  (L, EntryPrice) ;

Reply With Quote
  #6 (permalink)
 
SMCJB's Avatar
 SMCJB 
Houston TX
Legendary Market Wizard
 
Experience: Advanced
Platform: TT and Stellar
Broker: Advantage Futures
Trading: Primarily Energy but also a little Equities, Fixed Income, Metals and Crypto.
Frequency: Many times daily
Duration: Never
Posts: 5,041 since Dec 2013
Thanks Given: 4,375
Thanks Received: 10,192

Highest (Function)

The Highest function returns the highest price over a range of bars.

Syntax
Highest(Price, Length)

Returns (Double)
The highest Price found over a range of Length bars.

Parameters

Price
Numeric
Specifies which bar value (price, function, or formula) to evaluate.

Length
Numeric
Sets the number of bars to consider.

For

ioHighestHigh = Highest (H, EntryPrice) ;

to reference the highest high or lowest low price of an open position, EntryPrice would need to be the number of bars since you opened the position.

Reply With Quote
Thanked by:
  #7 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

djvie11,

you could check if using BarsSinceEntry instead of the EntryPrice will give you what you are looking for.

Regards,

ABCTG


djvie11 View Post
Just to revisit this idea, would making the "Highest High or Lowest Low" of a position a variable work? Below is meant to show the Highest or Lowest price of an open position.

ex:
 
Code
Variables:
ioHighestHigh (0),
ioLowestLow   (0);

ioHighestHigh  = Highest (H, EntryPrice) ;
ioLowestLow   = Lowest  (L, EntryPrice) ;


Follow me on Twitter Reply With Quote
Thanked by:
  #8 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1


ABCTG View Post
djvie11,

you could check if using BarsSinceEntry instead of the EntryPrice will give you what you are looking for.

Regards,

ABCTG

Just back to revisit this idea!

So I wrote a variable to make my "Highest High" and "Lowest Low." I did this because I don't want a limitation as to how many bars back it'll reference ( ie, Highest (H, bars back) ;

Here's what I have below. It doesn't seem to be working as I expected and wanted to get some feedback if you guys have the time!
 
Code
Variables:
io_HighestHigh (0),
io_LowestLow   (0);

IF MarketPosition = 0 THEN BEGIN // this is to reset the variable as it's not used to enter into a position
io_HighestHigh = 0 ;
io_LowestLow   = 0 ;
END ; 

IF MarketPosition <> 0 THEN BEGIN
io_HighestHigh  = H of data1 ;
io_LowestLow   = L of data1 ;
IF H of data1 > io_HighestHigh  then io_HighestHigh = H of data1 ;
IF L of data1 < io_LowestLow   then  io_LowestLow   = L of data1 ;
END ;
Does the above make sense? Thanks for your time!

-Brandon

Reply With Quote
  #9 (permalink)
 ABCTG   is a Vendor
 
Posts: 2,431 since Apr 2013
Thanks Given: 481
Thanks Received: 1,623

Brandon,

when you constantly set the highest high to the High of the bar (and vice versa for the low) while you are in a position:
 
Code
io_HighestHigh  = H of data1 ;
io_LowestLow   = L of data1 ;
How can the check you do within the "if... then"... ever become true?
 
Code
 
IF H of data1 > io_HighestHigh  then io_HighestHigh = H of data1 ;
IF L of data1 < io_LowestLow   then  io_LowestLow   = L of data1 ;
Regards,

ABCTG

Follow me on Twitter Reply With Quote
Thanked by:
  #10 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1



ABCTG View Post
Brandon,

when you constantly set the highest high to the High of the bar (and vice versa for the low) while you are in a position:
 
Code
io_HighestHigh  = H of data1 ;
io_LowestLow   = L of data1 ;
How can the check you do within the "if... then"... ever become true?
 
Code
 
IF H of data1 > io_HighestHigh  then io_HighestHigh = H of data1 ;
IF L of data1 < io_LowestLow   then  io_LowestLow   = L of data1 ;
Regards,

ABCTG

Ah, good point! I think if I make the highestHigh/LowestLow an average initially (or anything else besides H/L of data1) it should work then.

I appreciate the response!

Reply With Quote




Last Updated on June 1, 2017


© 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