Hi Silon,
OK, here an exploration for the buy condition you
wanted. I'm going to leave it to you to work out the sell, but it isn't
rocket science to reverse the buy condition to create a sell. The code as
written will produce stocks with a buy condition and further indicate whether a
2 or 3 day up condition was met.
I thought about also coding an indicator and backtest,
but that too is left to you as I didn't understand that you were asking for
those. And I'm not certain what you would want to use for an exit anyway
as the sell really should be a short and not just a sell of the long -- a casual
look at using the setup as a stop and reverse system does not suggest that it
would be very profitable, if at all. Let me know if you have further
questions. Enjoy.
// 3 DAY SETUPS
// WRITTEN BY NW TRADER AT THE REQUEST OF SILON SAMA 02-03-10
// =================
EXPLORATION CODE ================
PCONDUP2 = O > Ref(C,-1)
AND C > Ref(C,-1) AND Ref(O,-1) > Ref(C,-2) AND Ref(C,-1) > Ref(C,-2) ;
PCONDUP3 = O > Ref(C,-1)
AND C > Ref(C,-1) AND Ref(O,-1) > Ref(C,-2)
AND Ref(C,-1) > Ref(C,-2) AND Ref(O,-2) > Ref(C,-3) AND Ref(C,-2) > Ref(C,-3) ;
STOCHCONDUP = StochK(15,3) >
StochD(15,3,3)
AND Cross(StochK(15,3) , StochD(15,3,3) ) ;
DICONDUP = PDI(14) > MDI(14);
Filter = Buy = (PCONDUP2
OR PCONDUP3) AND STOCHCONDUP
AND DICONDUP;
AddColumn (C, "CLOSE",
3.2, colorYellow,colorBlack);
AddTextColumn ( WriteIf(PCONDUP2,
"YES", "NO"), " UP 2", 5.0, colorBlack, colorSkyblue);
AddTextColumn ( WriteIf(PCONDUP3,
"YES", "NO"), " UP 3", 5.0, colorBlack, colorPaleGreen);
AddTextColumn ( WriteIf(STOCHCONDUP, "YES", "NO"), " UP STOCH", 10.0, colorWhite, colorBlue);
AddTextColumn ( WriteIf(DICONDUP ,
"YES", "NO"), " UP DI", 10.0, colorWhite, colorRed );
AddTextColumn ( WriteIf(
Buy, "BUY", "NO"), "
ACTION", 10.0, colorYellow,
colorDarkGreen);
Peace and Justice --- Patrick
----- Original Message -----
Sent: Wednesday, February 03, 2010 11:27
AM
Subject: Re: [amibroker] AFl Code -3 days
continuous up+ adx rsinging
Hi Silon,
Apologies for delay -- lots going on at my end.
I'm in trading just now, so I'll have to wait for market to close before
spending much more time on this. However as I originally said, this isn't
difficult to code once you write out the conditions you are looking to be
met.
What have you tried so far? As an example to get you
started (and without doing this is AB, but it should work) consider
the following to code for two days up (your definition: Open> previous
day's close + close >close of previous day):
PCondUP2 = ( O > ref(C,-1) and C >
REF(C,-1) ) AND ( REF(O,-1) > REF(C,-2) AND REF(C,-1) > REF(C,-2) )
;
Do you see how to refer to the open or close and the
prior close as well as tie price actions for different days together?
The same will work for any array (StochK(15,3), PDI(14), etc. While you
could run all coding into a single Filter = , when you first start out (and
even later), I recommend writing out each of your conditions as a separate
statement and then linking them in the filter as Filter = PCondUP2 and
PCondUP3 and ... etc. That way if you have a problem with your coding, you can
isolate it quickly or if you decide you want to add or delete conditions, it
is relatively easy to do so. This condition approach also allows for
easy construction of Buy or Sell statements, putting signals (arrows,
triangles, etc.) on a chart, as well as constructing different ribbons
to depict conditions or coloring your candles based on one or more
conditions. Adding information in a title statement is also
facilitated. Complex code execution can also be speeded up by making
conditions dependent on each other.
I'll check back in a few hours after the market closes
to see how you are doing. I would rather you learn how to fish than I
just give you a fish to eat today.
Peace and Justice ---
Patrick
----- Original Message -----
Sent: Wednesday, February 03, 2010 8:46
AM
Subject: Fw: [amibroker] AFl Code -3
days continuous up+ adx rsinging
hi NWTRADER can u please give me sollution ---
On Sat, 1/30/10, silon sama <u4my1986@xxxxxxxxx>
wrote:
From:
silon sama <u4my1986@xxxxxxxxx> Subject:
Fw: [amibroker] AFl Code -3 days continuous up+ adx rsinging [1
Attachment] To: amibroker@xxxxxxxxxxxxxxx Date:
Saturday, January 30, 2010, 11:57 PM
pls suggest me wat to do --- On Sat,
1/30/10, silon sama <u4my1986@xxxxxxxxx>
wrote:
From:
silon sama <u4my1986@xxxxxxxxx> Subject:
[amibroker] AFl Code -3 days continuous up+ adx rsinging [1
Attachment] To: amibroker@xxxxxxxxxxxxxxx Date:
Saturday, January 30, 2010, 2:45 PM
Dear All member,
can anybody wil help me to create AFL as
per attachment :
(1) Stock is continuous up from last
2or 3 days + and each of day OPEN>CLOSE
+
(2) ADX indicator
of last day candle +DI>
-DI
+
(3)STOCHASTIC indicator at
last day %K>%D ..or K is rising
is it possible to combile all these three and
generate BUY SIGNal and viceversa for SELL signal with
arrow mark....i need it urgently
...
can any body help me to create this
CODE
|
|
|
__._,_.___
**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com
TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
__,_._,___
|