You must use a constant when declaring and sizing an array at the same time.
Otherwise declare the array and size it.
input int FASTEMA = 50; int start() { double MAXIMUM[]; ArrayResize(MAXIMUM,FASTEMA); {
You must use a constant when declaring and sizing an array at the same time.
Otherwise declare the array and size it.
Hey, can i ask 1 more question?
Is it possible to close position if the indicator's color change? i.e. closing position on indicator's color not the indicator's value
Hey, can i ask 1 more question?
Is it possible to close position if the indicator's color change? i.e. closing position on indicator's color not the indicator's value
Indicators don't have a colour.
Indicators may use objects or lines etc and these may have a colour.
If a line/histogram has 2 colours, then it may use 2 buffers. You will need to check the values of both buffers to see which colour is showing for the particular bar.
Indicators don't have a colour.
Indicators may use objects or lines etc and these may have a colour.
If a line/histogram has 2 colours, then it may use 2 buffers. You will need to check the values of both buffers to see which colour is showing for the particular bar.
Oh yeap, so in my code, when indicator is rising, the buffer color is green, when fall = red, when sideway = white.
Is it possible to code in a way that will close my current position if the buffer color turns red?
Also, is there a way to limit opening position that would allow only 1 long and 1 short position?
Sorry for having so many questions.
Oh yeap, so in my code, when indicator is rising, the buffer color is green, when fall = red, when sideway = white.
Is it possible to code in a way that will close my current position if the buffer color turns red?
A buffer colour does not change, a buffer is either displayed or not displayed.
Find out which buffer is the red buffer and check its value. Usually if it is not displayed, its value will be EMPTY_VALUE, so if it has a different value, the line etc is being displayed as red.
A buffer colour does not change, a buffer is either displayed or not displayed.
Find out which buffer is the red buffer and check its value. Usually if it is not displayed, its value will be EMPTY_VALUE, so if it has a different value, the line etc is being displayed as red.
I see, I will try different ways to see if it works or not.
Also, is there a way to limit opening position that would allow only 1 long and 1 short position?
Also, is there a way to limit opening position that would allow only 1 long and 1 short position?
Yes.
Show your code and you will receive some help.
Yes.
Show your code and you will receive some help.
Currently its
//Long if((Bars > BarsCount) && (OrdersTotal() == 0)) { if(SecondCustom > ThirdCustom) if(Custom> SecondCustom) if(Custom< MaxLongCustom) { LongOrder(); } //Short// if(ThirdCustom> SecondCustom ) if(SecondCustom > Custom) if(MaxShortCustom < Custom) { ShortOrder(); } }
Currently, the only way i know to limit order is with OrdersTotal(), however is there other way to limit opening position to allowing maximum of 1 long and short positions (1 of each)?
Currently its
Currently, the only way i know to limit order is with OrdersTotal(), however is there other way to limit opening position to allowing maximum of 1 long and short positions (1 of each)?
Count the buys and sells first and use the results
int buys=0,sells=0; for(int x=OrdersTotal()-1; x>=0; x--) { if(OrderSelect(x,SELECT_BY_POS)) if(OrderType()==OP_BUY) buys++; else if(OrderType()==OP_SELL) sells++; }
Work like a Charm! Thank you!
Back to the "Find out which buffer is the red buffer and check its value. Usually if it is not displayed, its value will be EMPTY_VALUE, so if it has a different value, the line etc is being displayed as red."
How do I check my iCustom's buffer value? Currently I have three colors, Green, Red, White. (Buffer 1 = Green, Buffer 2 = Red, Buffer 3 = White).

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
This may sound abit stupid to professional coder but is it not possible to use variable as array, as there will be invalid index value (i tried understanding it but i seem to not be able to)
Example Code would be
However, if it use
It works, can somebody explain why I cannot substitute FASTEMA for 50?
And whether there is a way to make it substitutable?
Thank you.