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)
And if it helps to see what I'm talking about, this is the whole thing. Can you see anywhere it wouldn't be updating properly? Or do you think this is more of a job for a couple Arrays? Thanks for your time again!!
Can you help answer these questions from other members on NexusFi?
I am sorry, but I don't understand why you do what you do within your code. Why the multiple resets?
Why still resets while in a position?
You might want to add some comments to your code blocks, explaining why you do what you do.
From the code I would say, you are not getting what you have in mind.
I would strongly suggest to use the print reserved word and check when your code resets variables and what happens bar by bar within your code.
Regards,
ABCTG
djvie11
And if it helps to see what I'm talking about, this is the whole thing. Can you see anywhere it wouldn't be updating properly? Or do you think this is more of a job for a couple Arrays? Thanks for your time again!!
Variables:
EnterHighestHigh (0) ,
EnterHighStore (0) ,
EnterLowestLow (0) ,
EnterLowStore (0) ,
ExitHighestHigh (0) ,
ExitHighStore (0) ,
ExitLowStore (0) ,
ExitLowestLow (0) ;
IF MarketPosition <> 0 THEN BEGIN
EnterHighStore = 0 ;
EnterLowStore = 0 ;
EnterHighestHigh = 0 ;
EnterLowestLow = 0 ; END ;
If MarketPosition = 0 OR MarketPosition = 1 THEN BEGIN
ExitLowStore = 0 ;
ExitLowestLow = 0 ; END ;
If MarketPosition = 0 OR MarketPosition = -1 THEN BEGIN
ExitHighStore = 0 ;
ExitHighestHigh = 0 ; END ;
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 ;
IF MarketPosition = 1 THEN BEGIN
ExitHighStore = H of data1 ;
IF H of data1 > ExitHighStore THEN ExitHighStore = H of data1 ;
ExitHighestHigh = ExitHighStore ; END ;
If MarketPosition = -1 THEN BEGIN
ExitLowStore = L of data1 ;
IF L of data1 < ExitLowStore THEN ExitLowStore = L of data1 ;
ExitLowestLow = ExitLowStore ; END ;
I am sorry, but I don't understand why you do what you do within your code. Why the multiple resets?
Why still resets while in a position?
You might want to add some comments to your code blocks, explaining why you do what you do.
From the code I would say, you are not getting what you have in mind.
I would strongly suggest to use the print reserved word and check when your code resets variables and what happens bar by bar within your code.
Regards,
ABCTG
Hello again, ABCTG!
I am now convinced I need to be using Arrays to capture the data I need so I can retrieve it at a later time in the chart. This is my first time using arrays. I've scoured all the information out there and have come up with the code below. It compiles just fine but when I apply it to the chart it gives me an error message: Message: Error in Study... Array bounds. Wrong index value: 1. Any idea why?
I just want my arrays to do 2 things:
1) capture each new High or Low to use at a later date (either data1 or data2)
2) reset each Array value depending on MarketPosition
As always, your input is greatly appreciated!
Array:
intrabarpersist HighOfData2[](0) , //Dynamic arrays are the best option as I don't know how many values will be stored
intrabarpersist LowOfData2 [](0) ,
intrabarpersist HighofData1[](0) ,
intrabarpersist LowOfData1 [](0) ;
IF MarketPosition <> 0 THEN BEGIN // I'm trying to reset the Array's value's here
Array_SetValRange (HighofData2,0 ,0, 0) ;
Array_SetValRange (LowofData2, 0 ,0, 0);
END ;
If MarketPosition = 0 OR MarketPosition = -1 THEN BEGIN // I'm trying to reset the Array's value's here
Array_SetValRange (HighOfData1, 0, 0, 0) ;
END ;
If MarketPosition = 0 OR MarketPosition = 1 THEN BEGIN // I'm trying to reset the Array's value's here
Array_SetValRange (LowOfData1, 0, 0, 0 ) ;
END ;
HighofData2[0] = H of data2 ; //Looking input each new high (or Low) into the dynamic array
LowofData2 [0] = L of data2 ;
HighofData1[0] = H of data1 ;
LowofData1 [0] = L of data1 ;
Value1 = HighestArray (HighofData2, 0) ; // Looking to pull out the highest high off all the recorded information in this array
Value2 = LowestArray (LowOfData2, 0) ;
Value3 = HighestArray (HighofData1, 0) ;
Value4 = LowestArray (LowofData1, 0) ;
why are you now convinced that you need to use Arrays? Based on what you wrote before, I don't see the need to make it unnecessarily complex.
What were your findings when you applied the print reserved word to your code to "check when your code resets variables and what happens bar by bar within your code"?
I believe arrays are the way to go because the trades are not adding up with variables. When I manually calculate them they're acting much different - like the variables aren't updating on higher highs/ lower lows (i.e., they only update once throughout each trade).
The print log statement I'm using is "Print( File(“c:\Users\Brandon\Desktop\MyPRINT.txt”),
Date, Time, Close);" - but I'm not getting any useful information from that. To be honest, I haven't used the print function often.
Can you suggest better print parameters that would help me decode this a bit better? Much thanks!
-brandon
it matters more where you place the print statements in the code - best at multiple times to "check when your code resets variables and what happens bar by bar within your code".
So you will need something to distinguish between the different print statements (i.e. a string that tells you which print statement was responsible for what print exactly).
Other than that you'll need the time and date as you do it already. You just might want to change the date format to something more user friendly, but if and how you do that is up to you (and the platform you use).
that's not a problem of the variables, but because your code tells the platform to do that. The print statements will show you were it goes wrong.
Regards,
ABCTG
Man, the print function is pretty awesome! So my suspicions were correct (it's not working properly). Obviously it's because I have it coded wrong. Below is the code, and I also copy/pasted several instances on why it's not working correctly. Can you see anything I may have missed here?
ex1:[ EnterHigh is only supposed to change with a HIGHER high, EnterLow should only change when LOWER]
EnterHigh 1.3787 / ExitHigh -1000.0000 / EnterLow 1.3683 / ExitLow 1000.0000
EnterHigh 1.3787 / ExitHigh -1000.0000 / EnterLow 1.3640 / ExitLow 1000.0000
EnterHigh 1.3787 / ExitHigh -1000.0000 / EnterLow 1.3683 / ExitLow 1000.0000
EnterHigh 1.3793 / ExitHigh -1000.0000 / EnterLow 1.3640 / ExitLow 1000.0000
EnterHigh 1.3787 / ExitHigh -1000.0000 / EnterLow 1.3683 / ExitLow 1000.0000
ex2:[ If EnterHigh is populated with a number, so should EnterLow ]
EnterHigh 1.3516 / ExitHigh -1000.0000 / EnterLow 0.0000 / ExitLow 1000.0000
EnterHigh 1.3516 / ExitHigh -1000.0000 / EnterLow 0.0000 / ExitLow 1000.0000
EnterHigh 1.3516 / ExitHigh -1000.0000 / EnterLow 0.0000 / ExitLow 1000.0000
EnterHigh 1.3516 / ExitHigh -1000.0000 / EnterLow 0.0000 / ExitLow 1000.0000
ex3:[ExitHigh should only change if it makes a HigherHigh ]
EnterHigh -1000.0000 / ExitHigh 1.3757 / EnterLow 1000.0000 / ExitLow 1000.0000
EnterHigh -1000.0000 / ExitHigh 1.3754 / EnterLow 1000.0000 / ExitLow 1000.0000
EnterHigh -1000.0000 / ExitHigh 1.3728 / EnterLow 1000.0000 / ExitLow 1000.0000
EnterHigh -1000.0000 / ExitHigh 1.3757 / EnterLow 1000.0000 / ExitLow 1000.0000
ex4: [ Example of ExitLow going up instead of only down ]
EnterHigh -1000.0000 / ExitHigh -1000.0000 / EnterLow 1000.0000 / ExitLow 1.3640
EnterHigh -1000.0000 / ExitHigh -1000.0000 / EnterLow 1000.0000 / ExitLow 1.3683
Variables:
EnterHighestHigh (0) ,
EnterLowestLow (0) ,
ExitHighestHigh (0) ,
ExitLowestLow (0) ;
IF MarketPosition <> 0 THEN BEGIN
EnterHighestHigh = -1000 ;
EnterLowestLow = 1000 ; END ;
If MarketPosition = 0 OR MarketPosition = -1 THEN BEGIN
ExitHighestHigh = -1000 ; END ;
If MarketPosition = 0 OR MarketPosition = 1 THEN BEGIN
ExitLowestLow = 1000 ; END ;
IF MarketPosition = 0 THEN BEGIN
IF H of data2 > EnterHighestHigh THEN EnterHighestHigh = H of data2 ;
IF L of data2 < EnterLowestLow THEN EnterLowestLow = L of data2 ; END ;
IF MarketPosition = 1 THEN BEGIN
If H of data1 > ExitHighestHigh THEN ExitHighestHigh = H of data1 ; END ;
If MarketPosition = -1 THEN BEGIN
IF L of data1 < ExitLowestLow THEN ExitLowestLow = L of data1 ; END ;
I don't know where you put the prints, so I can't tell. However with using the print statement you have a great way of finding out what is going on internally.
Include one at every point in your code where you reset/update your tracking variables. Then look at the results and ask yourself if this update/result is actually occurring where I want it to happen and if this helps you in getting what you want.
One question could be: Does it help me if I reset my tracking variables constantly while I am long or short? Can I track the high/low of a position this way or would I lose the information with every reset?