Need a script for MT4
پوسٹ: 1
کب سے رکن ہے: 26/01/2012
Hey guys
Looking for a simple script to close one or many positions at a specific time I choose. If you have such, please, post it or give a download link.
Thanks!
پوسٹ: 734
کب سے رکن ہے: 22/04/2011
I found something very close to wat u want. But u need to know coding to change it according to ur needs
The good or ill of a man lies within his own will. – Epictetus
پوسٹ: 711
کب سے رکن ہے: 17/05/2011
پوسٹ: 734
کب سے رکن ہے: 22/04/2011
Originally posted by ChampHow to use these notepads" />. You also need to post a full tutorial on "how to use these notepads"" />.
Even I dont know exactly how to use it. I only copied it from another source. A developer can help in running this code.
The good or ill of a man lies within his own will. – Epictetus
پوسٹ: 836
کب سے رکن ہے: 16/05/2011
Originally posted by gerard
Hey guys
Looking for a simple script to close one or many positions at a specific time I choose. If you have such, please, post it or give a download link.
Thanks!
MT4 comes with many scripts already built into it. You can also make simple scripts even if u dont know programming. Just search on google for "make your own forex EA". You will get websites where u can make simple EAs easily.
پوسٹ: 28
کب سے رکن ہے: 25/01/2012
Scripts Don't work like that. Scripts only run once and are performed instantly by the user.
You need an EA . I have a Free EA - Discipline Trader EA - You can Insert the Time you wish to close the trades ( ALL) and it will do it for you.
پوسٹ: 28
کب سے رکن ہے: 25/01/2012
// Copy Paste into MetaEditor, then Save as into Experts Folder, then Compile
extern int TimeEnd_Hour = 23; // HOUR
extern int TimeEnd_Min = 59; // MIN
int Cur_Hour;int Cur_Min;bool result;double price;int cmd,error;
int start()
{
Cur_Hour=Hour();
Cur_Min=Minute();
if (Cur_Hour>=TimeEnd_Hour && Cur_Min>=TimeEnd_Min)
{
if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES))
{
cmd=OrderType();
//---- first order is buy or sell
if(cmd==OP_BUY || cmd==OP_SELL)
{
while(true)
{
if(cmd==OP_BUY) price=Bid;
else price=Ask;
result=OrderClose(OrderTicket(),OrderLots(),price,3,White);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
else error=0;
if(error==135) RefreshRates();
else break;
}
}
}
}
else Print( "Error when order select ", GetLastError());
//----
return(0);
}
//+------------------------------------------------------------------+
Or use this code. I haven't tried it, but it should work
پوسٹ: 561
کب سے رکن ہے: 21/04/2011
پوسٹ: 7
کب سے رکن ہے: 19/12/2012
Originally posted by gerard
Hey guys
Looking for a simple script to close one or many positions at a specific time I choose. If you have such, please, post it or give a download link.
Thanks!
closed any open trade at specific time??will you closed your open trade on loss condition :)
try this
put it on script folde (mt4/expert/script)
#property copyright "Mn"
#property show_confirm
#property show_inputs
#include <stdlib.mqh>
extern int mSlippage = 3;
extern double mProfTgt = 1000;
extern string mCAP = "**** USE ENTIRELY AT OWN RISK *****";
extern string mCAPx = "**** Profit level above which the order closes *****";
extern double mProfit = 100.00;
extern string mCAPxx = "** TAKE CARE SETTING THESE OPTIONS *****";
extern string mCAPxxx = "** Set to 1 for all pairs : Set to 0 for CurrentChart Only *****";
extern int mAllSymbol = 0;
extern string mCAPxxxx = "** Set to 1 to close Longs in profit : 0 to ignore Longs *****";
extern int mLong = 1;
extern string mCAPxxxxx = "** Set to 1 to close Shorts in profit : 0 to ignore Shorts *****";
extern int mShort = 1;
// ---------------------------------------------------------------------------------- +
int start()
{
int mType, mTotal = OrdersTotal();
double mTotProf = 0;
for(int i = mTotal - 1; i >= 0; i--)
{
OrderSelect(i, SELECT_BY_POS);
mType = OrderType();
bool mResult = false;
if(OrderSymbol() == Symbol() || mAllSymbol == 1)
{
mTotProf += OrderProfit();
}
}
if(mTotProf > mProfTgt)
{
for(i = mTotal - 1; i >= 0; i--)
{
OrderSelect(i, SELECT_BY_POS);
mType = OrderType();
mResult = false;
if(OrderSymbol() == Symbol() || mAllSymbol == 1)
{
switch(mType)
{
case OP_BUY :
{
if(mLong == 1)
mResult = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE );
break;
}
case OP_SELL :
{
if(mShort == 1)
mResult = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE );
break;
}
default :
break;
}
if(mResult == false)
{
Alert("Order " , OrderTicket() , " Failed to close. Error:" , GetLastError() );
Sleep(2000);
}
} // if(OrderSymbol
} // for i
} // if mTotProf
return(0);
}
cheer
#1 Forex expert advisor vendor Tasukigap Ea
پوسٹ: 836
کب سے رکن ہے: 16/05/2011
Hello tasuki gap.
Will this script close only profitable trades or all trades? or will it ask for a time to close trades?