[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EOF?



PureBytes Links

Trading Reference Links

I'm not quite sure where to begin. I have a feeling you are missing some
key concepts. I suggest downloading the EL manual and giving it a good
read. 

http://www.tradestation2000i.com/support/guide/default.shtm

Random thoughts....

TS runs your code on every bar unless you tell it not to. It starts at
the beginning and works its way forward in time until it gets to the
last bar. Realtime, it will pause there until data comes in for a new
bar and then it runs again.

TS can't look forward, only back. Logical when you think about it.
Realtime, you don't know the future.

Previous values of variables or prices are represented with square
brackets. Close[10] is the closing price 10 bars ago.

I'm don't what you are trying to do with your code.

While CurrentBar <> LastBar
Begin
  mDiff = MA10 - MA20;
  If mDiffMax < mDiff Then mDiffMax = mDiff;
End;

If you want to keep track of the highest MDiffMax as the code walks
forward through the bars, you don't need a loop.

mDiff = MA10 - MA20;
If mDiffMax < mDiff Then mDiffMax = mDiff;

will do the job fine, with the understanding that MDiffMax will grow as
the code moves forward through the bars.

If you only want to know the biggest difference in say the last 20 bars
prior to the bar being calculated, you could do

mDiff = MA10 - MA20;
mDiffMax = 0;
for count = 0 to 20 begin
  If mDiffMax < mDiff[count] Then mDiffMax = mDiff[count];
end;

or you could just use the built-in Highest function. Open Highest in
power editor and you will see they have coded the loop for you.

mDiff = MA10 - MA20;
mDiffMax = Highest(mDiff,20);

What you CAN'T do, is be working on a bar in the middle of the chart and
look ahead to know the highest value of mDiff in the future.

If you want to work all the way through the chart before you do your
final calcs, you can use the LastBarOnChart function. Opening that one
in power editor will show it's just shorthand for

if date = lastcalcdate and time = lastcalctime....

Anyway, you could do something like

mDiff = MA10 - MA20;
If mDiffMax < mDiff Then mDiffMax = mDiff;
If LastBarOnChart then begin
  {whatever};
End;

Those are some raw basics. Download the manual and you'll pick it up
quickly.
  
-- 
  Dennis





  • References:
    • EOF?
      • From: John Wood