iCustom Value with another value ?

 

Hello there!

Quick question, I know you guys get a ton of these, but I hope someone cares enough to help me out.

My current EA logic looks like this;

double signaldown=iCustom(Symbol(),0,"OS",2,1)
double signalup=iCustom(Symbol(),0,"OS",1,1)

(both value's 1 & 2 are a number).

Now;

- I only want signaldown to trigger if value 2 > 4

- I only want signalup not to trigger if value 1 > -4

How do I do this?

Sorry if i'm not clear enough, not typing in my mother-tongue.

 

those values are the buffer index and the shift you have them set as constants

if you want to do such code so they can change during execution you need to set them as variables so then you can do something like

if ((int a > 4) && (int b > -4)) 
{double signaldown=iCustom(Symbol(),0,"OS",a,b)
}
 
SDC:

those values are the buffer index and the shift you have them set as constants

if you want to do such code so they can change during execution you need to set them as variables so then you can do something like


Thanks for the answer!

I tried this;

int down=iCustom(Symbol(),0,"OS",2,1)
int up=iCustom(Symbol(),0,"OS",1,1)

if (down>4)
{double signaldown;
}

if (up<=-4)
{double signalup;
}


It doesn't give any errors when compiling, however it also doesn't trade (no errors in the log).

Is the code correct (should I look for the mistake elsewhere)?
 
yes the mistake is not in the code you posted it is probably in the logic, you will have to post the rest of it if you need more help with it
 

You are right SDC, the logic itself was all wrong.

Works like a charm now, thanks!

 
Maybe not like a charm, a bit off-topic but too small to open a new thread;

When I run the EA in a backtest it prints the open/close positions correctly on the chart, however when I run it live it only prints the opening of the position ?

 
wickedwin:
Maybe not like a charm, a bit off-topic but too small to open a new thread;

When I run the EA in a backtest it prints the open/close positions correctly on the chart, however when I run it live it only prints the opening of the position ?

If you mean on Live it doesn't draw the extra arrow and line . . this is correct, the Strategy Tester does this for you, on Live/Demo you have to code it yourself if you want it . .
 
RaptorUK:
If you mean on Live it doesn't draw the extra arrow and line . . this is correct, the Strategy Tester does this for you, on Live/Demo you have to code it yourself if you want it . .


I see, then the error lies in the closing part (when the TP/SL is encountered).


Thanks, you guys are the best!

Reason: