Check for no exit in prior period

jackie540

Junior member
Messages
13
Likes
1
Hi, everyone:

Can anyone help me with how to code conditon for no exit in the prior period?

Thanks
 
I would try, but I have not the slightest clue what you are even talking about here ???
 
I'm attempting to code in EL how to check that I haven't exited a position in the prior period/bar/interval. If marketposition = 1 or 0, or -1 tells me if I have a long, no or short position respectively for the current bar, then marketposition(1) tells me if I have a position for the prior bar. BUT, would I simply check marketposition(1) = 0 to see if I exited the prior period, thinking that if marketposition(1) = 0 I have no position therefore I didn't exit a position? Thanks to all my readers.
 
A common coding concept in EL is to do the following

variables:
MP ( 0 ) ;

MP = MarketPosition ;

if MP <> MP [ 1 ] and MP = 0 then ... This says that I have just changed position but now am flat
if MP <> MP[ 1] and MP[ 1 ] = -1 then ... This says I have just changed position and I WAS short
if MP <> MP[ 1 ] and MP[ 1 ] = 1 then ... This says I have just changed position and I WAS long
if MP <> MP[ 1] and MP = -1 then ... This says I have just changed position and I AM short
if MP <> MP[ 1 ] and MP = 1 then ... This says I have just changed position and I AM long


MarketPosition( 1 ) is not as you describe it. That would say that your last closed out trade was ??? That could be one bar or 100 bars ago.

Greg
 
StratOpt/Greg:

First, thank you so much!

Can you help me with how MP[1] relates to bar interval? If I'm trying to check if my MP occured one bar ago, can I do that? Or can you potentially get multiple MPs in one bar interval?

Thanks!
 
Sure the square brackets in EL is called an executive offset. What this basically means is that it will check N bars back from the current bar so if you put in a [ 1 ] then that refers to the value of the variable on the previous bar. If you use a [ 5 ] then this refers to the bar 5 bars before the current bar. The only way you can get more than one MP in a bar interval with your strategy is if you write it that way using intrabarpersistant variables. The [ 1 ] works wonders and you will use this sort of thing so often in your code writing that it will become second nature

want to check to see if a bar is the first bar of a new day .... if date <> date[ 1 ] then begin ....
 
Top