Open Condition -- Need Advanced Programming Help

 

Hi Experts,

I've been attempting to program my open order condition based upon the following criteria as an example:

1. A cross of some sort (Ex. MA cross):

a) at the point of cross, it needs to make a time stamp (or bar stamp // or similar) to mark the place where cross takes place.

b) When this bar closes, it needs to recorded the close of the cross bar (not the close when the cross occurs)(i.e. if cross happens @ 10:10:10 and your using 1m chart, it will record the close of 10:10 @ 10:11)

2. Once a Close Price is recorded:

a) a Counter needs to be establish to count (to a limit) the number of bars since the cross.

b) The Condition is met when, in case of long open, a current Close higher than the recorded close is reached and vice versa lower close on short before the limit is reached

The problem I'm having is that I use Global static variables for the time stamp, Close Price, and Counter. In doing this, upon each new bar it records new information if the condition remains true.

I.E. 1 min Chart: MA Cross @ 10:10 Recorded itime/time[0] = 12345667

next bar: Close recorded: 1.1111, Counter=1

next bar: conditions remain true so in my case it now records a new timestamp, close, counter=1;

BUT I want: next bar: conditions remain -- Time stamp remains original, Close Price remains original .... and it looks for the final condition to be met which is a higher close.

Any help would be greatly appreciated,

Thanks,

SaxMan

 

I Fixed my Issue

Hi Everyone,

I fixed my issue. The basic problem I had was using itime/time. I replaced this with Bars since the increment for Bars is +1 whereas itime/time varies based upon timeframe used.

If you would like to know how I accomplished this please post a reply... otherwise I'll not bother.

Have a good one,

SaxMan

 

Please post or PM

This looks similar to a problem I am trying to solve. Your solution could help.

Thanks.

Reason: