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"

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

djvie11,

why do you want to do that?

Regards,

ABCTG


djvie11 View Post
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!


Follow me on Twitter Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Online prop firm The Funded Trader (TFT) going under?
Traders Hideout
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
Deepmoney LLM
Elite Quantitative GenAI/LLM
Futures True Range Report
The Elite Circle
ZombieSqueeze
Platforms and Indicators
 
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
37 thanks
GFIs1 1 DAX trade per day journal
22 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
  #12 (permalink)
djvie11
Chicago, IL
 
Posts: 52 since Jul 2013
Thanks Given: 29
Thanks Received: 1


ABCTG View Post
djvie11,

why do you want to do that?

Regards,

ABCTG

I'm just trying to track the "Highest High or Lowest Low" since the start of an open position without the limitation of having to deal with "bars back."

 
Code
Highest (H, bars back)
<---- I don't want to reference bars back, because what if it's been many more bars back since the open of my position than the code is referencing?

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


djvie11,

I was referring to "I think if I make the highestHigh/LowestLow an average initially (or anything else besides H/L of data1) it should work then."

You are on the correct way with your tracking, apart from where you reset the values at MarketPosition = 0 and this code:
 
Code
io_HighestHigh  = H of data1 ;
io_LowestLow   = L of data1 ;
It looks okay.
Think about what will happen when you set io_LowestLow to 0 at reset and check for "L of data1 < io_LowestLow" later.

Also consider how your code would/should reset the values in case of a reversal.

Regards,

ABCTG

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


ABCTG View Post
djvie11,

I was referring to "I think if I make the highestHigh/LowestLow an average initially (or anything else besides H/L of data1) it should work then."

You are on the correct way with your tracking, apart from where you reset the values at MarketPosition = 0 and this code:
 
Code
io_HighestHigh  = H of data1 ;
io_LowestLow   = L of data1 ;
It looks okay.
Think about what will happen when you set io_LowestLow to 0 at reset and check for "L of data1 < io_LowestLow" later.

Also consider how your code would/should reset the values in case of a reversal.

Regards,

ABCTG

Hi again, ABCTG!

So here's my code:

 
Code
Variables: 
enterHighestHigh = 0 ;
enterHighStore1  = 0 ;
enterHighStore2  = 0 ;
enterLowestLow   = 0 ;
enterLowStore1   = 0 ;
enterLowStore2   = 0 ;


IF MarketPosition = 0 THEN BEGIN
EnterHighStore1 =  H of data2 ; 
EnterHighStore2 =  H of data1 ;

EnterLowStore1 =  L of data2 ; 
EnterLowStore2 =  L of data1 ; 

IF EnterHighStore1 > EnterHighStore2 THEN enterHighestHigh = EnterHighStore1 ;
IF EnterHighStore2 > EnterHighStore1 THEN enterHighestHigh = EnterHighStore2 ;

IF EnterLowStore1 < EnterLowStore2 THEN enterLowestLow = enterLowStore1 ;
IF EnterLowStore2 < EnterLowStore1 THEN enterLowestLow = enterLowStore2 ;
END ;
My question is this ..
I would like the "EnterStoreXXXX" to populate the variable only once.. and not keep updating (I,e, always keep the highest or lowest number as the variable stored & not update on a new bar's High or Low). Is this possible? The reason behind this is because I would like to reference the price once I've entered into a position. To clarify, I would ONLY like the variable to update upon a higher or lower number that's already in the variable's position.

Would simplifying this with "EntryPrice" be better? Or is there an advantage to having these variables?

Thanks for your time! - Brandon

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

Brandon,

I am sorry, but I don't understand what you are trying to do with your code as you update all the tracking variables while your are flat.
You almost had it in your previous code:

1. Reset the tracking variables while you are flat. To Something like:
 
Code
io_HighestHigh  = -999999 ;
io_LowestLow   = +99999 ;
for example.

2. Then while you are in a position update these variables when the high/low of a bar is higher/lower.

3. When not using intrabar order generation the market position change will be noticeable after the entry bar. For that situations you might want to use a boolean flag (that you also reset when flat) and use it to check for the last two bar's highs/lows on the first bar of each entry.

Regards,

ABCTG

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


ABCTG View Post
Brandon,

I am sorry, but I don't understand what you are trying to do with your code as you update all the tracking variables while your are flat.
You almost had it in your previous code:

1. Reset the tracking variables while you are flat. To Something like:
 
Code
io_HighestHigh  = -999999 ;
io_LowestLow   = +99999 ;
for example.

2. Then while you are in a position update these variables when the high/low of a bar is higher/lower.

3. When not using intrabar order generation the market position change will be noticeable after the entry bar. For that situations you might want to use a boolean flag (that you also reset when flat) and use it to check for the last two bar's highs/lows on the first bar of each entry.

Regards,

ABCTG

Thanks for all your responses, ABCTG!

I suppose what I'm asking is how to "Set and hold Variables conditionally." I found this section below on it, but it doesn't reference a variable that is indeed dynamic (say, The "High or Low of a bar" that would automatically update anyways when a new High/Low of the bar is made). I'm looking to take a "Snap Shot" of a high or low, insert that into the variable, and update it only when the "Snap Shot" is superseded.

Or maybe I'm wrong? Would something like the code below just take a "Snap Shot" of the High of data1 once, or would it consistently update because highs/lows indeed change? Meaning ... the "H of data1" maybe "10" right now .. but a few bars down the road it could very well be "5." I'm looking to keep that "10" in there until the high is greater than "10" (and so forth).
 
Code
Vars: io_HighestHigh (0) ;

io_HighestHigh = H of data1 ;
Setting and Holding Variables Conditionally

Variables hold their value from bar to bar until they are re-assigned, i.e., reset or recalculated. This allows
you to capture a value and hold it until needed. When doing this, the variable assignment statement is placed
inside a conditional so that the variable is set or calculated only when the condition is true. The variable holds
the new value until the next time the condition is true.

Usage Example:
Vars: Bar1Range(0);
if Date <> Date[1] then
Bar1Range = Range;

In this example, on the first bar of each day on an intraday chart, the variable Bar1Range will be set to the
range of that first bar. Bar1Range will retain that value until the first bar of the next day. Referring to
Bar1Range on any intraday bar will return the range of the first bar of that day

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

Actually, I think I found the solution in the Multicharts wiki:

Declare Min_Price as a numerical variable, tied to the series with Data #2, and the initial value equal to the value of Close function:
 
Code
Variable: Min_Price(Close,Data2);
Ie, instead of having

 
Code
Vars:
Min_Price (0);
You'd have
 
Code
Vars:
Min_Price (Close,Data2);
Or would you not be able to reset it once it's declared?

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

Brandon,

you are doing that in your post here already:

Now you just need to follow the steps I outlined in my last post and you should be able to arrive at the result you have in mind.

Regards,

ABCTG

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

Brandon,

you can reset any variable once it's declared and initialized.

Regards,

ABCTG


djvie11 View Post
Actually, I think I found the solution in the Multicharts wiki:

Declare Min_Price as a numerical variable, tied to the series with Data #2, and the initial value equal to the value of Close function:
 
Code
Variable: Min_Price(Close,Data2);
Ie, instead of having

 
Code
Vars:
Min_Price (0);
You'd have
 
Code
Vars:
Min_Price (Close,Data2);
Or would you not be able to reset it once it's declared?


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



ABCTG View Post
Brandon,

you can reset any variable once it's declared and initialized.

Regards,

ABCTG

So I've had a new revelation here .. the code below works, and I do "reset" all the variables when "MarketPosition <> 0".....
HOWEVER... I found that the more I increase the "maximum number of bars the study will reference" under the properties tab, the better the strategy performs.

I understand the concept that the strategy will only look back "x amount of bars," but that's why I wanted to create variables so it can "record" information as it happened so I can reference that information PAST the "maximum number of bars the study will reference"

Any ideas? Hopefully you're not getting tired of me yet!!

 
Code
Variables: EnterHighestHigh(0) , EnterHighStore(0) , EnterLowestLow(0) , EnterLowStore(0) ;

IF MarketPosition = 0 THEN BEGIN
EnterHighStore = H of data2 ;
EnterLowStore  = L of data2 ; 
IF H of data1 > EnterHighStore THEN EnterHighStore = H of data1 ;
IF L of data1 < EnterLowStore  THEN EnterLowStore  = L of data1 ; 
EnterHighestHigh = EnterHighStore ; 
EnterLowestLow   = EnterLowStore ; END ;

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