Coding help - page 294

 
mladen:
airquest

You must take it into account or else it will not work OK

The best way to call indicators with such parameter is the following :

iCustom(NULL,targetTimeFrame,indicatorName,"",...,buffer,shift);

So, use "" for that parameter

Thank you Mladen, as always, you're very helpfull.

 

would anyone be able to make this indicator plot on the open of the bar when present? the version in TradeStation will plot a higher time frame indicator plot (when present) on the lower time frame bar before price actually trades through the value. however, in the MT4 version this is not the case, and it will not plot until price has traded through it.

many thanks,

Scott

***

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 White

#property indicator_color2 White

//#property indicator_width1 5

//#property indicator_width2 5

//---- input parameters

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

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

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

extern int TimeFrame = 240;

extern int num = 6;

extern color Color = White;

double vftop[];

double vfbot[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

IndicatorBuffers(2);

SetIndexBuffer(0, vfbot);

SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 5, Color);

// SetIndexArrow(0, 117);

SetIndexEmptyValue(0, 0);

SetIndexBuffer(1, vftop);

SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 5, Color);

// SetIndexArrow(1, 117);

SetIndexEmptyValue(1, 0);

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("MTF_VolumeFinder ("+TimeFrameStr+")");

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int counted_bars=IndicatorCounted();

int i = Bars - counted_bars;

if(counted_bars == 0) i = Bars - num*2;

int j = 0;

double t1, t2;

int y = 0;

while(i >= 0)

{

y = iBarShift(Symbol(), TimeFrame, Time);

t1 = iLow(Symbol(), TimeFrame, y);

t2 = iHigh(Symbol(), TimeFrame, y);

for(j = y+1; j < y + num; j++)

{

t1 = MathMax(t1, iLow(Symbol(), TimeFrame, j));

t2 = MathMin(t2, iHigh(Symbol(), TimeFrame, j));

}

if(t1 <= t2)

{

vftop = t2;

vfbot = t1;

}

i--;

}

//----

return(0);

}

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

 
scott TTM:
would anyone be able to make this indicator plot on the open of the bar when present? the version in TradeStation will plot a higher time frame indicator plot (when present) on the lower time frame bar before price actually trades through the value. however, in the MT4 version this is not the case, and it will not plot until price has traded through it.

many thanks,

Scott

***

#property indicator_chart_window

#property indicator_buffers 2

#property indicator_color1 White

#property indicator_color2 White

//#property indicator_width1 5

//#property indicator_width2 5

//---- input parameters

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

PERIOD_M1 1

PERIOD_M5 5

PERIOD_M15 15

PERIOD_M30 30

PERIOD_H1 60

PERIOD_H4 240

PERIOD_D1 1440

PERIOD_W1 10080

PERIOD_MN1 43200

You must use the numeric value of the timeframe that you want to use

when you set the TimeFrame' value with the indicator inputs.

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

extern int TimeFrame = 240;

extern int num = 6;

extern color Color = White;

double vftop[];

double vfbot[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- indicators

IndicatorBuffers(2);

SetIndexBuffer(0, vfbot);

SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 5, Color);

// SetIndexArrow(0, 117);

SetIndexEmptyValue(0, 0);

SetIndexBuffer(1, vftop);

SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 5, Color);

// SetIndexArrow(1, 117);

SetIndexEmptyValue(1, 0);

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("MTF_VolumeFinder ("+TimeFrameStr+")");

//----

return(0);

}

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

//| Custom indicator deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| Custom indicator iteration function |

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

int start()

{

int counted_bars=IndicatorCounted();

int i = Bars - counted_bars;

if(counted_bars == 0) i = Bars - num*2;

int j = 0;

double t1, t2;

int y = 0;

while(i >= 0)

{

y = iBarShift(Symbol(), TimeFrame, Time);

t1 = iLow(Symbol(), TimeFrame, y);

t2 = iHigh(Symbol(), TimeFrame, y);

for(j = y+1; j < y + num; j++)

{

t1 = MathMax(t1, iLow(Symbol(), TimeFrame, j));

t2 = MathMin(t2, iHigh(Symbol(), TimeFrame, j));

}

if(t1 <= t2)

{

vftop = t2;

vfbot = t1;

}

i--;

}

//----

return(0);

}

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

Can you post the original tradestation code?

 

I searched for it, but cannot find it. I bought the indicator in 2004.

 
scott TTM:
I searched for it, but cannot find it. I bought the indicator in 2004.

I asked it since I would like compare the code - sometimes easy language code looks as a simple task to convert to metatrader but differences are too big to be 100% in some cases that the conversion is done as it should

 

Pls Help me

hi

Could you please help to Make it work for MT4 Build 600+

Thanks in advance!

Files:
sap_robot.mq4  32 kb
forexhacked.mq4  19 kb
 

WPR_MA bug

Hi mladen!

May I aks a little coding help?

I, kinda, wrote an indicator which is averaging 4 other WPR in one indicator window.

If you load the template, you can see the difference between the MA on WPRs.

Upper is the indicator, lower is manually mixed. The goal is, make the manual to an indicator.

My ask why is she doin that? Where I coded wrong the WPR_MA..

Thanks for your time

Adledion

Files:
 
adledion:
Hi mladen!

May I aks a little coding help?

I, kinda, wrote an indicator which is averaging 4 other WPR in one indicator window.

If you load the template, you can see the difference between the MA on WPRs.

Upper is the indicator, lower is manually mixed. The goal is, make the manual to an indicator.

My ask why is she doin that? Where I coded wrong the WPR_MA..

Thanks for your time

Adledion

Adledion

In the template ma is applied to only one WPR (WPR(50) in the case of that template). You can not apply ma to multiple indicators and that is why there is a difference between your indicator and template

Try it out - set all the WPR periods in your indicator to 50 and compare the values of the indicator to the previous value of ma in the template (previous since you use shift one in the indicator for iMAOnArray() ) and you will see that you are having exactly the same values in that case

 
mladen:
Adledion

In the template ma is applied to only one WPR (WPR(50) in the case of that template). You can not apply ma to multiple indicators and that is why there is a difference between your indicator and template

Try it out - set all the WPR periods in your indicator to 50 and compare the values of the indicator to the previous value of ma in the template (previous since you use shift one in the indicator for iMAOnArray() ) and you will see that you are having exactly the same values in that case

Wow, thanks, did not dig that deep

edit: and that means, in the manual mix the ma is just on one wpr? first indicators data..? so basically the manual is the wrong one (calculating one wpr ma), compared to my original idea, which is calculating 3 or 4 wpr ma.

 

Mladen ,

I am little puzzled are these 2 indicators repainting? https://www.mql5.com/en/forum/172895

What are those histograms representing do you know?Thanks.

Files:
forexmtn.mq4  3 kb
rd-combo.mq4  11 kb
Reason: