Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
WHEN do you want to use a STATIC variable - what problems can it solve?
WHEN do you want to put something in the INIT() section - what problems does it solve?
Big Be
A static variable will remain the same with every function call that that variable is in, unless it's changed in the function of course. You may want an integer in that function only that you want to increase by 1 for example every function call.
But, you could aswell use global variables for this.
Example of init:
int init() {
TakeProfit=TakeProfit*Point;
StopLoss=StopLoss*Point;
TrailingStop=TrailingStop*Point;
breakEven=breakEven*Point;
return(0);
}
These are extern variables and you set takeprofit to 50 for example if you want 50 pips. But for this to work in the EA it must be multiplicated with the pip value of the currency 0.001 for example.
A static variable will remain the same with every function call that that variable is in, unless it's changed in the function of course. You may want an integer in that function only that you want to increase by 1 for example every function call.
But, you could aswell use global variables for this.
...
Simon-
Thanks. Please help make it clear:
Does this mean a static variable holds the last value assigned to it even though it is not global?
Regarding init(), it looks like it is used as a setup function.
- Can you tell me other good examples for it?
is there any ma indicator that color change according to the close of the candle.For example if the candle close above SMA then the line color is blue but if below MA then the color will change to red.
I know there is a indicator that has called "ma_in_color.mq4" sorry but i don't know how to post it, my question is, of there is anybody out there, who could program an sound alert in this indicator.
What is the easiest way to get the buffer values of an indicator to either display as a comment or print out in the experts folder so I can see the values change?? I have 8 buffers in this indicator.
Does this mean a static variable holds the last value assigned to it even though it is not global?
Yes, but it can be used inside of that function only. You can have global variables with the same name as the static variable (I'm 99% sure), but it's good use not too, so you don't mix things up.
The other questions someone else might want to answer as I'm not sure.
Hi I have a quick question. Im trying to code an EA where I will only be able to open one trade per bar. So when I use the 1H timeframe I can only open one order. I tried to add this line to limit the amount of orders, but it does not work.
Hi Guys,
How do you change an alert indicator into a trading EA?
I've tried changing the command Alert(Symbol()+" "+Period()+" XO Long ",Bid); into OrderSend(Symbol(),OP_BUY,0.01,Ask,3,20,20,"XO-CCI",1,0,Blue); at the start I chose menu to make EA, then content of my alert indicator, i copied to this EA, then I changed the command alert to trading command as above, then i compiled. But the compiled EA is not making any trade after i tried it on 1M chart for a day.