MQL4 Learning - page 114

 
Drave Robber:
If it's entirely different, then you perhaps need ArraySetAsSeries.

It's not entirely different. I did try your suggestion, though, but there is no difference.

 

Need Help to debug While loop

Kindly help me debug the code (Tried back testing, it gets stuck on while loop).

Objective of the code:

1. The code needs to check for crossover.

2. If there is a Cross over, Monitor every next candle for Buy condition.

3. If the Buy Condition is satisfied, Set Value to Order variable and exit loop.

4. If Cross over condition is false exit loop.

if (Cross(TsenP, Tsen, KsenP, Ksen) == true) BuyCross = true; // Checks for Cross.

{

while (BuyCross == true)// Loop to be run after Crossover has happened.

{

i = 0;

if (Tsen >= Ksen)

{

if (i >= 0)

{

if (iIchimoku(NULL, 0, T1, T2, Span, MODE_TENKANSEN, i) >= iIchimoku(NULL, 0, T1, T2, Span, MODE_KIJUNSEN, i))

{

i++;

}

if ( Close >= Close &&

Pa > iIchimoku(NULL, 0, T1, T2, Span, MODE_TENKANSEN, i) &&

Bull(i) == true) // Check condition to Buy

{

Order = SIGNAL_BUY;

BuyCross = false;

break;

}

}

} else break;

} //End of while

}

Thanks guys....I have resolved the issue buy moving BuyCross variable as global and replacing while with if operator.

 

how to set stop loss and take profit when opening an order whose type is Market execu

Hello there

I have a problem setting the stoploss and takeprofit of some equities when I am opening orders. For some equities, when I try to open a new order, the dialog shows:

Symbol:...

Volume:...

Stop Loss:...

Comment:...

Type: "Market Execution"

and for other equities in the field Type it puts "Instant Execution" instead.

My problem comes when I try to open a new order whose field type contains "MarketExecution". In these cases, I cannot set the stoploss or the takeprofit at the time of opening the order because when I try, the dialog shows the message:

"Invalid S/L or T/P". For example, I try open buy with an equity whose Bid-Ask is 1.9800-1.9803 and try to put 1 as stop loss and 3 as takeprofit. Then I get the message: "Invalid S/L or T/P".

Therefore, I have to wait until the order is opened and then set the stoploss and takeprofit to the values I want but that seems really risky to me. I would prefer not to open any order without stoploss.

However, if the field type of the dialog of new order shows "Instant Execution" then when I try to set the stop loss and take profit, there is no problem at all and the order is opened with stop loss and take profit.

Would please anybody tell me what is happening here? I would appreciate if anybody could tell me how to open this kind of Market Execution orders with a stop loss and take profit without having to wait to put them until the order has been opened.

I look forward for your replies very soon.

Thanks in advance

 

Market Execution US Instant Execution

Hello there

Does anybody know any way to know from the inside of an expert advisor whether the order type for an equity is MarketExecution or InstantExecution? It is just because MarketExecution orders do not let put stop loss at the time of opening them. Otherwise an error message "Invalid S/L or T/P" is thrown in case you try to put the stop loss at the time of opening the Market Execution order.

Look forward your replies.

Thks in advance

 

How do I change Property Indicator Minimum and Maximum values using Extern Int?

Hello,

I have an idicator which I find very useful. The Maximum and Minimum scale values I find are important so I can read market sentiment by the magnitude of the variances.

Settings:

#property indicator_minimum -1.25

#property indicator_maximum 1.25

I am attempted to created a user-definable way of changing the scale by declaring Extern int and a variable name Scale_Min and Scale_Max in Inputs tab instead of modifying the numbers in the Common tab.

extern int Scale_Min = -1.25;

extern int Scale_Max = 1.25;

What I find though is I am required to define the Max and Min values next to the #property indicator_maximum and #property indicator_minimum whereas I'd rather vary the scale using inputs and hoped this would work:

Desired outcome

#property indicator_minimum Scale_Min (which would be -1.25)

#property indicator_maximum Scale_Max (would be 1.25 ) ... but it won't work!

Is there a way I can do this?

Any help greatly appreciated.

 

Wick Time ?

Hello all,

I am hoping that someone has come across this task in the past.

Is there a way to get the wick time ?

That would be the amount of time spent above / below a previous candle high / low.

I think I can use this to identify false breakouts.

When the ea is ready to place an order it will pause while the price is above / below the last candle high / low for x number of seconds / minutes, if after this time the price is still above / below then the trade is placed.

This is much appreciated. Thanks

 

In short, no

#property indicator_minimum and #property indicator_maximum are compile time defined variables (instructions) only and are not changeable or accessible in runtime.

What you can do is make 2 dummy buffers, set their visibility to not visible (something like this SetIndexStyle(number of buffer used,DRAW_NONE)) and then feel those buffers with constant values (+1.25 and -1.25 in your case). The trick is that even though they are not visible, they are going to set the bounds for cases when values of the indicator are in the range. The problem is that you are using 2 drawing buffers out of maximum 8 drawing buffers for that (so, you are left with 6 drawing buffers)

Newton51:
Hello,

I have an idicator which I find very useful. The Maximum and Minimum scale values I find are important so I can read market sentiment by the magnitude of the variances.

Settings:

#property indicator_minimum -1.25

#property indicator_maximum 1.25

I am attempted to created a user-definable way of changing the scale by declaring Extern int and a variable name Scale_Min and Scale_Max in Inputs tab instead of modifying the numbers in the Common tab.

extern int Scale_Min = -1.25;

extern int Scale_Max = 1.25;

What I find though is I am required to define the Max and Min values next to the #property indicator_maximum and #property indicator_minimum whereas I'd rather vary the scale using inputs and hoped this would work:

Desired outcome

#property indicator_minimum Scale_Min (which would be -1.25)

#property indicator_maximum Scale_Max (would be 1.25 ) ... but it won't work!

Is there a way I can do this?

Any help greatly appreciated.
 

MQL 4 need help

hello i am new to MQL4 and am unable to under what does this code mean:

thisCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift);

lastCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift + 1);

if (thisCCI >= 0 && lastCCI < 0) bufferUp[shift + 1] = bufferDn[shift + 1];

if (thisCCI 0) bufferDn[shift + 1] = bufferUp[shift + 1];

If shift is for e.g. 100. Then (shift +1) is previous bar or next bar? i.e. 101th bar or 99th bar?

Do reply because i am not able to understand the meaning of the code. This is a really helpful forum and i keep reading it whenever i get time.

 

Help guys! Really need your expertise

 
thestockbull:
hello i am new to MQL4 and am unable to under what does this code mean:

thisCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift);

lastCCI = iCCI(NULL, 0, CCI, PRICE_TYPICAL, shift + 1);

if (thisCCI >= 0 && lastCCI < 0) bufferUp[shift + 1] = bufferDn[shift + 1];

if (thisCCI 0) bufferDn[shift + 1] = bufferUp[shift + 1];

In MT4, the current bar is 0, previous bar is 1 and so forth. So if thisCCI shift=100, previous bar is bar 101.

Reason: