Ask! - page 54

 

possible solution for 0 buffer:

int currentBar=0;

double lowestFG=iCustom(NULL,0,"Forex-Grail Trade Indicator",period,PRICE_CLOSE,0, currentBar);

double highestFG = lowestFG;

for(;currentBar<4; currentBar++) lowestFG=MathMin(lowestFG, iCustom(NULL,0,"Forex-Grail Trade Indicator",period,PRICE_CLOSE,0,currentBar));

for(currentBar=0;currentBar<4; currentBar++) highestFG =MathMax(highestFG , iCustom(NULL,0,"Forex-Grail Trade Indicator",period,PRICE_CLOSE,0,currentBar));

you need to do all over again for buffer # 1

 
iscuba11:
How do I limit the amount of decimal places a comment statement shows on the graph. Right now it shows a variable result as .00347892, and I want it only to show .0035 (Rounded to the next number)??
Appreciate your input! Dave

function IndicatorDigits

 

First of all, I would like to thank all of you for helping me. I believe I can now put my new EA on line for testing.

I still have a question on decimal places.

The comment statement is being generated from the EA and not the indicator. The function indicatordigits, I believe, is used in the indicator itself and not the ea. Is there not a simple rounding off up to x places of a variable that I could use. Why they make this language so complicated. Even basic language could probably do this!

As always appreciated, feedback of knowledge and wisdom is welcome. Please help if you can.

Thanks a bunch!

 

I finally read your post correctly, try Comment(DoubleToStr(doubleVariable, 4));

 

That did it! Now to tweak and test. You all blessed me - Thanks!

Peace and Love to all, in Jesus Name! Reverend Dave
 

Need More Help Please!

if(currency_decimal == 2) OpenTriggerLevel = DoubleToStr(OpenTriggerLevel,2);

What I am attempting to do is have the EA automatically change the default OpenTriggerLevel from 4 decimal places to 2 when the user selects 2 (currency_decimal) from 4 in the EA setup. Such a change would have to take place on a currency like USDJPY which is 2 decimal places.

Evidently the compiler does not like the second ' = ' sign in the above statement.

With continued appreciation, Thanks in Advance for your input assistance!

Dave
 

MQL4 has predefined variable Digits which corresponds to number of decimal places of the pair.

DoubleToStr(OpenTriggerLevel, Digits);

the code is correct, look error in variable definition probably.

 
asmdev:
MQL4 has predefined variable Digits which corresponds to number of decimal places of the pair.

DoubleToStr(OpenTriggerLevel, Digits);

the code is correct, look error in variable definition probably.

I tried this, but it still displays OpenTriggerLevel as .0004 versus .04:

if(currency_decimal == 2) DoubleToStr(OpenTriggerLevel,2);

Still confused???

 
iscuba11:
if(currency_decimal == 2) OpenTriggerLevel = DoubleToStr(OpenTriggerLevel,2);[/PHP]

What I am attempting to do is have the EA automatically change the default OpenTriggerLevel from 4 decimal places to 2 when the user selects 2 (currency_decimal) from 4 in the EA setup. Such a change would have to take place on a currency like USDJPY which is 2 decimal places.

Evidently the compiler does not like the second ' = ' sign in the above statement.

With continued appreciation, Thanks in Advance for your input assistance!

Dave

The problem of that statement is that the variable 'OpenTriggerLevel' is of 'double' type, while the function returns a 'string'. So, while the code is syntactically correct, it's semantically wrong, and I would believe that's why the compiler complains.

If you want to carry the string in a variable, you'll need a variable to do so. Otherwise you can use the 'DoubleToStr' function within the 'Comment' argument to replace where it currently says 'OpenTriggerLevel'. There it could say

[PHP]DoubleToStr( OpenTriggerLevel, currency_decimal )

and you wouldn't need the 'if ..' statement at all.

 

anyone know how to get the total of each buy, sell, buystop, sellstop, buylimit and sellstop by the script? thanks

Reason: