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 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."
<---- 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?
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?
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:
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.
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:
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).
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
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 …
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.
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!!
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 ;