Coding help - page 254

 
thefxpros:
Hi,

i'm having fun in turning some indicator in MTF using icustom. The indicator works, but doesn't display color and arrows properly, why?

Where is the error, please?

wilders_trailing_stop_mtf.mq4

wilders_trailing_stop.mq4

//------------------------------------------------------------------

#property copyright "thefxpros"

#property link "thefxpros@katamail.com"

//------------------------------------------------------------------

#property indicator_chart_window

//#property indicator_color1 Orange

//#property indicator_color2 LimeGreen

//#property indicator_color3 LimeGreen

//#property indicator_color4 Orange

//#property indicator_width3 1

//#property indicator_width4 1

//

//

//

extern int TimeFrame = 0;

extern int Length = 2;

extern double Coeff = 1.75;

extern int LineWidth = 1;

extern int ArrowWidth = 1;

extern color UpLineClr = LimeGreen;

extern color DnLineClr = Orange;

extern color UpArrowClr = LimeGreen;

extern color DnArrowClr = Orange;

//

double WTS[];

double WTSDn[];

double arrUp[];

double arrDn[];

//+------------------------------------------------------------------+

//| |

//+------------------------------------------------------------------+

int init()

{

IndicatorBuffers(4);

SetIndexBuffer(0,WTS); SetIndexStyle(0,DRAW_LINE, EMPTY, LineWidth, DnLineClr);

SetIndexBuffer(1,WTSDn); SetIndexStyle(1,DRAW_LINE, EMPTY, LineWidth, UpLineClr);

SetIndexBuffer(2,arrUp); SetIndexStyle(2,DRAW_ARROW, EMPTY, ArrowWidth, UpArrowClr); SetIndexArrow(2,SYMBOL_ARROWUP);

SetIndexBuffer(3,arrDn); SetIndexStyle(3,DRAW_ARROW, EMPTY, ArrowWidth, DnArrowClr); SetIndexArrow(3,SYMBOL_ARROWDOWN);

IndicatorShortName("Wilders trailing stop MTF ("+Length+","+Coeff+")");

Length = MathMax(Length,1);

switch(TimeFrame)

{

case 1 : string TimeFrameStr="Period_M1"; break;

case 5 : TimeFrameStr="Period_M5"; break;

case 15 : TimeFrameStr="Period_M15"; break;

case 30 : TimeFrameStr="Period_M30"; break;

case 60 : TimeFrameStr="Period_H1"; break;

case 240 : TimeFrameStr="Period_H4"; break;

case 1440 : TimeFrameStr="Period_D1"; break;

case 10080 : TimeFrameStr="Period_W1"; break;

case 43200 : TimeFrameStr="Period_MN1"; break;

default : TimeFrameStr="Current Timeframe";

}

IndicatorShortName("Wilders trailing stop MTF ("+TimeFrameStr+")");

return(0);

}

//----

//+------------------------------------------------------------------+

//| MTF function |

//+------------------------------------------------------------------+

int start()

{

datetime TimeArray[];

int i,limit,y=0,counted_bars=IndicatorCounted();

// Plot defined time frame on to current time frame

ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);

limit= MathMin(Bars-counted_bars+3*TimeFrame/Period(),Bars-1);

for(i=0,y=0;i<limit;i++)

{

if (Time<TimeArray[y]) y++;

/*********************************************************************************************************

Add your main indicator loop below. You can reference an existing indicator with its iName or iCustom.

Rule 1: Add extern inputs above for all neccesary values

Rule 2: Use 'TimeFrame' for the indicator time frame

Rule 3: Use 'y' for your indicator's shift value

********************************************************************************************************/

WTS=iCustom(Symbol(),TimeFrame,"Wilders trailing stop",Length,Coeff,0,y);

WTSDn=iCustom(Symbol(),TimeFrame,"Wilders trailing stop",Length,Coeff,1,y);

arrUp=iCustom(Symbol(),TimeFrame,"Wilders trailing stop",Length,Coeff,2,y);

arrDn=iCustom(Symbol(),TimeFrame,"Wilders trailing stop",Length,Coeff,3,y);

}

return(0);

}

//+------------------------------------------------------------------+[/PHP]

thefxpros

You commented out the part when you have to declare drawing buffers

This part :

[PHP]#property indicator_chart_window

//#property indicator_buffers 4

//#property indicator_color1 Orange

//#property indicator_color2 LimeGreen

//#property indicator_color3 LimeGreen

//#property indicator_color4 Orange

//#property indicator_width3 1

//#property indicator_width4 1

Remove comments from those lines and it will work

 
mladen:
thefxpros

You commented out the part when you have to declare drawing buffers

This part :

#property indicator_chart_window

//#property indicator_buffers 4

//#property indicator_color1 Orange

//#property indicator_color2 LimeGreen

//#property indicator_color3 LimeGreen

//#property indicator_color4 Orange

//#property indicator_width3 1

//#property indicator_width4 1
Remove comments from those lines and it will work

yes i know, but I've specified later, is not enough? Do i have always specify at the beginning?

I remember often i did like that, with previous build metaeditor and as far i remember it worked, do i remember wrong?

 
thefxpros:
yes i know, but I've specified later, is not enough? Do i have always specify at the beginning? I remember often i did like that, with previous build metaeditor and as far i remember it worked, do i remember wrong?

thefxpros

At the beginning you are specifying drawing buffers. Later you can specify calculatings buffers. If you do not specify #property indicator_buffers numberOfDrawningBuffer then nothing will be drawn on the hart

 

show all your Speard History . Please Help Me

 

Any one please help me to check this EA for the CloseInMA function .

I have stuck in here for many days and i can't find the solution .

Thank You .

Files:
testing1.5.mq4  38 kb
 
stevenpun:
Any one please help me to check this EA for the CloseInMA function .

I have stuck in here for many days and i can't find the solution .

Thank You .

stevenpun

Try to do like it is written now

Files:
 

Hello kind hearted guru, I am requesting please that someone help code this and then build a robot (EA) version of it:

INDICATOR- Auto draw horizontal lines (preferably broken lines) on prices ending at 5, 15, 31, 67 respectively. Example on UJ 103.05, 102.67, 103.15 e.t.c. Line length should be 1 inch long of a mathematical ruler with these numbers underneath so that I will have a decent chart because of couple lines I have already.

PS- 4 and 5 digit broker compatible

 

Rules for the EA

BUY

Place pending buy stop order anytime price moves 3 pips before magic number from BELOW. Example for magic number 5, price currently at UJ 103.02, place pending order buy @103.05.

SELL

Place pending sell stop any time price nearing magic number by 3 pips from ABOVE. Example, price currently @103.08, place sell stop @103.05

SL and TP 25/50 pip each.

When trade hit +3 pips in profit, move STOP LOSS to lock +1 profit, move 5 lock 4, move 8 lock 7, move 12 lock 10

Maximum open position or floating trade or pending order =1 only until stopped out for a new trade

Maximum daily draw down 3% and once reached, EA should stop trading.

Default lot size 0.1 (10,000)

24hrs trading

P.S: EA should have an option to hide magic numbers, trailing stop, take profit/stop loss from my broker and should be 4/5 digits compatible. Default pair UJ.

Will be most greatful to have this coded soon.

 
mladen:
stevenpun Try to do like it is written now

Hello mladen ,

I have try it before , but it not work .

That why i very confuse .

Hope you can help me see what is the problem .

Thank you .

 
stevenpun:
Hello mladen ,

I have try it before , but it not work .

That why i very confuse .

Hope you can help me see what is the problem .

Thank you .

In the version you posted you were comparing constants (Fastma, Dn_slowma and Up_slowma are periods that are used for moving averages, not the values of moving averages)

Now it is changed to compare the values of the moving averages. If that is not what you have in mind, thaen you have to change it, but you can not compare constant values and to expect that they are going to change from bar to bar

Check if those are the exact moving averages conditions (in the GetSignalClose() function) that you have imagined as exit conditions, but keep comparing the values of the moving averages not the parameters of those moving averages

Reason: