How to code? - page 275

 
alvintran:
No no , it not problem SL/TP, i know that problem, i said it do nothing, it is mean on demo account ( instant execution or something i don't know) it work fine,but on live account it not work,not have any problem, just do nothing.

This EA by me writed, not buy, not trial version, not any limited.

Please ! help

Post the quotes here, and I'm sure somebody will hell you.

 
alvintran:
No no , it not problem SL/TP, i know that problem, i said it do nothing, it is mean on demo account ( instant execution or something i don't know) it work fine,but on live account it not work,not have any problem, just do nothing.

This EA by me writed, not buy, not trial version, not any limited.

Please ! help

Ok, but post this EA, I can help you but i need code.

Cheers,

Grzesiek

 

How to get 2-dimension array to file and than get back it to another array in next EA

Hi!

could somebody help me and explain how can i get 2-dimension array (i.e. double array[x][y] where x=100, y=30) to inside a file and than how can i get back the numbers from this file to an array in otehr EA? 1-dimension is much easier!!!

I found this article: Three-Dimensional Graphs - a Professional Tool of Market Analyzing - MQL4 Articles but i don't know how can I read the file with numbers from this file in my secound EA...

Additionally i'd like to save big precision of my numbers and i was pondering to use FileWriteDouble() funcion (in binary).

Could somebody help me - i appreciate it a lot!

thank You!

 
g.pociejewski:
Ok, but post this EA, I can help you but i need code.

Cheers,

Grzesiek

Fist thank you everybody !

Like i said, my EA have not any problem, I know problem you said, in market execution must open fist after that modify position ( if not it will show order(130) error ) . But my EA have not any problem ,just do nothing.

I give you condition before open a position :

if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

//Open buy order

}

Cheers Grzesiek ! i can not share this EA, please ! contact me on skype (duong_4sao) or yahoo (tieuthienma88), we will have a disscus .

I hope you can help me. Thanks !

 
alvintran:
Fist thank you everybody !

Like i said, my EA have not any problem, I know problem you said, in market execution must open fist after that modify position ( if not it will show order(130) error ) . But my EA have not any problem ,just do nothing.

I give you condition before open a position :

if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount)))) {

//Open buy order

}

Cheers Grzesiek ! i can not share this EA, please ! contact me on skype (duong_4sao) or yahoo (tieuthienma88), we will have a disscus .

I hope you can help me. Thanks !

Why you are asking for help????

 

ECN brokers and Stop Loss

I am new to MQL programming . Please help me .

I am trying to have a stop loss with an Market orders . What is the best way to acheive this. I tried with ordersend but it turned

out that ECN brokers does not support stop loss with market orders.

I search and only info i found is that we need to first have a pending order and then modify that order .

I tried this and the problem is in many cases the pending order is already executed before the modify order so the ordermodify fails

Here is the order sell for Market order :

STicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,null,MagicNumber,0,red);

Here is the order modify :

OrderSelect(SlTicket, SELECT_BY_TICKET);

OpenPrice = OrderOpenPrice();

{ double SellStopLoss = OpenPrice - (StopLoss * UsePoint);

bool TicketMod1 = OrderModify(SellTicket ,OrderOpenPrice() , SellStopLoss , 0,0);

}

This stop method works sometimes and sometimes marker order is already executed so ordermodify fails.

Please help me acheive stoploss order for ECN brokers !!!!

 
winston99:
I am new to MQL programming . Please help me .

I am trying to have a stop loss with an Market orders . What is the best way to acheive this. I tried with ordersend but it turned

out that ECN brokers does not support stop loss with market orders.

I search and only info i found is that we need to first have a pending order and then modify that order .

I tried this and the problem is in many cases the pending order is already executed before the modify order so the ordermodify fails

Here is the order sell for Market order :

STicket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,0,0,0,null,MagicNumber,0,red);

Here is the order modify :

OrderSelect(SlTicket, SELECT_BY_TICKET);

OpenPrice = OrderOpenPrice();

{ double SellStopLoss = OpenPrice - (StopLoss * UsePoint);

bool TicketMod1 = OrderModify(SellTicket ,OrderOpenPrice() , SellStopLoss , 0,0);

}

This stop method works sometimes and sometimes marker order is already executed so ordermodify fails.

Please help me acheive stoploss order for ECN brokers !!!!

only way to acheive stoploss in ECN brokers is to send order without stops and modify it.

I use:

ticket=OrderSend(Symbol(),OP_SELL,lots,Bid, slippage,0,0,comment,magic);

OrderSelect(ticket,SELECT_BY_TICKET);

OrderModify(ticket,OrderOpenPrice(),sltpValue(Ask +StopLoss*Point, StopLoss),sltpValue(Bid- TakeProfit*Point,TakeProfit),0);

and don't have any problems( sltp give us Sl/TP value).

 
g.pociejewski:
only way to acheive stoploss in ECN brokers is to send order without stops and modify it.

I use:

ticket=OrderSend(Symbol(),OP_SELL,lots,Bid, slippage,0,0,comment,magic);

OrderSelect(ticket,SELECT_BY_TICKET);

OrderModify(ticket,OrderOpenPrice(),sltpValue(Ask +StopLoss*Point, StopLoss),sltpValue(Bid- TakeProfit*Point,TakeProfit),0);

and don't have any problems( sltp give us Sl/TP value).

how to you calculate slippage ?

I am passing 0 for that may be thats why it a problem.

 

zig zag help

Hi,

I'm trying to write an ea based on zigzag and pitchfork.

to draw pitchfork i need price and time of last 4 zigzag

i get the price with ICustom()

but I don't know how to get the Time

Please help me

thanks in advance

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

this is for price...

int n0, n1, n2, n3, i0, i1, i2, i3 = 0;

double zig0, zig1, zig2, zig3;

while(n3<4)

{

zig3=iCustom(NULL, 0, "ZigZag", 0, i3);

if(zig3>0) n3+=1;

i3++;

}

while(n2<3)

{

zig2=iCustom(NULL, 0, "ZigZag", 0, i2);

if(zig2>0) n2+=1;

i2++;

}

while(n1<2)

{

zig1=iCustom(NULL, 0, "ZigZag", 0, i1);

if(zig1>0) n1+=1;

i1++;

}

while(n0<1)

{

zig0=iCustom(NULL, 0, "ZigZag", 0, i0);

if(zig0>0) n0+=1;

i0++;

}

...........................................

 

small change needed for indi

This is code for daily boxes but I need some changes-I want to have gap where tokio market closes and london opens.So lets say that box is blue (for whole day) and gap should be white

#property indicator_chart_window

int gi_76 = 50;

string gs_80 = "00:00";

string gs_88 = "23:59";

extern color Color_Up = Lavender;

extern color Color_Down = Wheat;

extern color Color_Neutral = LightGray;

bool gi_108 = TRUE;

double gd_112;

int g_color_120 = Red;

void init() {

DeleteObjects();

for (int l_count_0 = 0; l_count_0 < gi_76; l_count_0++) CreateObjects("PWT1" + l_count_0, g_color_120);

Comment("");

}

void start() {

int l_datetime_0 = TimeCurrent();

for (int l_count_4 = 0; l_count_4 < gi_76; l_count_4++) {

DrawObjects(l_datetime_0, "PWT1" + l_count_4, gs_80, gs_88);

for (l_datetime_0 = decDateTradeDay(l_datetime_0); TimeDayOfWeek(l_datetime_0) > 5; l_datetime_0 = decDateTradeDay(l_datetime_0)) {

}

}

}

void DrawObjects(int ai_0, string a_name_4, string as_12, string as_20) {

int l_str2time_28 = StrToTime(TimeToStr(ai_0, TIME_DATE) + " " + as_12);

int l_str2time_32 = StrToTime(TimeToStr(ai_0, TIME_DATE) + " " + as_20);

int l_shift_52 = iBarShift(NULL, 0, l_str2time_28);

int l_shift_56 = iBarShift(NULL, 0, l_str2time_32);

int l_shift_60 = iBarShift(NULL, PERIOD_D1, l_str2time_28);

if (iClose(NULL, PERIOD_D1, l_shift_60) - iOpen(NULL, PERIOD_D1, l_shift_60) > 0.0) gd_112 = iClose(NULL, PERIOD_D1, l_shift_60) - iOpen(NULL, PERIOD_D1, l_shift_60);

else gd_112 = iOpen(NULL, PERIOD_D1, l_shift_60) - iClose(NULL, PERIOD_D1, l_shift_60);

if (gd_112 < iATR(NULL, PERIOD_D1, 7, l_shift_60) / 100.0) g_color_120 = Color_Neutral;

else {

if (iOpen(NULL, PERIOD_D1, l_shift_60) > iClose(NULL, PERIOD_D1, l_shift_60)) g_color_120 = Color_Down;

else

if (iClose(NULL, PERIOD_D1, l_shift_60) > iOpen(NULL, PERIOD_D1, l_shift_60)) g_color_120 = Color_Up;

}

double l_high_36 = High;

double ld_44 = Low;

if (!gi_108) {

l_high_36 = 0;

ld_44 = 2.0 * ld_44;

}

ObjectSet(a_name_4, OBJPROP_TIME1, l_str2time_28);

ObjectSet(a_name_4, OBJPROP_PRICE1, l_high_36);

ObjectSet(a_name_4, OBJPROP_TIME2, l_str2time_32);

ObjectSet(a_name_4, OBJPROP_PRICE2, ld_44);

ObjectSet(a_name_4, OBJPROP_COLOR, g_color_120);

}

int decDateTradeDay(int ai_0) {

int li_4 = TimeYear(ai_0);

int li_8 = TimeMonth(ai_0);

int li_12 = TimeDay(ai_0);

int l_hour_16 = TimeHour(ai_0);

int l_minute_20 = TimeMinute(ai_0);

li_12--;

if (li_12 == 0) {

li_8--;

if (li_8 == 0) {

li_4--;

li_8 = 12;

}

if (li_8 == 1 || li_8 == 3 || li_8 == 5 || li_8 == 7 || li_8 == 8 || li_8 == 10 || li_8 == 12) li_12 = 31;

if (li_8 == 2) {

if (MathMod(li_4, 4) == 0.0) li_12 = 29;

else li_12 = 28;

}

if (li_8 == 4 || li_8 == 6 || li_8 == 9 || li_8 == 11) li_12 = 30;

}

return (StrToTime(li_4 + "." + li_8 + "." + li_12 + " " + l_hour_16 + ":" + l_minute_20));

}

void CreateObjects(string a_name_0, color a_color_8) {

ObjectCreate(a_name_0, OBJ_RECTANGLE, 0, 0, 0, 0, 0);

ObjectSet(a_name_0, OBJPROP_STYLE, STYLE_SOLID);

ObjectSet(a_name_0, OBJPROP_COLOR, a_color_8);

ObjectSet(a_name_0, OBJPROP_BACK, TRUE);

}

void DeleteObjects() {

for (int l_count_0 = 0; l_count_0 < gi_76; l_count_0++) ObjectDelete("PWT1" + l_count_0);

}

void deinit() {

DeleteObjects();

Comment("");

}