PureBytes Links
Trading Reference Links
|
I have had this same problem in the past. The issue is that internally, TS
doesn't remember variable values with any more granularity than the current
bar (doesn't remember what happened on the last tick of the current bar). I
made a simple DLL and TS function to get around this problem. I am attaching
it to this post. This is for 16 bit TS4. You must copy the DoOnce16.DLL file
into your \Omega\Prog\ directory.
{--------------------}
{Function DoOnce}
{When DoOnce returns True, it means no Alert has occurred on the current bar
yet}
Inputs: Symbol(NumericSimple);
DefineDLLFunc:"DoOnce16.DLL",LONG,
"DoEvent",Long,{Symbol Number}
LONG;{Bar Time}
Value1 = DoEvent(Symbol, Time);
if Value1 = 1 Then DoOnce = True Else DoOnce = False;
{End of Function DoOnce}
{--------------------}
To test the function I created a simple Indicator:
{-----------------------}
{Indicator AlertOnce}
Inputs: SymNum(1100); {Add this input to your existing Indicator/System
Code}
{Prep the DoOnce Function}
If CurrentBar = 1 then Condition1 = DoOnce(SymNum);
if LastBarOnChart = True then begin
{Some Simple Condition is met}
If Close > Open Then Begin
if DoOnce(SymNum) Then Alert = True;
end;
end;
if 1 = 0 then Plot1(0,"Bogus"); {Every indicator needs a plot statement}
{End Indicator AlertOnce}
{----------------------------}
You can use the DoOnce function on multiple graphs, just change the Symbol #
to a unique number on each chart where you call this function. The DoOnce
Function is designed to return True the first time a condition is met on the
current bar and false every time thereafter on the current bar. Make sure to
enable your indicators to update on every tick.
Enjoy!
I take no responsibility for how you use any of this material. It has not
been designed for any specific purpose other than to illustrate how to make
an alert only do once per bar. Use at your own risk! This program contains
no warrantees or guarantees of any kind. I disclaim any and all losses you
might incur through the use of this program in actual trading.
Patrick White
Copyright 2001 Patrick White.
begin 666 DOONCE16.DLL
M35H*``(````$``\`__\``, `````````0 ``````````````````````````
M````````````````````D ```+0)NA `#A_-(;@!3,TAD)!4:&ES('!R;V=R
M86T@;75S="!B92!R=6X@=6YD97(@36EC<F]S;V9T(%=I;F1O=W,N#0HD````
M````````````3D4&`+4`$ ``````"8 #```$``#T``$````#``0`!0`.`$ `
M8 !@`'0`?@!5`0```@`(`````@`````````*`P(`<0U0$7$-`````-$0`0`2
M`"@!40`F"!0`H )0$* "!D1/3TY#10``!T1/159%3E0"```!``4`# `1`!D`
M``-'1$D&2T523D5,!%5315('5TE..#=%30A/3$4R1$E34 9&4$E.250&1E!4
M15)-!D9034%42 +_`\T_`60%`\T_!)8````*1$]/3D-%+D1,3 ```*JJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJH``.FG!NFD!NFA!NF>!NF;!NF8!NF5!NF2!O__
M____________________________________________________________
M_________P`"( #__P``__\``/__``#__P``__\``/__``#__P``__\``/__
M``#__P``__\``/__``#__P``__\``/__``#__P``__\``/__``#__P``__\`
M`/__``#__P``__\``/__``#__P``__\``/__``#__P``__\``/__``#__P``
M__\``/__``#__P``__\``/__``#__P``__\``/__``#__P``Z,8`QP9 !0``
M+O<&,@<$`'5?_P9 !2[_'IP`"\!T2XD.1 6)%CX%B1XT!8P&-@x)/D8%B39(
M!8P&+@xxxxxx`*,P!8D6,@57,\!0+O\>Y `N_QZ8``O =!'HW #H60!R"?\.
M0 4>Z$$`'Z! !;1,S2&)-C0%C 8V!8D.1 6)/D8%QP9(!0``+O\>< "C, 6)
M%C(%Z*(`Z!\`<@O_!D %51[H!@`?7:% !<N))D(%Z#L#ZHH`___+R^@!`,.
M/CP%`W(!P[@$`</#G%%65P;]BPX8``,.( "^* `#\4Z+/AP``_E/'@?SI+D8
M`+\A!_.D!U]>69W#_#/ BPX*!XL^#@<>!_.JZ"D)P_QFQP8@```````>#AX'
M'S/ N4X`OYP$\ZI(N0@`O^H$\ZJY#@"^. "_\@3SI1_#,\"C. 6T,,TAAL2C
M.@xx! #H(0##G%18.\2P`742G%@x`$!0G9Q8J0! L )T`K #HCP%G<.["P`N
M_Q[P``O =!Z##C@%`KL%`"[_'O `HX(%)4#@HX0%NPD`+O\>\ ##+O<&,@<@
M`'0#Z!0$BR9"!<,*P'4"L 7I$@3H0?_H4?^X,A/H"O]:63/ 4(OL@^PB4%!0
M4%%2RP"L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
MK :L!JP&K :L!JP&K ; !\L(K :L!HP"B J=`JP&K :L!JP&K :L!JP&K :L
M!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
M7 VL!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&I@*L!JP&K :L
M!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
MK :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L
M!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
MK :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L
M!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
MK :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L
M!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&
MK :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&K :L!JP&BP`QNC$?K#\*
M``YDX?^,R+D'`;[$`K^ `!X>!X[8_*6KXOP?PV2*!":(!49'"L!U],.I#P!T
M!>@"`$##T>C1Z-'HT>C#4%-14FH`+O\>J !:65M8PSQA<@8\>G<"-"##4P8/
MH.@%``^A!UO#:$(@9E N_QZ ``O =!-04"[_'HP`60O =0>+P@x = '#L ?Y
MPP",V)!5B^P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``,!N `#`&4`
M`P&\``,`;P`#`< ``@!K``,!Q `#`!8``P'(``(`NP`#`<P``@"]``,!T `#
M`.@``P'4``4`! `#`=@`!0`&``,!W `%``<``P'@``,`<0`#`>0``@`>``,!
MZ `"`*8``P'L``(`'0`#`? `! `!``(`'@`$````JJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJ``````````````````````0````B!P``Y ``
M`"8'```<````"@@````````!``@!``````````````0`````````````````
M````````````````````````````````````````````````````````````
M```````````````````````````````````````````````````````!``@!
M``````````````0`````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````````````/____\``@``( ````````#_____``````$```"J
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
MJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJKX]P;@!/__=0[#
MG/CW!N $__]U`IW#G>L+P\-W!2O"> '#L E:#E+_+@x!"])U!0KD=0'#L ;K
M[ O2>/C#48O*F3O*677NPPO >.D+TG7EPU",P O#6'0!P[ )Z\=F468/M\IF
M,])F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