Ask! - page 61

 

Code Question

Please disregard post. This setting did what I needed it to do. Thanks for begin there to help us.

I have modified an EA to work with several methods. I have done some research but can not figure out how to add the name of the EA to the comments field when opening an order. Can someone please point me in the right direction.

I am hoping there is a simple string command that I can integrate into any EA I modify so that the orders are better organized when running more than one EA during a test.

Thanks for your time and insight.

Here is one of the non-modified sections I will need to change to input the EA comment.

if(ObjectFind(BuyStop_TrendName) == 0)

{

SetObject("Active" + BuyStop_TrendName,

ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),

ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) + BuyStop_StepActive*Point,

ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),

ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) + BuyStop_StepActive*Point,

ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));

SetObject("Prepare" + BuyStop_TrendName,

ObjectGet(BuyStop_TrendName, OBJPROP_TIME1),

ObjectGet(BuyStop_TrendName, OBJPROP_PRICE1) - BuyStop_StepPrepare*Point,

ObjectGet(BuyStop_TrendName, OBJPROP_TIME2),

ObjectGet(BuyStop_TrendName, OBJPROP_PRICE2) - BuyStop_StepPrepare*Point,

ObjectGet(BuyStop_TrendName, OBJPROP_COLOR));

vA = NormalizeDouble(ObjectGetValueByShift("Active"+BuyStop_TrendName,0),Digits);

vM = NormalizeDouble(ObjectGetValueByShift(BuyStop_TrendName,0),Digits);

vP = NormalizeDouble(ObjectGetValueByShift("Prepare"+BuyStop_TrendName,0),Digits);

sl = vA - BuyStop_StopLoss*Point;

tp = vA + BuyStop_TakeProfit*Point;

if(Ask = vP && OrderFind(MagicBuyStop) == false)

if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"", MagicBuyStop, 0, Green) < 0)

Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);

if(Ask = vP && OrderFind(MagicBuyStop) == true &&

glbOrderType == OP_BUYSTOP)

{

OrderSelect(glbOrderTicket, SELECT_BY_TICKET, MODE_TRADES);

if(vA != OrderOpenPrice())

if(OrderModify(glbOrderTicket, vA, sl, tp, 0, Green) == false)

Print("Err (", GetLastError(), ") Modify BuyStop Price= ", vA,

" SL= ", sl, " TP= ", tp);

}

if(Ask < vP && OrderFind(MagicBuyStop) == true &&

glbOrderType == OP_BUYSTOP && AutoClose==true)

{

OrderDelete(glbOrderTicket);

}

}

[/code]

I am not sure of the logic but can I just input the CommentName in the following location? I have not tested this but it compiles fine.

[code]

if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"CommentName", MagicBuyStop, 0, Green) < 0)

Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);

Files:
 

Thank you Coderguru for being here for us!

I have a question about Alerts.

I want to change the alert type in this code so it will play a wav file that I choose and not have the popup window buy sell thing. Just play wav file when fractal apears.

How should the code be. I have attached the sFractals alert indicator.

if(PrevSignal <= 0 )

{

if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = 1;

Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");

}

}

if(PrevSignal >= 0)

{

if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = -1;

Alert("sFractals (", Symbol(), ", ", Period(), ") - SELL!!!");

}

}

Files:
sfractals.mq4  8 kb
 
proverbs:
I am not sure of the logic but can I just input the CommentName in the following location? I have not tested this but it compiles fine.

if(OrderSend(Symbol(), OP_BUYSTOP, BuyStop_Lot, vA, 3, sl, tp,"CommentName", MagicBuyStop, 0, Green) < 0)

Print("Err (", GetLastError(), ") Open BuyStop Price= ", vA, " SL= ", sl," TP= ", tp);

That will work fine. You can also put a string variable in that place.

 
Drivefast:
Thank you Coderguru for being here for us!

I have a question about Alerts.

I want to change the alert type in this code so it will play a wav file that I choose and not have the popup window buy sell thing. Just play wav file when fractal apears.

How should the code be. I have attached the sFractals alert indicator.

if(PrevSignal <= 0 )

{

if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = 1;

Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");

}

}

if(PrevSignal >= 0)

{

if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = -1;

Alert("sFractals (", Symbol(), ", ", Period(), ") - SELL!!!");

}

}

I think CodersGuru died or something. He hasn't been around in a while.

Anyway.... add this statement:

PlaySound("alert.wav");

.... where "alert.wav" is the name of the file that you want to play.

 
ryanklefas:
I think CodersGuru died or something. He hasn't been around in a while.

Anyway.... add this statement:

PlaySound("alert.wav");

.... where "alert.wav" is the name of the file that you want to play.

Thank you for responding to my post.

I am not sure about where to put PlaySound("alert.wav"); in the code.

Can I just delete this part? Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");

Or, does it need to be something like this?

PrevSignal = 1;

PlaySound("alert.wav");

Alert("sFractals (", Symbol(), ", ", Period(), ") - BUY!!!");

 

Yep. Just replace the entire alert with the sound.

if(PrevSignal <= 0 )

{

if(ExtDownFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = 1;

PlaySound("alert.wav");

}

}

if(PrevSignal >= 0)

{

if(ExtUpFractalsBuffer[SIGNAL_BAR] > 0)

{

PrevSignal = -1;

PlaySound("alert.wav");

}

}
 

Thank you ryanklefas for all your help it works just like I want it to now.

 

Ask about sorting

I have a data table, 2 dimensional, stored into a 2 dimensional array. I want to do some manipulation, such as sorting according to any column from that data table.

The ArraySort() function, in the instruction, can sort arrays on its 1st dimension. I don't see how that can works for me.

Any suggestions about data table sorting on MetaTrader?

 

Communication Betwen Expert Advisor

Hello,

i want to know if there's a way to communicate between expert advisor, let say i have EA A as main strategy

and backup EA B as backup strategy

i place it on 2 different pair..

i want to trigger if EA A are in drawdown position, start EA B...

when cummulative profit for EA A and EA B has reach some target point..

close all positions from EA A and EA B

is that possible to do ?

 
veematics:
Hello,

i want to know if there's a way to communicate between expert advisor, let say i have EA A as main strategy

and backup EA B as backup strategy

i place it on 2 different pair..

i want to trigger if EA A are in drawdown position, start EA B...

when cummulative profit for EA A and EA B has reach some target point..

close all positions from EA A and EA B

is that possible to do ?

I think global variables would be the thing you are looking for. You can check them out in the MetaEditor reference section. To view your current global variables, press F3 in the MT4 terminal.