Coding help - page 167

 

I want to use " CLOSE PRICE" instead of Median price in the below coding .... Plz help :

Thanks a lot

int start()

{

double ClosePrice=Close[0];

int limit, i, flag, flagh, trend[5000];

double up[5000], dn[5000], medianPrice, atr;

int counted_bars = IndicatorCounted();

//---- check for possible errors

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

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

if(counted_bars > 0) counted_bars--;

limit=Bars-1-counted_bars;

//Print(limit);

//----

for (i = Bars; i >= 1; i--) {

TrendUp = EMPTY_VALUE;

TrendDown = EMPTY_VALUE;

atr = iATR(NULL, 0, Nbr_Periods, i);

//Print("atr: "+atr);

medianPrice = (High+Low)/2;

//Print("medianPrice: "+medianPrice);

up=medianPrice+(Multiplier*atr);

//Print("up: "+up);

dn=medianPrice-(Multiplier*atr);

//Print("dn: "+dn);

trend=1;

if (Close>up) {

trend=1;

if (trend == -1) changeOfTrend = 1;

//Print("trend: "+trend);

}

else if (Close<dn) {

trend=-1;

if (trend == 1) changeOfTrend = 1;

//Print("trend: "+trend);

}

else if (trend==1) {

trend=1;

changeOfTrend = 0;

}

else if (trend==-1) {

trend=-1;

changeOfTrend = 0;

}

if (trend0) {

flag=1;

//Print("flag: "+flag);

}

else {

flag=0;

//Print("flagh: "+flag);

}

if (trend>0 && trend<0) {

flagh=1;

//Print("flagh: "+flagh);

}

else {

flagh=0;

//Print("flagh: "+flagh);

}

if (trend>0 && dn<dn)

dn=dn;

if (trendup)

up=up;

if (flag==1)

up=medianPrice+(Multiplier*atr);

if (flagh==1)

dn=medianPrice-(Multiplier*atr);

//-- Draw the indicator

if (trend==1) {

TrendUp=dn;

if (changeOfTrend == 1) {

TrendUp = TrendDown;

changeOfTrend = 0;

}

}

else if (trend==-1) {

TrendDown=up;

if (changeOfTrend == 1) {

TrendDown = TrendUp;

changeOfTrend = 0;

}

}

if (trend==1 && trend==-1) {

UpBuffer = iLow(Symbol(),0,i)-(3*Point);

DnBuffer = EMPTY_VALUE;

}

if (trend==-1 && trend==1) {

UpBuffer = EMPTY_VALUE;

DnBuffer = iHigh(Symbol(),0,i)+(3*Point);

}

}

WindowRedraw();

//----

return(0);

}

 
rpasupathy:
I want to use " CLOSE PRICE" instead of Median price in the below coding .... Plz help :

Thanks a lot

int start()

{

double ClosePrice=Close[0];

int limit, i, flag, flagh, trend[5000];

double up[5000], dn[5000], medianPrice, atr;

int counted_bars = IndicatorCounted();

//---- check for possible errors

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

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

if(counted_bars > 0) counted_bars--;

limit=Bars-1-counted_bars;

//Print(limit);

//----

for (i = Bars; i >= 1; i--) {

TrendUp = EMPTY_VALUE;

TrendDown = EMPTY_VALUE;

atr = iATR(NULL, 0, Nbr_Periods, i);

//Print("atr: "+atr);

medianPrice = (High+Low)/2;

//Print("medianPrice: "+medianPrice);

up=medianPrice+(Multiplier*atr);

//Print("up: "+up);

dn=medianPrice-(Multiplier*atr);

//Print("dn: "+dn);

trend=1;

if (Close>up) {

trend=1;

if (trend == -1) changeOfTrend = 1;

//Print("trend: "+trend);

}

else if (Close<dn) {

trend=-1;

if (trend == 1) changeOfTrend = 1;

//Print("trend: "+trend);

}

else if (trend==1) {

trend=1;

changeOfTrend = 0;

}

else if (trend==-1) {

trend=-1;

changeOfTrend = 0;

}

if (trend0) {

flag=1;

//Print("flag: "+flag);

}

else {

flag=0;

//Print("flagh: "+flag);

}

if (trend>0 && trend<0) {

flagh=1;

//Print("flagh: "+flagh);

}

else {

flagh=0;

//Print("flagh: "+flagh);

}

if (trend>0 && dn<dn)

dn=dn;

if (trendup)

up=up;

if (flag==1)

up=medianPrice+(Multiplier*atr);

if (flagh==1)

dn=medianPrice-(Multiplier*atr);

//-- Draw the indicator

if (trend==1) {

TrendUp=dn;

if (changeOfTrend == 1) {

TrendUp = TrendDown;

changeOfTrend = 0;

}

}

else if (trend==-1) {

TrendDown=up;

if (changeOfTrend == 1) {

TrendDown = TrendUp;

changeOfTrend = 0;

}

}

if (trend==1 && trend==-1) {

UpBuffer = iLow(Symbol(),0,i)-(3*Point);

DnBuffer = EMPTY_VALUE;

}

if (trend==-1 && trend==1) {

UpBuffer = EMPTY_VALUE;

DnBuffer = iHigh(Symbol(),0,i)+(3*Point);

}

}

WindowRedraw();

//----

return(0);

}

You can replace :

(High+Low)/2

with

Close

 
mladen:
kenwa

What autocheck symbol functionality are you talking about? There is no such thing in that code

All you have to do is to enter the symbol in the appropriate parameter field and it will work (on any symbol, as long as the symbol name is correct) Use the indicator the fareastol provided since it does all that you were talking about that you need it

hi mladen,

i see these inside:

if (ForSymbol1=="") ForSymbol1 = Symbol();

if (ForSymbol2=="") ForSymbol2 = Symbol();

if (ForSymbolSyn3a=="") ForSymbolSyn3a = Symbol();

if (ForSymbolSyn3b=="") ForSymbolSyn3b = Symbol();

if (ForSymbolSyn3c=="") ForSymbolSyn3c = Symbol();

some parts:

void checkSymbol(int limit, string ForSymbol, double& buffer[])

{

limit = MathMax(limit,MathMin(Bars-1,iCustom(ForSymbol,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));

for (int i=limit; i>=0; i--)

{

int y = iBarShift(ForSymbol,timeFrame,Time);

buffer = iCustom(ForSymbol,timeFrame,indicatorFileName,"calculateValue",MA_Period,MA_Method,CCI_Period,applied_price,"",0,y);

}

}

i cannot exact know what it is doing, as my ability cannot know its exact purpose, but from my raw guess, it seems the code is auto detect if we external input a symbol, then show on chart, if none is input, will show the local Null chart. then i will think if i intentionally leave several external input string to blank outside (filling nothing there), will the indicator repeatedly (at least superimpose) show the local Null chart several times? also how the code adapt to internal preset symbols? i do not know how exact to do, but i try , is it like the attachment way to do (to desensitize the external input symbol function/recognition)? or how to adapt modify to internal preset symbols ?

by the way, why the version i made before page 166 #1660, still repaint in live? what basic reasons cause such repaint? Thanks for advices.

 
kenwa:
hi mladen,

i see these inside:

if (ForSymbol1=="") ForSymbol1 = Symbol();

if (ForSymbol2=="") ForSymbol2 = Symbol();

if (ForSymbolSyn3a=="") ForSymbolSyn3a = Symbol();

if (ForSymbolSyn3b=="") ForSymbolSyn3b = Symbol();

if (ForSymbolSyn3c=="") ForSymbolSyn3c = Symbol();

some parts:

void checkSymbol(int limit, string ForSymbol, double& buffer[])

{

limit = MathMax(limit,MathMin(Bars-1,iCustom(ForSymbol,timeFrame,indicatorFileName,"returnBars",0,0)*timeFrame/Period()));

for (int i=limit; i>=0; i--)

{

int y = iBarShift(ForSymbol,timeFrame,Time);

buffer = iCustom(ForSymbol,timeFrame,indicatorFileName,"calculateValue",MA_Period,MA_Method,CCI_Period,applied_price,"",0,y);

}

}

i cannot exact know what it is doing, as my ability cannot know its exact purpose, but from my raw guess, it seems the code is auto detect if we external input a symbol, then show on chart, if none is input, will show the local Null chart. then i will think if i intentionally leave several external input string to blank outside (filling nothing there), will the indicator repeatedly (at least superimpose) show the local Null chart several times? also how the code adapt to internal preset symbols? i do not know how exact to do, but i try , is it like the attachment way to do (to desensitize the external input symbol function/recognition)? or how to adapt modify to internal preset symbols ?

by the way, why the version i made before page 166 #1660, still repaint in live? what basic reasons cause such repaint? Thanks for advices.

You can check the indicator from this post : https://www.mql5.com/en/forum/178416/page19 to see how some additional controls can be done

 

for #1664, read and download before, i cannot adapt the codes, too advanced & complex to me.

 
kenwa:
for #1664, read and download before, i cannot adapt the codes, too advanced & complex to me.

Not everything can be written in two lines. In some cases it is impossible

 
fareastol:
Hi Mladen

Related to my request to calculate POC and VA for a target band based on a given market profile, I have tried as hard as possible. Unfortunately, I've only gained POC value. Getting VA High/Low values are beyond of my current ability.

Besides, at the week beginning, the original indicator Level Sensor seems to have error in its code, causing terrible display as you can see in attached picture. I can't understand what reason, just guessing it relates to conflicts between MT4 default display and data of lower timeframe (<W1).

Please have a look and give me advice to move on.

Thanks deeply,

fareastol

fareastol

That thing on screen is happening because there is a time gap on chart between last Friday data and first Sunday or Monday data and when xshift time is added to the times of the line.

One possible solution is the one from this version : to invert the display and instead of displaying it from right to left to display it from left to right (like on the picture). So far haven't found a solution for right to left display

Files:
 

Sometimes all it takes is to think a bit (as soon as I finished the prvious post the idea was there )

Here is the "right to left" solution (as far as I tested it it works OK now)

 

Hi,

I have calculated the standard deviation line "by hand".

Now I want to draw a channel like the original Deviation Channel from the metatrader.

But I don't know how to calculate the factor = 0.618 to my normal deviation line so that it works like the original channel ...OBJPROP_DEVIATION,0.618)

 

Hi Mladen,

You remind me many meaningful things and motivate me much.

Thanks for all

fareastol