Coding a "Highest High of an open position" - EasyLanguage Programming | futures io social day trading
futures io futures trading


Coding a "Highest High of an open position"
Updated: Views / Replies:1,324 / 29
Created: by djvie11 Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors – all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you don’t need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Coding a "Highest High of an open position"

  #21 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 44 since Jul 2013
Thanks: 26 given, 1 received

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!!

 
Code
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 ;


Last edited by djvie11; May 30th, 2017 at 12:44 AM.
Reply With Quote
 
  #22 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received

Brandon,

it appears you have an incorrect understanding of the "maximum number of bars the study will reference" feature.

You can read more here under the two links:
Maximum Number of Bars Study Will Reference Setting
https://www.multicharts.com/trading-software/index.php/Default_Study_Properties#Setting_Default_Maximum_Bars_Back

They are just for initial calculations, before your code actually starts displaying/trading.

Regards,

ABCTG


djvie11 View Post
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
 
  #23 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received


Brandon,

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

 
Code
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 ;


Reply With Quote
The following user says Thank You to ABCTG for this post:
 
  #24 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 44 since Jul 2013
Thanks: 26 given, 1 received


ABCTG View Post
Brandon,

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!

 
Code
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) ;

Reply With Quote
 
  #25 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received

Brandon,

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"?

Regards,

ABCTG

Reply With Quote
 
  #26 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 44 since Jul 2013
Thanks: 26 given, 1 received

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

Reply With Quote
 
  #27 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received

djvie11,

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).

Regards,

ABCTG

Reply With Quote
 
  #28 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received


djvie11 View Post
[...] like the variables aren't updating on higher highs/ lower lows (i.e., they only update once throughout each trade). [...]

Brandon,

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

Reply With Quote
 
  #29 (permalink)
Trading Apprentice
Chicago, IL
 
Futures Experience: Advanced
Platform: Tradestation + Multicharts
Favorite Futures: Forex, Futures
 
Posts: 44 since Jul 2013
Thanks: 26 given, 1 received


ABCTG View Post
Brandon,

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


 
Code
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 ;

Reply With Quote
 
  #30 (permalink)
Market Wizard
Hamburg Germany
 
Futures Experience: Advanced
Platform: Multicharts, Tradestation, Multicharts.NET, NinjaTrader, MetaTrader
Broker/Data: DTN IQ
Favorite Futures: ES
 
Posts: 1,604 since Apr 2013
Thanks: 242 given, 896 received


Brandon,

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?

Regards,

ABCTG

Reply With Quote
The following user says Thank You to ABCTG for this post:

Reply



futures io > > > > > Coding a "Highest High of an open position"

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)
 

Brett Steenbarger: Current Best Practices of Best Traders

Elite only

CME Group: Futures & Bitcoin

Elite only

Ran Aroussi: TBA [special time 11AM ET]

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
"Extremes", "highest/lowest" functions affecting maxbarback LastSyndrome Elite EasyLanguage Automated Trading 3 September 1st, 2012 06:38 AM
Fukushima: "China Syndrome Is Inevitable" ... "Huge Steam Explosions", or "Nuclear Bo Quick Summary News and Current Events 0 November 22nd, 2011 02:50 AM
How to change "Stop Loss" and "Take Profit" in "shElderImpulse" Strategy javed759 NinjaTrader 1 November 1st, 2011 11:44 PM
"misery index" rises to highest since 1983 kbit News and Current Events 0 October 20th, 2011 12:29 PM
Coding required for "High Probability Trading Setups" Manfred MetaQuotes MetaTrader MQL Programming 2 September 9th, 2011 08:10 AM


All times are GMT -4. The time now is 06:59 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2018-02-22 in 0.15 seconds with 19 queries on phoenix via your IP 54.221.131.67