Requests & Ideas - page 60

 

" Need your HELP "

Hi Mr.mladen,

When I was compiled that source, why there is ERROR like this : " ) ' - wrong parameter count....

this is for code Sir' :

#property copyright "Test"

#property link "http://www.test.com"

#include

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

extern int Secend = 3600;

//extern int Secend = 300;

extern double Lot = 1;

extern double SL = 10;

extern double TP = 5;

extern double Slippage_Open = 1;

extern double Slippage_Close = 1;

extern string Comments = "example";

extern int MagicNumber = 123456;

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

int init()

{

//----

start();

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| expert start function |

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

int start()

{

//----

int Last_openorder_time = Secend+1 ;

int Last_historyorder_time = Secend+10;

closeOrders();

if(OrdersTotal() > 0 )

{

OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);

Last_openorder_time = TimeCurrent() - OrderOpenTime();

if( Last_openorder_time > Secend )

{

GetOrder ( "buy" ) ; return(0);

}

}

else if( OrdersHistoryTotal() > 0 )

{

OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);

Last_historyorder_time = TimeCurrent() - OrderOpenTime();

if( Last_historyorder_time > Secend )

{

GetOrder ( "buy" ) ; return(0);

}

}

//

//

//

// no opened orders yet, open the first order

//

//

else GetOrder ( "buy" );

//----

return(0);

}

//====================================== Send Order ===========================================

int GetOrder(string cmd)

{

double stoploss =0;

double takeprofit =0;

int Ticket=0;

int lastError=0;

//

//

// pip multiplier needed for 5 digit brokers to convert point into pips

//

//

int pipMultiplier = 1;

if (Digits==3 || Digits==5) pipMultiplier=10;

if(cmd == "buy")

{

if(TP == 0 ) takeprofit = 0;

else takeprofit = MarketInfo(Symbol(),MODE_ASK) + TP * Point*pipMultiplier;

if(SL == 0 ) stoploss = 0;

else stoploss = MarketInfo(Symbol(),MODE_ASK) - SL * Point*pipMultiplier;

Print("Buy Order Sent With: Symbol=", Symbol(), " Lot=", Lot, " Price=", MarketInfo(Symbol(),MODE_ASK));

Ticket = OrderSend(Symbol(), OP_BUY, Lot, MarketInfo(Symbol(),MODE_ASK), Slippage_Open, stoploss, takeprofit, Comments, MagicNumber, 0, Blue);

if (Ticket < 0)

{

lastError = GetLastError(); // save last error because GetLastError() clears the error number and than you do not

// know what the error code was when calling ErrorDescription() function

Print("OrderSend failed with error #", lastError, " ", ErrorDescription(lastError));

}

}

else if(cmd == "sell")

{

if(TP == 0 ) takeprofit = 0;

else takeprofit = MarketInfo(Symbol(),MODE_BID) - TP * Point*pipMultiplier;

if(SL == 0 ) stoploss = 0;

else stoploss = MarketInfo(Symbol(),MODE_BID) + SL * Point*pipMultiplier;

Print("Sell Order Sent With: Symbol=", Symbol(), " Lot=", Lot, " Price=", MarketInfo(Symbol(),MODE_BID));

Ticket = OrderSend(Symbol(), OP_SELL, Lot, MarketInfo(Symbol(),MODE_BID), Slippage_Open, stoploss, takeprofit, Comments, MagicNumber, 0, Blue);

if (Ticket < 0)

{

lastError = GetLastError();

Print("OrderSend failed with error #", lastError, " ", ErrorDescription(lastError));

}

}

return (Ticket);

}

//----------------------------------------------------------------------------------------

//

//----------------------------------------------------------------------------------------

//

//

// close orders

// example usage : closeOrders(OP_BUY,PERIOD_H1); will close buys that are opened at a previous or older 1 hour bar

// example usage : closeOrders(OP_SELL,PERIOD_H4); will close sells that are opened at a previous or older 4 hour bar

//

//

//

void closeOrders(int orderType, int timeFrameToCheck)

{

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

{

if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)==false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderType() != orderType) continue;

if(OrderSymbol() != Symbol()) continue;

//

//

//

// check if order has to be closed at all

// it is checking the target time frame (use PERIOD_H1 in timeFrameToCheck

// if you want to close an order after 1 hour bar has expired)

//

//

//

int y = iBarShift(Symbol(),timeFrameToCheck,OrderOpenTime()); // target time frame bar of the order open time

int c = iBarShift(Symbol(),timeFrameToCheck,Time[0]); // target time frame bar of the current bar

if (y<=c) continue; // if the bar is lees (opened after - in some errors case)

// or the bar is the same, no need to close this opened order

//

//

//

//

//

RefreshRates();

switch(orderType)

{

case OP_BUY : OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE); break;

case OP_SELL : OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE); break;

}

}

}

Thank you so much for your kindness Sir' and helping me.

Please forgive if I'm disturbing you.

Best regards,

Paulinge

 
Paulinge:
Hi Mr.mladen,

When I was compiled that source, why there is ERROR like this : " ) ' - wrong parameter count....

this is for code Sir' :

#property copyright "Test"

#property link "http://www.test.com"

#include

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

extern int Secend = 3600;

//extern int Secend = 300;

extern double Lot = 1;

extern double SL = 10;

extern double TP = 5;

extern double Slippage_Open = 1;

extern double Slippage_Close = 1;

extern string Comments = "example";

extern int MagicNumber = 123456;

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

int init()

{

//----

start();

//----

return(0);

}

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

//| expert deinitialization function |

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

int deinit()

{

//----

//----

return(0);

}

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

//| expert start function |

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

int start()

{

//----

int Last_openorder_time = Secend+1 ;

int Last_historyorder_time = Secend+10;

closeOrders();

if(OrdersTotal() > 0 )

{

OrderSelect(OrdersTotal()-1, SELECT_BY_POS, MODE_TRADES);

Last_openorder_time = TimeCurrent() - OrderOpenTime();

if( Last_openorder_time > Secend )

{

GetOrder ( "buy" ) ; return(0);

}

}

else if( OrdersHistoryTotal() > 0 )

{

OrderSelect(OrdersHistoryTotal()-1, SELECT_BY_POS, MODE_HISTORY);

Last_historyorder_time = TimeCurrent() - OrderOpenTime();

if( Last_historyorder_time > Secend )

{

GetOrder ( "buy" ) ; return(0);

}

}

//

//

//

// no opened orders yet, open the first order

//

//

else GetOrder ( "buy" );

//----

return(0);

}

//====================================== Send Order ===========================================

int GetOrder(string cmd)

{

double stoploss =0;

double takeprofit =0;

int Ticket=0;

int lastError=0;

//

//

// pip multiplier needed for 5 digit brokers to convert point into pips

//

//

int pipMultiplier = 1;

if (Digits==3 || Digits==5) pipMultiplier=10;

if(cmd == "buy")

{

if(TP == 0 ) takeprofit = 0;

else takeprofit = MarketInfo(Symbol(),MODE_ASK) + TP * Point*pipMultiplier;

if(SL == 0 ) stoploss = 0;

else stoploss = MarketInfo(Symbol(),MODE_ASK) - SL * Point*pipMultiplier;

Print("Buy Order Sent With: Symbol=", Symbol(), " Lot=", Lot, " Price=", MarketInfo(Symbol(),MODE_ASK));

Ticket = OrderSend(Symbol(), OP_BUY, Lot, MarketInfo(Symbol(),MODE_ASK), Slippage_Open, stoploss, takeprofit, Comments, MagicNumber, 0, Blue);

if (Ticket < 0)

{

lastError = GetLastError(); // save last error because GetLastError() clears the error number and than you do not

// know what the error code was when calling ErrorDescription() function

Print("OrderSend failed with error #", lastError, " ", ErrorDescription(lastError));

}

}

else if(cmd == "sell")

{

if(TP == 0 ) takeprofit = 0;

else takeprofit = MarketInfo(Symbol(),MODE_BID) - TP * Point*pipMultiplier;

if(SL == 0 ) stoploss = 0;

else stoploss = MarketInfo(Symbol(),MODE_BID) + SL * Point*pipMultiplier;

Print("Sell Order Sent With: Symbol=", Symbol(), " Lot=", Lot, " Price=", MarketInfo(Symbol(),MODE_BID));

Ticket = OrderSend(Symbol(), OP_SELL, Lot, MarketInfo(Symbol(),MODE_BID), Slippage_Open, stoploss, takeprofit, Comments, MagicNumber, 0, Blue);

if (Ticket < 0)

{

lastError = GetLastError();

Print("OrderSend failed with error #", lastError, " ", ErrorDescription(lastError));

}

}

return (Ticket);

}

//----------------------------------------------------------------------------------------

//

//----------------------------------------------------------------------------------------

//

//

// close orders

// example usage : closeOrders(OP_BUY,PERIOD_H1); will close buys that are opened at a previous or older 1 hour bar

// example usage : closeOrders(OP_SELL,PERIOD_H4); will close sells that are opened at a previous or older 4 hour bar

//

//

//

void closeOrders(int orderType, int timeFrameToCheck)

{

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

{

if(OrderSelect(i,SELECT_BY_POS, MODE_TRADES)==false) break;

if(OrderMagicNumber() != MagicNumber) continue;

if(OrderType() != orderType) continue;

if(OrderSymbol() != Symbol()) continue;

//

//

//

// check if order has to be closed at all

// it is checking the target time frame (use PERIOD_H1 in timeFrameToCheck

// if you want to close an order after 1 hour bar has expired)

//

//

//

int y = iBarShift(Symbol(),timeFrameToCheck,OrderOpenTime()); // target time frame bar of the order open time

int c = iBarShift(Symbol(),timeFrameToCheck,Time[0]); // target time frame bar of the current bar

if (y<=c) continue; // if the bar is lees (opened after - in some errors case)

// or the bar is the same, no need to close this opened order

//

//

//

//

//

RefreshRates();

switch(orderType)

{

case OP_BUY : OrderClose(OrderTicket(),OrderLots(),Bid,0,CLR_NONE); break;

case OP_SELL : OrderClose(OrderTicket(),OrderLots(),Ask,0,CLR_NONE); break;

}

}

}

Thank you so much for your kindness Sir' and helping me.

Please forgive if I'm disturbing you.

Best regards,

Paulinge

Paulinge you were very close from what i can see you needed to add

closeOrders(OP_BUY,PERIOD_H1);

closeOrders(OP_SELL,PERIOD_H1);

right after the start routine, not 100% sure but think you can make the timeperiods an external parameter, which would make it easier to test other timeframes.

Files:
test.mq4  5 kb
 

Hi Mladen..,

I think it is entirely out of the context of this thread, but it is just a question that has been sitting in the corner of my mind for a long time since i read it somewhere and since there were conflicting views, i was a little confused., but i think now you are the only right person that i can ask this, even though it sounds silly (the question that is), i think i should ask it to put an end to the speculation for my part though.

Is it possible for the MT4 broker to know what indicators i'm using while trading, the settings i'm using, etc., (not that i've found a holy grail, ha ha). Though it sounds a little on the edge of paranoia, there was a code developed by some guy to mask the winning EA or indicator u r using from the broker.

regards,

Paapi

 

" The Sample of Simple learning EA "

Hi Mr. tools,

Thank you so much Sir'.... thank's for you have done !!!!

And now the Sample of EA was running well.....

You and Mr. mladen was a GREAT and a MASTER.....

Thank's GOD this forum have the both of you..... Very very nice and SMART people.. a Place to everybody can ask and discuss clearly.....

Thank you so much to both of you for helping and kindness.

Best regards,

Paulinge

mrtools:
Paulinge you were very close from what i can see you needed to add

closeOrders(OP_BUY,PERIOD_H1);

closeOrders(OP_SELL,PERIOD_H1);

right after the start routine, not 100% sure but think you can make the timeperiods an external parameter, which would make it easier to test other timeframes.
 

Flytox

Posted it here : https://www.mql5.com/en/forum/179686/page3

regards

Mladen

Flytox:
Hi Mr Mladen

is it possible, when you have time, to do the same with your cfb channel.

Thx
 

You rock Mr Mladen.

Thx again.

 

Hi Mladen..,

I've got one more request. Can you please create an indicator that draws vertical lines on the chart depending on the GMT shift i want for each new day..., like if i want GMT+2, the indicator should draw vertical line at the start of new day for GMT+2 and this GMT shift should be changeable to whatever periods i want.

regards,

paapi

 

" Need Your HELP "

Hi Mr.mladen,

Can you helping me to change code this indicator as to be visible in Chart, NOT in separate windows.

Thank you so much for your helping and kindness Sir'.

Best regards,

Paulinge

 

Paulinge

All that needs to be done is to change line where it is saying :
#property indicator_separate_window
to
#property indicator_chart_window
Anyway, attaching the changed one too

A pleasant weekend to all

regards

Mladen

Paulinge:
Hi Mr.mladen,

Can you helping me to change code this indicator as to be visible in Chart, NOT in separate windows.

Thank you so much for your helping and kindness Sir'.

Best regards,

Paulinge
 

" Thank you "

Hi Mr.mladen,

Thank you so much Sir'.

You are right, A pleasant weekend to all.

Best regards,

Paulinge

mladen:
Paulinge All that needs to be done is to change line where it is saying :
#property indicator_separate_window
to
#property indicator_chart_window
Anyway, attaching the changed one too

A pleasant weekend to all

regards

Mladen
Reason: