PureBytes Links
Trading Reference Links
|
Thanks Graham,
But I think StaticVarSet("aaa",lastvalue(Longentry)); will also set the static var to 'false' when Longentry is false...
I want the staticvar to be set 'true' if longentry is ever true, and then only reset when there's a longExit signal..)
Wes
----- Original Message ----
From: Graham <kavemanperth@xxxxxxxxx>
To: amibroker@xxxxxxxxxxxxxxx
Sent: Friday, January 12, 2007 4:05:04 PM
Subject: Re: [amibroker] Help with Static vars
there are easier ways without the IF's
LongEntry = C > Ref(H,-1) ;
LongExit = C < Ref(L,-1) ;
StaticVarSet("aaa",lastvalue(Longentr y));
Longlatch = (Longentry OR StaticVarGet("aaa"));
--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriti ng.com
On 13/01/07, wes_zoltran2 <wes_zoltran@ yahoo.com> wrote:
I'm trying to learn Static vars
The example I'm using is to form a 'Latch' type function, similar to
FLIP, for use in RT trading. (see dicussion last week in the
amibroker-at group).
The goal is to 'latch' a condition as true, once it has occurred,
regardless if the condition becomes false later in the curent bar
For example, if price > prior close. The normal FLIP doesn't work in
RT, as the condtion may vary during the bars life, and flip() only
"latches" at bar close time.
So here's the original code example using flip..
--
LongEntry = C > Ref(H,-1) ;
LongExit = C < Ref(L,-1) ;
/* The following 'Flip' doesn't work in RT.
It will vary with the condition, until the bar closes */
inlong = Flip(Longentry, longexit) ;
Plot(inlong,"",colorGreen, styleArea, 0,10);
PlotShapes(IIf( Longentry, shapeUpTriangle, shapeNone) ,colorLime) ;
PlotShapes(IIf( Longexit, shapeDownTriangl e,shapeNone) ,colorRed) ;
Title = Name() + " In long entry = " + inlong ;
--
And here's my attempt with using static vars to latch 'inlong' = true
on the 1st occurance of the signal.
But it doesn't work right .. the static var doesn't seem to getting
set.. or at least that's the appearance.
--
_SECTION_BEGIN("RT-FLIP");
LongEntry = C > Ref(H,-1) ;
LongExit = C < Ref(L,-1) ;
if (Longentry[BarCount -1] = True)
{
StaticVarSet("aaa",True);
}
if (Longexit[BarCount- 1] = True)
{
StaticVarSet("aaa",False);
}
Longlatch = (Longentry OR StaticVarGet("aaa"));
inlong = Flip(Longlatch ,longexit);
/* This should be true, until we get a new longexit ) */
Plot(inlong,"",colorGreen, styleArea, 0,10);
PlotShapes(IIf( Longentry, shapeUpTriangle, shapeNone) ,colorLime) ;
PlotShapes(IIf( Longexit, shapeDownTriangl e,shapeNone) ,colorRed) ;
SignalText = WriteIf(inlong, EncodeColor( colorLime) + " IN LONG TRADE","");
Title = Name() + " longentry = " + Longentry + " StVar= " +
StaticVarGet("aaa") + signaltext;
_SECTION_END( );
---
I suspect I'm getting hung up in my use of barcount and/or my use of
the braces in the IF statements.
Any help would be appreciated.
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroke r.com/devlog/
For other support material please check also:
http://www.amibroke r.com/support. html
Yahoo! Groups Links
http://groups. yahoo.com/ group/amibroker/
http://groups. yahoo.com/ group/amibroker/ join
(Yahoo! ID required)
mailto:amibroker-fullfeatu red@xxxxxxxxxxxx com
<!--
#ygrp-mlmsg {font-size:13px;font-family:arial,helvetica,clean,sans-serif;}
#ygrp-mlmsg table {font-size:inherit;font:100%;}
#ygrp-mlmsg select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}
#ygrp-mlmsg pre, code {font:115% monospace;}
#ygrp-mlmsg * {line-height:1.22em;}
#ygrp-text{
font-family:Georgia;
}
#ygrp-text p{
margin:0 0 1em 0;
}
#ygrp-tpmsgs{
font-family:Arial;
clear:both;
}
#ygrp-vitnav{
padding-top:10px;
font-family:Verdana;
font-size:77%;
margin:0;
}
#ygrp-vitnav a{
padding:0 1px;
}
#ygrp-actbar{
clear:both;
margin:25px 0;
white-space:nowrap;
color:#666;
text-align:right;
}
#ygrp-actbar .left{
float:left;
white-space:nowrap;
}
.bld{font-weight:bold;}
#ygrp-grft{
font-family:Verdana;
font-size:77%;
padding:15px 0;
}
#ygrp-ft{
font-family:verdana;
font-size:77%;
border-top:1px solid #666;
padding:5px 0;
}
#ygrp-mlmsg #logo{
padding-bottom:10px;
}
#ygrp-vital{
background-color:#e0ecee;
margin-bottom:20px;
padding:2px 0 8px 8px;
}
#ygrp-vital #vithd{
font-size:77%;
font-family:Verdana;
font-weight:bold;
color:#333;
text-transform:uppercase;
}
#ygrp-vital ul{
padding:0;
margin:2px 0;
}
#ygrp-vital ul li{
list-style-type:none;
clear:both;
border:1px solid #e0ecee;
}
#ygrp-vital ul li .ct{
font-weight:bold;
color:#ff7900;
float:right;
width:2em;
text-align:right;
padding-right:.5em;
}
#ygrp-vital ul li .cat{
font-weight:bold;
}
#ygrp-vital a {
text-decoration:none;
}
#ygrp-vital a:hover{
text-decoration:underline;
}
#ygrp-sponsor #hd{
color:#999;
font-size:77%;
}
#ygrp-sponsor #ov{
padding:6px 13px;
background-color:#e0ecee;
margin-bottom:20px;
}
#ygrp-sponsor #ov ul{
padding:0 0 0 8px;
margin:0;
}
#ygrp-sponsor #ov li{
list-style-type:square;
padding:6px 0;
font-size:77%;
}
#ygrp-sponsor #ov li a{
text-decoration:none;
font-size:130%;
}
#ygrp-sponsor #nc {
background-color:#eee;
margin-bottom:20px;
padding:0 8px;
}
#ygrp-sponsor .ad{
padding:8px 0;
}
#ygrp-sponsor .ad #hd1{
font-family:Arial;
font-weight:bold;
color:#628c2a;
font-size:100%;
line-height:122%;
}
#ygrp-sponsor .ad a{
text-decoration:none;
}
#ygrp-sponsor .ad a:hover{
text-decoration:underline;
}
#ygrp-sponsor .ad p{
margin:0;
}
o {font-size:0;}
.MsoNormal {
margin:0 0 0 0;
}
#ygrp-text tt{
font-size:120%;
}
blockquote{margin:0 0 0 4px;}
.replbq {margin:4;}
-->
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.10/624 - Release Date: 1/12/2007 2:04 PM
|