Jump to content

Instant Buy/Sell code - What are the rules?


heikobear

Recommended Posts

Hi

 

I want to create an EA out of this indicator based on Dittmans´s instant buy sell strategy which works very well.

 

As I am not a MQL programmer, I couldn´t figure out what are the exact entry rules. There are other indicators included (Bulls/Bears, MACD) but it seems the only important indicator is 001mq4

Could someone give me some support here?

 

Here is the code and link for the indicator package.

 

http://www.2shared.com/file/OBAMMLyz/instant.html

 

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 DodgerBlue

#property indicator_color2 OrangeRed

 

extern int Arrowperiod = 53;

extern double Arrowsticker = 1.2;

extern int SL_distance_pips = 200;

extern bool EmailAlert = TRUE;

extern int Upper = 2;

extern int Downner = 3;

string gs_104 = "bs";

double g_ibuf_112[];

double g_ibuf_116[];

double g_ibuf_120[];

datetime g_time_124;

 

void DisplayAlert(string as_0, double ad_8, double ad_16, double ad_24, int ai_32) {

string ls_36;

string ls_44;

string ls_52;

string ls_60;

if (Time[0] != g_time_124) {

g_time_124 = Time[0];

if (ad_24 != 0.0) ls_52 = "Price " + DoubleToStr(ad_24, 4);

else ls_52 = "";

if (ad_8 != 0.0) ls_44 = ", TakeProfit - " + DoubleToStr(ad_8, 4);

else ls_44 = "";

if (ad_16 != 0.0) ls_36 = ", StopLoss - " + DoubleToStr(ad_16, 4);

else ls_36 = "";

ls_60 = "Entry - " + as_0 + ls_52 + ls_44 + ls_36 + " ";

drawSignalArrow(g_time_124, ad_16, ai_32, ls_60);

if (ai_32 > 0) {

SendMail("Buy signal alert ", "Buy signal at Ask=" + DoubleToStr(Ask, 4) + ", Bid=" + DoubleToStr(Bid, 4) + ", Date=" + TimeToStr(TimeCurrent(), TIME_DATE) + " " +

TimeHour(TimeCurrent()) + ":" + TimeMinute(TimeCurrent()) + " Symbol=" + Symbol() + " Period=" + Period());

}

if (ai_32 < 0) {

SendMail("Sell signal alert", "SELL signal at Ask=" + DoubleToStr(Ask, 4) + ", Bid=" + DoubleToStr(Bid, 4) + ", Date=" + TimeToStr(TimeCurrent(), TIME_DATE) + " " +

TimeHour(TimeCurrent()) + ":" + TimeMinute(TimeCurrent()) + " Symbol=" + Symbol() + " Period=" + Period());

}

Alert(ls_60, Symbol(), ", ", Period(), " minute MT4 chart");

}

}

 

int init() {

int li_0;

if (Arrowperiod == 8) li_0 = 2;

else li_0 = 4;

IndicatorBuffers(3);

string ls_4 = "(" + Arrowperiod + ")";

SetIndexBuffer(0, g_ibuf_112);

SetIndexStyle(0, DRAW_NONE, STYLE_SOLID, li_0);

SetIndexLabel(0, "" + ls_4);

SetIndexBuffer(1, g_ibuf_116);

SetIndexStyle(1, DRAW_NONE, STYLE_SOLID, li_0);

SetIndexLabel(1, "" + ls_4);

SetIndexBuffer(2, g_ibuf_120);

ArraySetAsSeries(g_ibuf_120, TRUE);

IndicatorShortName("Buy&Sell");

IndicatorDigits(MarketInfo(Symbol(), MODE_DIGITS) + 1.0);

return (0);

}

 

int deinit() {

DelObj("");

return (0);

}

 

double WMA(int ai_0, int a_period_4) {

return (iMA(NULL, 0, a_period_4, 0, Upper, Downner, ai_0));

}

 

int start() {

string ls_4;

double lda_28[];

double lda_32[];

double ld_44;

int l_ind_counted_0 = IndicatorCounted();

if (l_ind_counted_0 < 0) return (-1);

int li_12 = 1;

int l_period_16 = MathFloor(MathSqrt(Arrowperiod));

int li_20 = MathFloor(Arrowperiod / Arrowsticker);

int li_24 = Bars - l_ind_counted_0 + Arrowperiod + 1;

if (li_24 > Bars) li_24 = Bars;

ArraySetAsSeries(lda_28, TRUE);

ArrayResize(lda_28, li_24);

ArraySetAsSeries(lda_32, TRUE);

ArrayResize(lda_32, li_24);

double ld_36 = Close[1];

for (li_12 = 0; li_12 < li_24; li_12++) lda_28[li_12] = 2.0 * WMA(li_12, li_20) - WMA(li_12, Arrowperiod);

for (li_12 = 0; li_12 < li_24 - Arrowperiod; li_12++) g_ibuf_120[li_12] = iMAOnArray(lda_28, 0, l_period_16, 0, Upper, li_12);

for (li_12 = li_24 - Arrowperiod; li_12 > 0; li_12--) {

lda_32[li_12] = lda_32[li_12 + 1];

if (g_ibuf_120[li_12] > g_ibuf_120[li_12 + 1]) lda_32[li_12] = 1;

if (g_ibuf_120[li_12] < g_ibuf_120[li_12 + 1]) lda_32[li_12] = -1;

ls_4 = "trendx=" + lda_32[li_12] + " trendx+1=" + ((lda_32[li_12 + 1])) + " x=" + li_12 + " countedbars=" + l_ind_counted_0;

if (lda_32[li_12] > 0.0) {

g_ibuf_112[li_12] = g_ibuf_120[li_12];

if (lda_32[li_12 + 1] < 0.0) g_ibuf_112[li_12 + 1] = g_ibuf_120[li_12 + 1];

if (lda_32[li_12 + 1] < 0.0) {

if (li_12 == 1) {

ld_44 = Low[4] - SL_distance_pips * Point;

DisplayAlert(" Buy signal - ", 0, ld_44, ld_36, 1);

}

if (l_ind_counted_0 == 0) drawSignalArrow(Time[li_12], Low[li_12 + 1] - SL_distance_pips * Point, 1, ls_4);

}

g_ibuf_116[li_12] = EMPTY_VALUE;

} else {

if (lda_32[li_12] < 0.0) {

g_ibuf_116[li_12] = g_ibuf_120[li_12];

if (lda_32[li_12 + 1] > 0.0) g_ibuf_116[li_12 + 1] = g_ibuf_120[li_12 + 1];

if (lda_32[li_12 + 1] > 0.0) {

if (li_12 == 1) {

ld_44 = High[4] + SL_distance_pips * Point;

DisplayAlert(" Sell signal - ", 0, ld_44, ld_36, -1);

}

if (l_ind_counted_0 == 0) drawSignalArrow(Time[li_12], High[li_12 + 1] + SL_distance_pips * Point, -1, ls_4);

}

g_ibuf_112[li_12] = EMPTY_VALUE;

}

}

}

return (0);

}

 

void DelObj(string as_0) {

string l_name_8;

int li_20;

string ls_24;

for (int li_16 = ObjectsTotal() - 1; li_16 >= 0; li_16--) {

l_name_8 = ObjectName(li_16);

li_20 = StringLen(as_0) + StringLen(gs_104);

ls_24 = as_0 + gs_104;

if (StringSubstr(l_name_8, 0, li_20) == ls_24) ObjectDelete(l_name_8);

}

}

 

void drawSignalArrow(int a_datetime_0, double a_price_4, int ai_12, string a_text_16) {

int li_24;

color l_color_36;

if (ai_12 > 0) {

li_24 = 233;

a_price_4 -= 1.0 * Point;

} else {

li_24 = 234;

a_price_4 += 10.0 * Point;

}

string l_name_28 = gs_104 + "signalArrow" + a_price_4 + a_datetime_0 + li_24;

if (ai_12 < 1) l_color_36 = Red;

else l_color_36 = Green;

ObjectDelete(l_name_28);

ObjectCreate(l_name_28, OBJ_ARROW, 0, a_datetime_0, a_price_4, 0, 0, 0, 0);

ObjectSet(l_name_28, OBJPROP_WIDTH, 2);

ObjectSet(l_name_28, OBJPROP_ARROWCODE, li_24);

ObjectSet(l_name_28, OBJPROP_COLOR, l_color_36);

ObjectSetText(l_name_28, a_text_16, 0);

}

Link to comment
Share on other sites

Unfortunately, that would depend on market conditions. I did a quick look at the indicator when I built the EA, and thought that 25 for the Arrowsperiod looked better than 53, but each currency and TF will have different requirements. I think the EA would need to be optimized often, perhaps every week, and even then there is no guarantee. Like most indicators, the period depends on the total number of candles in each trending session. Without the crystal ball, or the super secret profit formula from Dittman, we are unfortunately SOL in estimating those numbers. However, by optimizing, one can at least stand a chance at succeeding.
Link to comment
Share on other sites

from the manual

 

H4 - Arrowperiod - 45-65 (55) Arrowsticker - 1.5-2.0 (1.9)

H1 - Arrowperiod - 44-64 (53) Arrowsticker - 1.1-1.7 (1.2)

M30 - Arrowperiod - 26-42 (37) Arrowsticker - 1.1-1.6 (1.3)

M15- Arrowperiod - 44-64 (53) Arrowsticker - 1.5-1.1 (1.2)

M5 - Arrowperiod - 15-30 (65) Arrowsticker - 1.1-1.4 (1.2)

Link to comment
Share on other sites

Test it visually with the indy to make sure it works right, and report any bugs back to me. Thx. BTW, I think the default settings for the BS indicator need to be changed to be profitable. Optimizing these would be the first start.

 

http://www.4shared.com/file/KCzkKmtc/BuySellEA10.html

 

I am not a fan of K.D's system I've spend (waste money) on several system by K.D system in the past, thought to myself, I never going to look at K.D's system again.

 

While I was looking at new post today, I saw thread titled under "Instant Buy/Sell code - What are the rules?" and I didn't realized its based on K.D's system. I download the EA and ran quick test. To my surprise, this system seem alright.

 

But I agree with stovedude, I am sure the settings need to be optimized in order to be profitable.

 

Thanks, stovedude, for making the EA.

Link to comment
Share on other sites

There may be a problem with entry??.........this one entered 33pips from arrow.......however i'm starting to believe these also repaint a bit..........still entry was 10pips from start of candle (settings; max slippage 3, max spread 3)......was the 9am candle (gmt) there was minor Euro news at 8:55 so may have been a jump in price.

 

SL function, breakeven and Trailing SL seems to work ok....thanks stovedude

 

http://i988.photobucket.com/albums/af5/kraven69/xxx2-1.gif

Edited by kraven
Link to comment
Share on other sites

Hi,

 

Good day,

 

And Happy New year for all,

 

I can see that this system contains Moving averges only where the arrow pops up whenever the crossover take place... in this case, you can use any 2 moveing average crossover EA to attain that,

 

Best wishes,

 

SF

a New Year 2011 has come, and the challenge has just started 8-)
Link to comment
Share on other sites

I did an opto for E/U H1, and it was profitable for the last month, but unfortunately the very last trade was the key winning trade. I tested for a year, and had the same total profit as last month, with the best trades at the end. Even with different trail stop functions enabled, it was about the same. In other words, it may not be worth pursuing. Without extra filters, MA crossovers have never worked long term. Just chalk it up to another bad KD dream....
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...