Heikin Ashi conditional mapping
Author: sofia
Creation Date: 12/10/2011 3:38 PM
profile picture

sofia

#1
Hello,

How do I map Heikin Ashi candle pattern as buy and sell ? I want to map Heiken Ashi Candle pattern as buy and sell. i.e If previous candle is Heiken Ashi red and current candle is Heiken Ashi blue
then buy at close and cover at close.
if previous candle is Heiken Ashi blue and current candle is Heiken Ashi red then sell and short at close.

HHclose,HHopen,HHhigh and HHlow are Heikin Ashi candle bars.

Here is what I am trying to do
CODE:
Please log in to see this code.


Sorry I am not very good with programming and still learning. So any help is appreciated.

Sofia
profile picture

Eugene

#2
Next time you post some code (or pseudocode), please wrap it in
CODE tags, not QUOTE.

QUOTE:
// DataSeries HHhigh = How do I code this ??

You don't need to code this. Just search the forum, and it will pop up an existing Heiken Ashi code and a pointer to the QuickRef function with that code.
QUOTE:
//if(bear)

Is there a reason for dropping the default check for last Position active from the code? (No, it will not work.)
QUOTE:
if previous candle is Heiken Ashi blue and current candle is Heiken Ashi red then sell and short at close.

See Knowledge Base > WealthScript Techniques | Creating a Stop-And-Reverse (SAR) system
QUOTE:
// bool bear = (HeikenAshiBlue[bar-1] && HeikenAshiRed[bar]);


Considering all of the aforementioned, see code below:
CODE:
Please log in to see this code.



P.S. Are you looking at Heiken Ashi bars for an external symbol to make the trading decisions?
QUOTE:
DataSeries Hclose = GetExternalSymbol("msft",true).Close;
profile picture

sofia

#3
Hi Eugene,

Thanks for your help. Yes I am looking for Heiken Ashi bars for external symbol to buy and sell.
Not necessarily msft but wanted to try out different high cap equities and currency etfs to buy and sell indices.I will follow your instructions regarding code next time.

I also have another question, I recently downloaded "Active trader strategy pack" which has compiled code.
Since I don't want them, I tried to delete them and I cannot do it.
How do I delete those strategies. The delete switch on WL6.2 seems to be inactive when I select those strategies.

Best regards,

Sofia
profile picture

Eugene

#4
QUOTE:
Yes I am looking for Heiken Ashi bars for external symbol to buy and sell.

OK, let's see how you would do it:

1. Define an external symbol's Bars like you did in your code before this section:
CODE:
Please log in to see this code.

Let's say:
CODE:
Please log in to see this code.

2. In this section, replace the DataSeries that point to the current Bars object, with references to your external symbol's corresponding DataSeries.
CODE:
Please log in to see this code.

Hint: keep in mind that "Open" etc. are the short for "Bars.Open" etc. and make the necessary corrections (total: 7) on the 4 lines of code.

Result:
CODE:
Please log in to see this code.


QUOTE:
I also have another question, I recently downloaded "Active trader strategy pack" which has compiled code.
Since I don't want them, I tried to delete them and I cannot do it.

Uninstall the Extension itself. You can't remove or edit a part of compiled strategy DLL.
profile picture

sofia

#5
Hi Eugene,

Thanks, I tried compiling your code for both cases(i.e first code and also the second code with external symbol) but I only got one trade, it looks like the program won't sample all bars only first few. Then it stops.i.e it does not progress through time.

so I removed
CODE:
Please log in to see this code.


I also had to update the buy and sell original code.

Here is the code for buy and sell. It seem to work good for 30min scale for US indices based on euro (FXE) movement.
But mot sure if this is duplicating the conditionals for Heiken Ashi.Better results can be obtained using moving average etc but here is the sample code.
CODE:
Please log in to see this code.


Thanks,

Sofia
profile picture

Eugene

#6
The code above assumes Daily bar scale. Next time don't hesitate to mention that you like to use it on different bar scales.

You should not remove arbitrary parts of code. Instead, modify this line:
Bars bars = new Bars( ext.Symbol.ToString() + " (Heikin-Ashi)", BarScale.Daily, 0 );

CODE:
Please log in to see this code.
profile picture

sofia

#7
Eugene,

Yes I tried daily barscale, but it won't give more than one result.
The issues I mentioned were for daily barscale.

Thanks again.

Regards,

Sofia
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).