Easylanguage Candle Ident

raven4ns

Member
Messages
61
Likes
0
Hello,
Does anyone have a script for candle identification they wouldn't mind sharing? I use Multicharts and would very much like to have such a script. I have looked in a few places but haven't come across any scripts that seem suitable. Any help will be most appreciated. Thank you.

Kindest regards,

Tim
 
It is very easy to define a particular candle pattern once one knows which pattern that they are looking for.
 
Candle Ident code

It is very easy to define a particular candle pattern once one knows which pattern that they are looking for.
Hi StratOpt,
The code I use to give me a heads up is written for Amibroker. It isn't as complete as needed to trade by solely but certainly good enough for what I want it for. Since computers and I are like water and oil, I prefer to find a code already written. That way my blood pressure remains fairly even.....lol.
I can provide you with the Amibroker code if you wish to use it yourself as long as you provide me with an EasyLanguage conversion as well. Thank you for your insights.


Kindest regards,

Tim
 
I can certainly try to make the conversion. I have never used Amibroker, but I can read code pretty good since it is my profession. You may be able to find somebody versed in both languages. If not then I can try.
 
I can certainly try to make the conversion. I have never used Amibroker, but I can read code pretty good since it is my profession. You may be able to find somebody versed in both languages. If not then I can try.

Hi StratOpt,
Here is the Amibroker code. I use it to give me a heads up on candle patterns. It would be nice to find a more complete candle recognition program but the only ones I have found are associated with charting programs like Metastock , Telechart etc. In any event, I hope you find this useful. Thank you for taking a look at it, I appreciate your kindness.

Kindest regards,

Tim

_SECTION_BEGIN("Candle Identification");
Plot(C,"",37,64);
O1 = Ref(O,-1);O2 = Ref(O,-2);
H1 = Ref(H,-1);H2 = Ref(H,-2);
L1 = Ref(L,-1);L2 = Ref(L,-2);
C1 = Ref(C,-1);C2 = Ref(C,-2);
function CandlePattern(P)
{
global PatternName;
if(P == 0) { PatternName = "NearDoji"; Pv = (abs(O-C)<= ((H-L)*0.1)); }
else if(P == 1) { PatternName = "BlackCandle"; Pv = (O>C); }
else if(P == 2) { PatternName = "LongBlackCandle"; Pv = (O>C AND
(O-C)/(.001+H-L)>.6); }
else if(P == 3) { PatternName = "SmallBlackCandle"; Pv = ((O>C) AND
((H-L)>(3*(O-C)))); }
else if(P == 4) { PatternName = "WhiteCandle"; Pv = (C>O); }
else if(P == 5) { PatternName = "LongWhiteCandle"; Pv = ((C>O) AND
((C-O)/(.001+H-L)>.6)); }
else if(P == 6) { PatternName = "SmallWhiteCandle"; Pv = ((C>O) AND
((H-L)>(3*(C-O)))); }
else if(P == 7) { PatternName = "BlackMaubozu"; Pv = (O>C AND H==O AND
C==L); }
else if(P == 8) { PatternName = "WhiteMaubozu"; Pv = (C>O AND H==C AND
O==L); }
else if(P == 9) { PatternName = "BlackClosingMarubozu"; Pv = (O>C AND
C==L); }
else if(P == 10) { PatternName = "WhiteClosingMarubozu"; Pv = (C>O AND
C==H); }
else if(P == 11) { PatternName = "BlackOpeningMarubozu"; Pv = (O>C AND
O==H); }
else if(P == 12) { PatternName = "WhiteOpeningMarubozu"; Pv = (C>O AND
O==L); }
else if(P == 13) { PatternName = "HangingMan"; Pv = (((H-L)>4*(O-C)) AND
((C-L)/(.001+H-L)>= 0.75) AND ((O-L)/(.001+H-L)>= 0.75)); }
else if(P == 14) { PatternName = "Hammer"; Pv = (((H-L)>3*(O-C)) AND
((C-L)/(.001+H-L)>0.6) AND ((O-L)/(.001+H-L)>0.6)); }
else if(P == 15) { PatternName = "InvertedHammer"; Pv = (((H-L)>3*(O-C))
AND ((H-C)/(.001+H-L)>0.6) AND ((H-O)/(.001+H-L)>0.6)); }
else if(P == 16) { PatternName = "ShootingStar"; Pv = (((H-L)>4*(O-C))
AND ((H-C)/(.001+H-L)>= 0.75) AND ((H-O)/(.001+H-L)>= 0.75)); }
else if(P == 17) { PatternName = "BlackSpinningTop"; Pv = ((O>C) AND
((H-L)>(3*(O-C))) AND (((H-O)/(.001+H-L))<.4) AND
(((C-L)/(.001+H-L))<.4)); }
else if(P == 18) { PatternName = "WhiteSpinningTop"; Pv = ((C>O) AND
((H-L)>(3*(C-O))) AND (((H-C)/(.001+H-L))<.4) AND
(((O-L)/(.001+H-L))<.4)); }
else if(P == 19) { PatternName = "BearishAbandonedBaby"; Pv = ((C1 == O1)
AND (C2>O2) AND (O>C) AND (L1>H2) AND (L1>H)); }
else if(P == 20) { PatternName = "BearishEveningDojiStar"; Pv = ((C2>O2)
AND ((C2-O2)/(.001+H2-L2)>.6) AND (C2<O1) AND (C1>O1) AND
((H1-L1)>(3*(C1-O1))) AND (O>C) AND (O<O1)); }
else if(P == 21) { PatternName = "DarkCloudCover"; Pv = (C1>O1 AND
((C1+O1)/2)>C AND O>C AND O>C1 AND C>O1 AND (O-C)/(.001+(H-L)>0.6)); }
else if(P == 22) { PatternName = "BearishEngulfing"; Pv = ((C1>O1) AND
(O>C) AND (O>= C1) AND (O1>= C) AND ((O-C)>(C1-O1))); }
else if(P == 23) { PatternName = "ThreeOutsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1>= C2) AND (O2>= C1) AND ((O1-C1)>(C2-O2)) AND (O>C) AND
(C<C1)); }
else if(P == 24) { PatternName = "BullishAbandonedBaby"; Pv = ((C1 == O1)
AND (O2>C2) AND (C>O) AND (L2>H1) AND (L>H1)); }
else if(P == 25) { PatternName = "BullishMorningDojiStar"; Pv = ((O2>C2)
AND ((O2-C2)/(.001+H2-L2)>.6) AND (C2>O1) AND (O1>C1) AND
((H1-L1)>(3*(C1-O1))) AND (C>O) AND (O>O1)); }
else if(P == 26) { PatternName = "BullishEngulfing"; Pv = ((O1>C1) AND
(C>O) AND (C>= O1) AND (C1>= O) AND ((C-O)>(O1-C1))); }
else if(P == 27) { PatternName = "ThreeOutsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1>= O2) AND (C2>= O1) AND ((C1-O1)>(O2-C2)) AND (C>O) AND
(C>C1)); }
else if(P == 28) { PatternName = "BullishHarami"; Pv = ((O1>C1) AND (C>O)
AND (C<= O1) AND (C1<= O) AND ((C-O)<(O1-C1))); }
else if(P == 29) { PatternName = "ThreeInsideUpPattern"; Pv = ((O2>C2)
AND (C1>O1) AND (C1<= O2) AND (C2<= O1) AND ((C1-O1)<(O2-C2)) AND (C>O) AND
(C>C1) AND (O>O1)); }
else if(P == 30) { PatternName = "PiercingLine"; Pv = ((C1<O1) AND
(((O1+C1)/2)<C) AND (O<C) AND (O<C1) AND (C<O1) AND
((C-O)/(.001+(H-L))>0.6)); }
else if(P == 31) { PatternName = "BearishHarami"; Pv = ((C1>O1) AND (O>C)
AND (O<= C1) AND (O1<= C) AND ((O-C)<(C1-O1))); }
else if(P == 32) { PatternName = "ThreeInsideDownPattern"; Pv = ((C2>O2)
AND (O1>C1) AND (O1<= C2) AND (O2<= C1) AND ((O1-C1)<(C2-O2)) AND (O>C) AND
(C<C1) AND (O<O1)); }
else if(P == 33) { PatternName = "ThreeWhiteSoldiers"; Pv = (C>O*1.01)
AND (C1>O1*1.01) AND (C2>O2*1.01) AND (C>C1) AND (C1>C2) AND (O<C1) AND
(O>O1) AND (O1<C2) AND (O1>O2) AND (((H-C)/(H-L))<.2) AND
(((H1-C1)/(H1-L1))<.2) AND (((H2-C2)/(H2-L2))<.2); }
else if(P == 34) { PatternName = "DarkCloudCover"; Pv = (C1>O1*1.01) AND
(O>C) AND (O>H1) AND (C>O1) AND (((C1+O1)/2)>C) AND (C>O1) AND
(MA(C,13)-Ref(MA(C,13),-4)>0); }
else if(P == 35) { PatternName = "ThreeBlackCrows"; Pv = (O>C*1.01) AND
(O1>C1*1.01) AND (O2>C2*1.01) AND (C<C1) AND (C1<C2) AND (O>C1) AND (O<O1)
AND (O1>C2) AND (O1<O2) AND (((C-L)/(H-L))<.2) AND (((C1-L1)/(H1-L1))<.2)
AND (((C2-L2)/(H2-L2))<.2); }
else if(P == 36) { PatternName = "doji"; Pv = (O == C); }
else if(P == 37) { PatternName = "GapUp"; Pv = GapUp(); }
else if(P == 38) { PatternName = "GapDown"; Pv = GapDown(); }
else if(P == 39) { PatternName = "BigGapUp"; Pv = L>1.01*H1; }
else if(P == 40) { PatternName = "BigGapDown"; Pv = H<0.99*L1; }
else if(P == 41) { PatternName = "HugeGapUp"; Pv = L>1.02*H1; }
else if(P == 42) { PatternName = "HugeGapDown"; Pv = H<0.98*L1; }
else if(P == 43) { PatternName = "DoubleGapUp"; Pv = GapUp() AND
Ref(GapUp(),-1); }
else if(P == 44) { PatternName = "DoubleGapDown"; Pv = GapDown() AND
Ref(GapDown(),-1); }
return Pv;
}

PatternNameList = "";
for(Cp=0; Cp<=44; Cp++)
{
VarSet("Pattern"+NumToStr(Cp,1.0),CandlePattern(cP));
PatternNameList = PatternNameList +PatternName+",";
}

BI = BarIndex();
SelectedBar = SelectedValue(BI) -BI[0];
//Selectedbar = Status("lastvisiblebar")-1;
PStr="";
for(Cp=0; Cp<=44; Cp++)
{
Temp = VarGet("Pattern"+NumToStr(Cp,1.0));
if(temp[SelectedBar]) Pstr=Pstr+"#"+NumToStr(Cp,1.0)+" - "+StrExtract(PatternNameList,Cp)+"\n";
}

Title = "\nCandle Demostration \n"+ Pstr;
_SECTION_END();
 
There is a pretty good candle coding example for TradeStation written by Demicron and posted for use for free in the EL Library in case you have found that.

I have copied your code example and will look at it as time permits me to do so over the next coming days. If you wanted to remove the code for some reason.
 
Thank you StratOpt for your suggestion and your help. I am trying to get help from MC support regards the code you mentioned. It has errors in it for MC and I wanted to take a look at it. It also isn't quite as comprehensive as the AB code but I wanted to view it anyways.

Tim
 
Curious as to how there can be errors in it when MC is supposed to be able to convert EL over ??
 
Curious as to how there can be errors in it when MC is supposed to be able to convert EL over ??

I just emailed the code to support to see if it was errors or my inability to handle it properly. As I said, computers and me are like water and oil......lol.


Tim
 
Here you go buddy. I converted your code over into TradeStation code. It provides both an alert system for live data and a print log section for both historical and live data. Hopefully you will find use for it.
 

Attachments

  • RAVENPATTERNS.ELD
    12.3 KB · Views: 481
Here you go buddy. I converted your code over into TradeStation code. It provides both an alert system for live data and a print log section for both historical and live data. Hopefully you will find use for it.

Hi StratOpt,
Thank you for your kindness, it is very much appreciated. I tried the code and it compiled successfully but it didn't show any text as to what the candle pattern was i.e. doji, engulfing etc. I must be doing something wrong, how did it work on your computer? My email is [email protected] by the way.

Tim
 
It will show the text in your print log window. On live data it will also do a pop up alert if you set it to allow alerts. CTRL SHIFT E will open this print window

Alerts:

Format Analysis Technique/Indicator - Alerts
On this tab, you format alert settings for indicators and analysis techniques that support alerts. The analysis techniques that support alerts are Indicators, ShowMe studies, PaintBar studies, and ActivityBar studies. A RadarScreen (Quotes)/OptionStation indicator may include alerts.

When formatting alerts, you can choose to use the global messaging preferences set up in the Message Center or you can configure custom settings for each type of alert.



Note All alerts are sent to the Message Center.



To format an alert for an analysis technique or indicator

Check Enable Alert to turn on all alerts for the selected analysis technique. Un-check this to disable alerts.

If alerts are enabled, choose one of the following actions to be taken when the alert condition is true:

Select Alert once to turn off alerts after the first one occurs and clear the Enable Alert check box.

Select Alert once per bar (interval) to turn off alerts for the remainder of the bar after the first one occurs. In addition, checking Clear triggered alert on bar open removes the displayed alert marker at the open of each bar.

Select Alert continuously to have all alerts processed.

If alerts are enabled, choose one of the following Message Center notification settings:

Select None to skip message notification while still sending the alert to the Message Center. Alert markers may still be displayed next to the symbol name in the Chart or RadarScreen window if enabled for the window.

Select Use the global messaging preferences for the global Message Center notification settings. Click Configure to set up your global messaging preferences.

Select Use custom settings to choose custom notification settings for this analysis technique or indicator. Click Configure to set up your custom messaging preferences.

For more information on Configure options, see Setting Up Messaging Preferences.



To use audio alerts, select the Audio Alert option. For specific configuration instructions, see Setting Up Audio Alerts.
To use visual alerts, select the Visual Alert option. For specific configuration instructions, see Setting Up Visual Alerts
To use email messaging, select the Email option. For specific configuration instructions, see Setting Up Email Messaging.

Click Default to use these settings as the default for all future analysis techniques of this type.

Click OK.
 
StratOpt that is so cool. Please accept my sincere thanks for your kindness. I wished you were close enough, we could go out for a coffee or something a little stronger....lol. Thank you again.

Tim
 
Ahahahahahaaha.... It works like a charm. I'm not sure if MC has a print log or not but am trying to find out. StratOpt, if someone who uses MC asks me for the code, would you mind if I shared it with them? I would make sure that you received the credit for it. I doubt if many would ask but just in case they do, I wanted to ensure you are ok with it.

Tim
 
Hi StratOpt, It appears as though MC doesn't have a print log like TS, only visual or audio alerts. How difficult would it be to be able to click on a candle with the mouse and have it display the candle pattern it represents? I really like the alerts as I will only enable those stocks that are close to a buy or sell. Hopefully you will be able to find some use for this code as well StratOpt. Once again, thank you so very much.

Tim
 
I doubt that I will have any use for the code at all, raven. It is not my style at all. What does MC have that would allow an output ?? Since I am not currently using MC then I can't be of much help with it. I do plan on testing and then likely purchasing the tool though in the future.
 
The only alerts are the visual alerts that pop-up or the audio alerts as far as I know. The company tries to be very accommodating as far as ideas about improving the software. For someone like me who is effectively computer illiterate, most software is a struggle. I was even considering Omnitrader because it wouldn't involve any programing. However, it seemed to be a black box affair and I am uncomfortable with them.

Tim
 
Top