Close On Prior Tick

Questions about MultiCharts and user contributed studies.
tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Close On Prior Tick

Postby tony » 20 May 2014

I was hoping someone could help me with this. I can't figure it out for the life of me. I am using IOG=True and I want to calculate the close on the last tick not the close on the last bar. Ultimately what I want to do is buy on a downtick and sell on an uptick.

Thank You in advance for any help.

Tony

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: Close On Prior Tick

Postby SUPER » 20 May 2014

I was hoping someone could help me with this. I can't figure it out for the life of me. I am using IOG=True and I want to calculate the close on the last tick not the close on the last bar. Ultimately what I want to do is buy on a downtick and sell on an uptick.

Thank You in advance for any help.

Tony

Code: Select all


Var: PriorClose(0),CurrentClose(0);

PriorTick = CurrentClose;
CurrentClose = C;

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Close On Prior Tick

Postby tony » 20 May 2014

I'm not having luck with that. Here's what I wrote

IntraBarPersist PriorClose ( 0 ),
IntraBarPersist Current Close ( 0 ),

PriorClose = CurrentClose;
CurrentClose = C;

// you had written PriorTick = CurrentClose and I assume you meant PriorClose not PriorTick. PriorTick is not a reserved word that I can see so essentially this is simply saying PriorClose = C which if I am mistaken is not calculating the prior tick but rather the current close.

User avatar
Smoky
Posts: 507
Joined: 03 Dec 2010
Location: Thailand
Has thanked: 97 times
Been thanked: 115 times

Re: Close On Prior Tick

Postby Smoky » 21 May 2014

I am mistaken is not calculating the prior tick but rather the current close.
with IOG=true, last tick is always last close.
to do your job :

IntraBarPersist PriorClose ( 0 );

// start of your code working with PriorClose

//end of your code

//last line
PriorClose = C;

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Re: Close On Prior Tick

Postby SUPER » 21 May 2014

I'm not having luck with that. Here's what I wrote

IntraBarPersist PriorClose ( 0 ),
IntraBarPersist Current Close ( 0 ),

PriorClose = CurrentClose;
CurrentClose = C;

// you had written PriorTick = CurrentClose and I assume you meant PriorClose not PriorTick. PriorTick is not a reserved word that I can see so essentially this is simply saying PriorClose = C which if I am mistaken is not calculating the prior tick but rather the current close.
tony,

Your code is correct I typed in hurry, if you add print statement at bottom of your code you will observe that it works so does smoky’s suggestion.

tony
Posts: 420
Joined: 14 Jun 2013
Has thanked: 30 times
Been thanked: 81 times
Contact:

Re: Close On Prior Tick

Postby tony » 21 May 2014

Thank you Smoky and Super (and Andrew from a prior email). Conceptually it was not making sense to me, but now I understand how it works. The help is much appreciated.

Tony


Return to “MultiCharts”