Jump to content

Help changing indicator from lines to arrow on cross


mrb123

Recommended Posts

Hi group; I have this indi that I am stuck with. It displayed lines when direction changed up or down. I am trying to just plot an arrow up & down at the point when direction changes from up to down instead. Can someone fix it for me? I am stuck as to how to finish this. Thanks!

Here is some of the code:

 

#property copyright "MT4"

#property link ""

 

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 Blue

#property indicator_color2 Red

 

extern int period = 50;

extern int method = 3;

extern int price = 0;

double g_ibuf_88[];

double g_ibuf_92[];

double g_ibuf_96[];

 

double CrossUp[];

double CrossDown[];

extern int Arrow_Distance = 10;

 

int init() {

IndicatorBuffers(3);

SetIndexBuffer(0, g_ibuf_88);

SetIndexBuffer(1, g_ibuf_92);

SetIndexBuffer(2, g_ibuf_96);

ArraySetAsSeries(g_ibuf_96, TRUE);

//---- indicators

SetIndexStyle(0, DRAW_ARROW, EMPTY);

SetIndexArrow(0, 233);

SetIndexBuffer(0, CrossUp);

SetIndexStyle(1, DRAW_ARROW, EMPTY);

SetIndexArrow(1, 234);

SetIndexBuffer(1, CrossDown);

//----

 

// SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 2);

// SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 2);

IndicatorShortName("FIP_ Arrow(" + period + ")");

return (0);

}

 

int deinit() {

return (0);

}

 

double WMA(int ai_0, int a_period_4) {

return (iMA(NULL, 0, a_period_4, 0, method, price, ai_0));

}

 

int start() {

double lda_0[];

double lda_4[];

int l_ind_counted_8 = IndicatorCounted();

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

int li_12 = 0;

int l_period_16 = MathSqrt(period);

int li_20 = Bars - l_ind_counted_8 + period + 1;

if (li_20 > Bars) li_20 = Bars;

ArrayResize(lda_0, li_20);

ArraySetAsSeries(lda_0, TRUE);

ArrayResize(lda_4, li_20);

ArraySetAsSeries(lda_4, TRUE);

for (li_12 = 0; li_12 < li_20; li_12++) lda_0[li_12] = 2.0 * WMA(li_12, period / 2) - WMA(li_12, period);

for (li_12 = 0; li_12 < li_20 - period; li_12++) g_ibuf_96[li_12] = iMAOnArray(lda_0, 0, l_period_16, 0, method, li_12);

for (li_12 = li_20 - period; li_12 >= 0; li_12--) {

lda_4[li_12] = lda_4[li_12 + 1];

if (g_ibuf_96[li_12] > g_ibuf_96[li_12 + 1]) lda_4[li_12] = 1;

if (g_ibuf_96[li_12] < g_ibuf_96[li_12 + 1]) lda_4[li_12] = -1;

 

if (lda_4[li_12] > 0.0) {

g_ibuf_88[li_12] = g_ibuf_96[li_12];

if (lda_4[li_12 + 1] < 0.0) g_ibuf_88[li_12 + 1] = g_ibuf_96[li_12 + 1]- Arrow_Distance * Point;

g_ibuf_92[li_12] = EMPTY_VALUE;

} else {

if (lda_4[li_12] < 0.0) {

g_ibuf_92[li_12] = g_ibuf_96[li_12];

if (lda_4[li_12 + 1] > 0.0) g_ibuf_92[li_12 + 1] = g_ibuf_96[li_12 + 1]+ Arrow_Distance * Point;

g_ibuf_88[li_12] = EMPTY_VALUE;

}

}

}

return (0);

}

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...