Coding help - page 197

 
mladen:
You can add it to draw those additional lines once more - like this :
if (add>0) { drawLine(totalLevels,current+diff+add,addLinesColor,addLinesStyle); drawLine(totalLevels,current+diff-add ,addLinesColor,addLinesStyle); }
and it will draw those additional lines around all the "basic" lines

Again thank you mladen

 

Need help in programming a Alert

Hi, im new to the whole mql4 programming.

I want to create a new "all in one" alarm.

I have Fx MNT, Super Signal and CHT Value Chart with alarm signals.

Now i want to have only one alarm, when MNT,Super Signal,Value Chart & RSI is in the right place.

How to code this ? Can i use the alarm parts from the existing and put them all in one big code ?

kindly regards Slow

 
Slow Moe:
Hi, im new to the whole mql4 programming.

I want to create a new "all in one" alarm.

I have Fx MNT, Super Signal and CHT Value Chart with alarm signals.

Now i want to have only one alarm, when MNT,Super Signal,Value Chart & RSI is in the right place.

How to code this ? Can i use the alarm parts from the existing and put them all in one big code ?

kindly regards Slow

Slow

You can do that, but the code that would be "responsible" for fetching data from all those indicators would not be simple (especially the part with parameters where you would need to declare external parameters to all indicators that would be called in order to find out if alert should be triggered or not)

 

consecutive higher/lower closes

The attached file has a number of conditions which may be included by selecting true/false.

I would like to incorporate another condition as true/false: are there

2 consecutive higher closes for longs?

If there are, then if the other conditions enabled by true are present, then up arrow produced.

2 consecutive lower closes for shorts?

If there are, then if the other conditions enabled by true are present, then down arrow produced.

Could the number of closes be a variable?

Could someone code this extra condition into the Stoch_Indy indicator? Thank you.

Files:
 
person77:
The attached file has a number of conditions which may be included by selecting true/false.

I would like to incorporate another condition as true/false: are there

2 consecutive higher closes for longs?

If there are, then if the other conditions enabled by true are present, then up arrow produced.

2 consecutive lower closes for shorts?

If there are, then if the other conditions enabled by true are present, then down arrow produced.

Could the number of closes be a variable?

Could someone code this extra condition into the Stoch_Indy indicator? Thank you.

person77

Try this one out

Option UseConsecutiveCloseBars added for that purpose. Not just a close ids tested, but a close must be greater than open on such bars in order to make it a consecutive up, or it must be lower than open on such bars in order to make consecutive down

Files:
 
mladen:
person77

Try this one out

Option UseConsecutiveCloseBars added for that purpose. Not just a close ids tested, but a close must be greater than open on such bars in order to make it a consecutive up, or it must be lower than open on such bars in order to make consecutive down

Very nice mladen - works very well. Thank you!

In the few instances that I have come across, having C = O allowed is by and large favorable.

Could you change it to allow this, or, better yet, have an option whether or not C = O is allowed?

Files:
 
person77:

Very nice mladen - works very well. Thank you!

In the few instances that I have come across, having C = O allowed is by and large favorable.

Could you change it to allow this, or, better yet, have an option whether or not C = O is allowed?

person77

One more options added : AllowCloseEqualOpen. so you can control it with that option now

Files:
 

Hi guys,

I have a question about coding

Is it possible to draw Moving average on general chart with this preferences?

nCountedBars = IndicatorCounted();

dFactor = 2*3.14159/180.0;

mFactor = 10000.0;

 
cain82:
Hi guys,

I have a question about coding

Is it possible to draw Moving average on general chart with this preferences?

nCountedBars = IndicatorCounted();

dFactor = 2*3.14159/180.0;

mFactor = 10000.0;

What you have written (the dFactor and mFactor) all evaluates to a constant value regardless of the price and bar number, so you would have a horizontal line on chart

 
mladen:
What you have written (the dFactor and mFactor) all evaluates to a constant value regardless of the price and bar number, so you would have a horizontal line on chart

Thanks for reply!

But how can I get an angle lines of MA on the general chart like in this indi hystogramm code?

//---- indicator settings

#property indicator_separate_window

#property indicator_buffers 3

#property indicator_color1 LimeGreen

#property indicator_color2 FireBrick

#property indicator_color3 Yellow

#property indicator_width1 2

#property indicator_width2 2

#property indicator_width3 2

//---- indicator parameters

extern int TimeFrame = 60;

extern int MAMode = 0;

extern int MAPeriod = 50;

extern int Price = 4;

extern double AngleTreshold = 0.25;

extern int StartMAShift = 2;

extern int EndMAShift = 0;

extern int MaxBars = 500;

string TF1;

//---- indicator buffers

double UpBuffer[];

double DownBuffer[];

double ZeroBuffer[];

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

//| Custom indicator initialization function |

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

int init()

{

//---- 2 additional buffers are used for counting.

IndicatorBuffers(3);

//---- drawing settings

SetIndexStyle(0,DRAW_HISTOGRAM);

SetIndexStyle(1,DRAW_HISTOGRAM);

SetIndexStyle(2,DRAW_HISTOGRAM);

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

//---- 3 indicator buffers mapping

if(!SetIndexBuffer(0,UpBuffer) &&

!SetIndexBuffer(1,DownBuffer) &&

!SetIndexBuffer(2,ZeroBuffer))

Print("cannot set indicator buffers!");

SetIndexLabel(0,"");

SetIndexLabel(1,"");

SetIndexLabel(2,"");

switch(TimeFrame)

{

case 1: TF1="M1"; break;

case 5: TF1="M5"; break;

case 15: TF1="M15"; break;

case 30: TF1="M30"; break;

case 60: TF1="H1"; break;

case 240: TF1="H4"; break;

case 1440: TF1="D1"; break;

case 10080: TF1="W1"; break;

case 43200: TF1="MN1"; break;

default: {TimeFrame = Period(); init(); return(0);}

}

IndicatorShortName("MAAngle MTF * "+TF1+" *");

//---- initialization done

return(0);

}

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

//| The angle for EMA |

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

int start()

{

double fEndMA, fStartMA;

double fAngle, mFactor, dFactor;

int nLimit, i;

int nCountedBars;

double angle;

int ShiftDif;

string Sym;

if (MAMode >= 4) MAMode = 0;

if(EndMAShift >= StartMAShift)

{

Print("Error: EndMAShift >= StartMAShift");

StartMAShift = 6;

EndMAShift = 0;

}

nCountedBars = IndicatorCounted();

dFactor = 2*3.14159/180.0;

mFactor = 10000.0;

Sym = StringSubstr(Symbol(),3,3);

if (Sym == "JPY") mFactor = 100.0;

ShiftDif = StartMAShift-EndMAShift;

mFactor /= ShiftDif;

//---- check for possible errors

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

//---- last counted bar will be recounted

if(nCountedBars>0) nCountedBars--;

nLimit=Bars-nCountedBars;

nLimit=MathMax(nLimit,TimeFrame/Period());

nLimit=MathMin(nLimit,MaxBars );

//---- main loop

for(i=0; i<nLimit; i++)

{

int y = iBarShift(NULL,TimeFrame,Time);

if (TimeFrame<Period()) TimeFrame=Period();

fEndMA=iMA(NULL,TimeFrame,MAPeriod,0,MAMode,Price,y+EndMAShift);

fStartMA=iMA(NULL,TimeFrame,MAPeriod,0,MAMode,Price,y+StartMAShift);

// 10000.0 : Multiply by 10000 so that the fAngle is not too small

// for the indicator Window.

fAngle = mFactor * (fEndMA - fStartMA)/2.0;

//fAngle = MathArctan(fAngle)/dFactor;

DownBuffer = 0.0;

UpBuffer = 0.0;

ZeroBuffer = 0.0;

if(fAngle > AngleTreshold)

UpBuffer = fAngle;

else if (fAngle < -AngleTreshold)

DownBuffer = fAngle;

else ZeroBuffer = fAngle;

}

return(0);

}

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

Reason: