Ask! - page 45

 
majlisb:
HI, professional

in example In an Ea we get a signal and we want to place a BUYSTOP/SellStop Order in hight of the signal bar,

We should wait to new bar open to find the Hight of signal bar , How we can do this ? (any article , post, EA , , , )

Thanks

If you count 3bars for signal now count 4bars simply yes ? Codersguru has a nice article about another way in mql4 site

 

I have a question:

This may require some additional programming that can't be done on MT. Not sure. Basically, I have an EA that both backtests and forward tests well in MT with Alpari data. On other broker's datafeeds, there is often a discrepancy between trades. Sometimes, if a trade is opened on Alpari, it may not be opened with a different broker or vice versa. Is it possible to write some kind of script that will execute trades on my broker's platform just after a trade is executed on Alpari's platform?

For example, I get a signal to buy 2 lots of cable at 1.9450 on Alpari. The trade is executed. That same order is then entered on my live broker's platform a split second later. When a stop or t/p level is hit on Alpari and the trade is closed, that same trade is then closed on my live broker's platform.

This is not a scalping system, so if there is a 2 pip discrepancy between the two prices, it's not a big deal. Does anyone know if this is possible, and if so, how do I go about doing it? Thank you.

 

Help with MTF xpMA

Codersguru,

Can you please check MTF capabilities of xpMA?

Many Thanks,

Pippt

Please see post #364 at:

https://www.mql5.com/en/forum/173574

 

simple question but i can't figure it out. what math function in mql is used to round out a double value?

say for example, i've got 0.69 and i want the result to be .70. or if the value is .63 and the result would be .60.

the mathceiling() and mathfloor() do not do the trick.

 

Beginners Question

Hello everyone...

Thanks to CodersGuru and his excellent course, I am attempting to learn MQL4

by converting an indicator I wrote in MQL3.

I have run into a snag and would appreciate some help... if someone could please tell me what I am doing wrong in the following code.

The problem is in the 2 If statements... at line 78 & 79

//+------------------------------------------------------------------+

//| First_Indicator.mq4 |

//| Codersguru |

//| https://www.mql5.com/en/forum |

//+------------------------------------------------------------------+

#property copyright "Codersguru"

#property link "https://www.forex-tsd.com"

#property indicator_chart_window

#property indicator_buffers 8

#property indicator_color1 Red

//---- buffers

double ExtMapBuffer1[];

//----------------- Variable Declarations ----------------------+

int pos=0;

double Pivot_Point = 0;

double new_Pivot_Point =0;

double prev_Pivot_Point=0;

double Pivot_Factor=0;

double LastClose=0;

//+------------------------------------------------------------------+

//| Custom indicator initialization function |

//+------------------------------------------------------------------+

int init()

{

//---- indicators

SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);

SetIndexBuffer(0,ExtMapBuffer1);

string short_name = "Pivot Line";

IndicatorShortName(short_name);

return(1);

}

//+------------------------------------------------------------------+

//| Custor indicator deinitialization function |

//+------------------------------------------------------------------+

int deinit()

{

return(0);

}

//+------------------------------------------------------------------+

//| Custom indicator iteration function |

//+------------------------------------------------------------------+

int start()

{

int counted_bars=IndicatorCounted();

//---- check for possible errors

if (counted_bars<0) return(-1);

//---- last counted bar will be recounted

if (counted_bars>0) counted_bars--;

int cnt=Bars-counted_bars;

//---- main calculation loop

while(cnt >= 0)

{

LastClose = Close[cnt];

If (LastClose > Pivot_Point) //Line 78

If(new_Pivot_Point > prev_Pivot_Point) //Line 79

{

prev_Pivot_Point = new_Pivot_Point;

Pivot_Point = new_Pivot_Point;

}

ExtMapBuffer1[cnt]= Pivot_Point ;

cnt--;

}

return(0);

}

These are the compiler messages -

---------------------------------------------------------------

'If' - function is not defined .....(78,10)

'If' - semicolon expected .....(79,13)

'If' - function is not defined ...(79, 13)

'{' - semicolon expected ....(80, 13)

----------------------------------------------------------------

No matter what I do, I can't seem to come up with what the problem is... I know it is very simple, but it is escaping me...

Thanks to all who can assist in this basic question....

Chief

P.S. Happy, Healthy, Prosperous New Year to ALL

 

MQL is case sensitive: use "if" instead of "If".

 

WOW... that was Fast....

THANK YOU so much for the fast reply... solved it...

your response is so very appreciated... have a great new year...

Chief

 

MathRound

BluePearl:
simple question but i can't figure it out. what math function in mql is used to round out a double value?

say for example, i've got 0.69 and i want the result to be .70. or if the value is .63 and the result would be .60.

the mathceiling() and mathfloor() do not do the trick.

There's "MathRound(double x)" which rounds a value to its nearest integer; same as "MathFloor(x+0.5)", I suppose. To get rounding to one decimal you can use a decimal shift/unshift expression like "MathRound(x*10)/10".

 

How can I add arrows to the attached to show up and down at the cross?

Files:
mtf_cross.mq4  5 kb
 

Histogram

Well, here is another question as I continue to learn how to convert from MQL3 to MQL4....

I would like to paint a section of the chart which lies between two lines, upper and lower. I don't know if there is any function to paint a screen section or not, so I decided to try using the "Draw_Histogram" in the SetIndexStyle() statement. But, I don't quite understand how it works. When I use it, nothing happens.

ex:

SetIndexStyle(7,DRAW_HISTOGRAM,0,1);

ExtMapBuffer8[cnt]= (Pivot_Point-(Short_Line*Point));

Print("Cnt = ",cnt," Histo = ",ExtMapBuffer8[cnt]," Calc = ",(Pivot_Point+(Short_Line*Point)));

The output in the journal produces the proper cnt, the proper calc but the Histo value is zero.

I have examined the code in the MACD indicator, to no avail, and in the Heiken-Ashi indicator, and I fail to understand how it works. The Heiken-Ashi indicator appears to use 4 buffers to create each candle, but I am not certain of that.

The MACD appears to use a baseline of zero, from which the histogram bar is drawn, is there a baseline from which it starts? If so, how does one go about establishing it?

Could someone please explain how this function works,so that I may learn how to code it properly. If there is a function that would paint a specified screen section, I would appreciate any info on that as well.

Thank you all for your kind assistance....

Sincerely,

Chief

Reason: