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

Re: [amibroker] Hold and Valuewhen functions



PureBytes Links

Trading Reference Links

like Thomas says you can get multiple signals which complicates things. In the code below I remove all signals in the waitPeriod after you get the first signal. Maybe a bit of a tough solution but I can only think of using a loop to get rid of these additional signals, I would not know how to do it using array based calculations (see chart for result).
 
SetBarsRequired(10000,10000);

triggerPercentage =
1.03
;
waitPeriod =
15
;

Setup =
C < BBandBot(C,20,2
);

for (i = 0; i < BarCount
- waitPeriod; i++) {

   
if
(Setup[ i ]) {

      
for (j = i + 1
; j < i + waitPeriod; j++) {
      
         Setup[ j ] =
0
;
      
      }

      i = j;

   }

}

BarssinceSetup =
BarsSince
(Setup);
SetupPrice =
ValueWhen(Setup,H
) * triggerPercentage;
SetupPrice =
IIf(BarssinceSetup < waitPeriod,SetupPrice,Null
);

Buy = Cross(H,SetupPrice) AND !IsNull(SetupPrice); BuyPrice = IIf(O > SetupPrice,O
,SetupPrice);

SetChartOptions(0, chartShowDates
);
GraphXSpace = 5
;
Plot(C,"C",1,64
);
Plot(BBandBot(C,20,2),"",colorGold,1
);
Plot(SetupPrice,"",colorLightBlue,1
);
PlotShapes(IIf(Setup,shapeSmallCircle,0),colorYellow, layer = 0, yposition = L, offset = 0
);
 
 
 
 
 
 
----- Original Message -----
From: Thomas Z.
Sent: Wednesday, March 21, 2007 8:08 AM
Subject: RE: [amibroker] Hold and Valuewhen functions

I think you are wondering because setups on following bars overwrite the
first setup and therefore they are producing new "setup prices".

Thomas
www.patternexplorer.com

From: amibroker@xxxxxxxxxps.com [mailto:amibroker@xxxxxxxxxps.com] On Behalf
Of bernardedmond01
Sent: Wednesday, March 21, 2007 4:15 AM
To: amibroker@xxxxxxxxxps.com
Subject: [amibroker] Hold and Valuewhen functions

I wondered whether you could tell me where I'm wrong with this basic
formula. I want it to hold my setup for 5 bars and then buy once the
high is more than 15% higher than the setup price. I'm having
difficulty with the hold and value when functions.
Thanks in advance.

Setup = C<BBandBot (C,20,2);
Buyzone= Hold(Setup,5); //What I'm trying to say here is once I have a
setup, hold it up to 5 periods//
SetupPrice = ValueWhen (Setup,H); //What I'm trying to say here is the
setup price is the high of the setup//
Buy = Buyzone AND H>SetupPrice*1.15;
Sell = 0;

__._,_.___

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.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html





SPONSORED LINKS
Investment management software Investment property software Investment software
Investment tracking software Return on investment software

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Attachment: trig.png
Description: PNG image