How to code? - page 208

 

To fxbg

Adjust your logic. When you close the order by program, you change CurrentDirection to 0, but, if it is closed by stoploss - not.

 
 

Comparing values

Hi all,

Very simple question as I am not sure that I understood properly values of indicators !?

I have values like this:

laADX00 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,0);

laADXP0 = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,0);

laADXM0 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,0);

laADX01 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,1);

laADXP1 = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,1);

laADXM1 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,1);

laADX02 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MAIN,2);

laADXP2 = iADX(NULL,0,14,PRICE_CLOSE,MODE_PLUSDI,2);

laADXM2 = iADX(NULL,0,14,PRICE_CLOSE,MODE_MINUSDI,2);

and if later on I have something like:

Addon= "";

if (laADX02 > laADX01 && laADX01 > laADX00) Addon= "Up laADX0";

if (laADX02 < laADX01 && laADX01 < laADX00) Addon= "Down laADX0";

if (laADX02 > laADX01 && laADX01 < laADX00) Addon= "Top laADX0";

if (laADX02 laADX00) Addon= "Bottom laADX0";

Print Addon.....

Addon= "";

if (laADXP2 > laADXP1 && laADXP1 > laADXP0) Addon= "Up laADXP";

if (laADXP2 < laADXP1 && laADXP1 < laADXP0) Addon= "Down laADXP";

if (laADXP2 > laADXP1 && laADXP1 < laADXP0) Addon= "Top laADXP";

if (laADXP2 laADXP0) Addon= "Bottom laADXP";

Print Addon.....

Addon= "";

if (laADXM2 > laADXM1 && laADXM1 > laADXM0) Addon= "Up laADXM";

if (laADXM2 < laADXM1 && laADXM1 < laADXM0) Addon= "Down laADXM";

if (laADXM2 > laADXM1 && laADXM1 < laADXM0) Addon= "Top laADXM";

if (laADXM2 laADXM0) Addon= "Bottom laADXM";

And I have printed that for example UP laADXM ...and on chart ADX DI- id going down or something else but not rising. Similar for RSI, CCI, MACD, ...

What is wrong here? I understood that defined like above laADX00 is value of ADX at the moment, laADX01 is value of ADX for previous bar at the moment when price is closed for that bar, laADX02 is value of ADX for 2 bars ago at the moment when price is closed for that bar. Is that correct or laADX01 is ADX value for previous tick and laADX02 for 2 ticks ago?

Can somebody clarify this to me please as charts and these definitions are not 1:1?

PS: I tested my EA in Strategy Simulator when I saw these contradiction results

Thanks in advance

Aleksandar

 

Sorry ... example was wrong ... this is from my script ... but anyhow simulator present it different than printed sentence

Addon= "";

if (laADX02 < laADX01 && laADX01 < laADX00) Addon= "Up laADX0";

if (laADX02 > laADX01 && laADX01 > laADX00) Addon= "Down laADX0";

if (laADX02 laADX00) Addon= "Top laADX0";

if (laADX02 > laADX01 && laADX01 < laADX00) Addon= "Bottom laADX0";

Print Addon.....

 

need help scripting

Hi!

Need help understanding how to use orderselect().

I'd like to know if it's possible to set a variable with the same value of orderprofit() .

Thank You

 

One more thing is there a way to close all open orders???

Thanks

 

Smoothing within indicator

I am trying to modify one of the bollinger percent b indicators posted here. I want (firstly anyway) to add simply an option to smooth the data with a moving average and place the result in Buffer3. Could someone please show me where I am going wrong.

if(counted_bars>=BBPeriod) i=Bars-counted_bars-1;

while(i>=0)

{ //(Last - Lower BB)/(Upper BB - Lower BB)

BLGBuffer=((Close - iBands(NULL,0,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i))/

(iBands(NULL,0,BBPeriod,StdDeviation,0,AppliedPrice,MODE_UPPER,i)-iBands(NULL,0,BBPeriod,StdDeviation,0,AppliedPrice,MODE_LOWER,i)))*100;

//m_level refers to the bollinger bands centre line. i.e. 21MA

mlevel=iMA(NULL,0,BBPeriod,0,BollingerMAMethod,AppliedPrice,0);

Buffer3 = iMAOnArray(BLGBuffer, 0, SmoothingMAPeriod, 0, SmoothingMAMethod, i);

i--;

}
 

just try

try the sign #

code

# this is not a code #

how to insert the image over here ?
 
 
Reason: