Ask! - page 138

 

You didn't quite follow or I wasn't clear enough

luxinterior:
Straight from the help file...

int iLowest( string symbol, int timeframe, int type, int count=WHOLE_ARRAY, int start=0)

Returns the shift of the least value over a specific number of periods depending on type.

Lux

Hi Lux,

Thanks for your input, but this wasn't what I was after. I am aware that this returns the lowest value and I have included it already as part of my script.

I need to know how to code the difference between the high and the low of each bar within a timeframe or array of bars and then take the shortest of these bars and use its height in pips as my take profit value.

Thanks again in advance

 
Bill FX:
Hi primajaya,

"CloseTrades_After_Account_Profit_Reached" is an EA (on the attach file). I want to combine this EA in to another EA.

Thanks for your help!

Just make new function according to the EA... and put it into int start() function...

Test this:

extern double My_Money_Profit_Target=300;

int start()

{

//Put The Close_Trade_Profit function just berfore return(0);

Close_Trade_Profit();

return(0);

}

void Close_Trade_Profit()

{

int Slippage=5;

int i;

if (AccountProfit()>= My_Money_Profit_Target)

{

for(i=OrdersTotal()-1;i>=0;i--)

{

OrderSelect(i, SELECT_BY_POS);

int type = OrderType();

bool result = false;

switch(type)

{

//Close opened long positions

case OP_BUY : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Pink);

break;

//Close opened short positions

case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Pink);

}

if(result == false)

{

Sleep(3000);

}

}

Print ("Account Profit Reached. All Open Trades Have Been Closed");

return(0);

}

Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),

"\nMy Account Profit Target: ",My_Money_Profit_Target);

}

 
primajaya:
Just make new function according to the EA... and put it into int start() function...

Hi primajaya,

There is 1 error " '}' - unbalanced parentheses " when I put this:

: //Put The Close_Trade_Profit function just berfore return(0);

Close_Trade_Profit();

return(0);

}

void Close_Trade_Profit()

{

int Slippage=5;

int i;

if (AccountProfit()>= My_Money_Profit_Target)

{

for(i=OrdersTotal()-1;i>=0;i--)

{

OrderSelect(i, SELECT_BY_POS);

int type = OrderType();

bool result = false;

switch(type)

{

//Close opened long positions

case OP_BUY : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Pink);

break;

//Close opened short positions

case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Pink);

}

if(result == false)

{

Sleep(3000);

}

}

Print ("Account Profit Reached. All Open Trades Have Been Closed");

return(0);

}

Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),

"\nMy Account Profit Target: ",My_Money_Profit_Target);

}

What's wrong ?

Thanks for your help!

 

Where from here?

Hi. I have produced some code

int start()

{

//----

Tick++; // Tick counter

datetime time = MarketInfo("EURUSD",MODE_TIME); //Counts each new tick

Alert("*Tick No: ", Tick," *Price: ", //with tick value &

DoubleToStr(Close[0], Digits)," *Time: ", //time.

TimeCurrent());

return; // start() exit operator

I now need to save Tick 1, 2 and 3 (value and time). On next Tick 1,2 and 3 again. How do I save the data for calculation later in the program?

 
Bill FX:
Hi primajaya,

There is 1 error " '}' - unbalanced parentheses " when I put this:

: //Put The Close_Trade_Profit function just berfore return(0);

Close_Trade_Profit();

return(0);

}

void Close_Trade_Profit()

{

int Slippage=5;

int i;

if (AccountProfit()>= My_Money_Profit_Target)

{

for(i=OrdersTotal()-1;i>=0;i--)

{

OrderSelect(i, SELECT_BY_POS);

int type = OrderType();

bool result = false;

switch(type)

{

//Close opened long positions

case OP_BUY : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,Pink);

break;

//Close opened short positions

case OP_SELL : result = OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,Pink);

}

if(result == false)

{

Sleep(3000);

}

}

Print ("Account Profit Reached. All Open Trades Have Been Closed");

return(0);

}

Comment("Balance: ",AccountBalance(),", Account Equity: ",AccountEquity(),", Account Profit: ",AccountProfit(),

"\nMy Account Profit Target: ",My_Money_Profit_Target);

}

What's wrong ?

Thanks for your help!

Oh mann... I'm sure you're totally beginner with ML4 coding...

I'm affraid this comment is the problem.....just delete this line...

://Put The Close_Trade_Profit function just berfore return(0);

if still error.........................................

Please upload your first EA... if you wish..

if you want to keep it secret... just PM me...

 
primajaya:
Oh mann... I'm sure you're totally beginner with ML4 coding...

I'm affraid this comment is the problem.....just delete this line...

://Put The Close_Trade_Profit function just berfore return(0);

if still error.........................................

Please upload your first EA... if you wish..

if you want to keep it secret... just PM me...

Ok. It's done !

Thanks for your help !

 

2-colored indi

Hi all,

The indi at the bottom (Complex_Pairs1) has only one color. Could anyone help me, and change it to 2 colors instead. Blue for going up, and Red for going down. Just like the indi on the chart (Execute Line).

I have been trying very hard to change the code myself, but with no succes.

After compiling there were no errors, but nothing happens when I try to open the indi.

This is probably a piece of cake for all you skilled coders, and hopefully I can learn from it.

Thank You!

Klondyke

Files:
 

Moving Average timezones

Is there a way to calculate the moving average of a diffent timezone than yours ? For example if your time is GMT+1, is it possible to calculate the 40 day moving average using close prices of GMT-7 ?

 

source code

Hi all,

I need a source code to add in my EA for limit timing for using a copy EA. Let's say I will give my EA to some one but I just let him use my EA for 1 month, so could you give me the source code and I just add it in to my EA ?

Thank you for your help,

 
Bill FX:
Hi all,

I need a source code to add in my EA for limit timing for using a copy EA. Let's say I will give my EA to some one but I just let him use my EA for 1 month, so could you give me the source code and I just add it in to my EA ?

Thank you for your help,

Please, see this links:

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

MQL4 programs protection! | www.metatrader.info

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

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

Reason: