|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Quote:
It's a very good idea to have a thread for the scrpits( mql2 & mql4). Hope to see this thread soon. |
|
|||
|
Trendline Script
Quote:
|
|
||||
|
Can you please help me with the referencing of the previous value on an indicator for example:
MovingAverage[2]
__________________
Pro FX Experts for Professional Meta Trader Experts Automate your manual method! We accept all major credit cards with no upfront payment required! |
|
|||
|
Here is a little script I wrote that closes all open positions. You need to check "Alow Live Trading" option under Options > Expert Advisor tab in order for this script to work.
To Setup: - Open up MetaEditor. - Click File > New - Select "Script program" - Select replace all text with code below - Compile & Run I hope you find it as useful as I do. Code:
//+------------------------------------------------------------------+
//| CLOSE_ALL.mq4 |
//| pileo|
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "pileo"
#property link "http://www.metaquotes.net"
#include <stdlib.mqh>
#include <WinUser32.mqh>
//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
if(MessageBox("Do you really want to close all positions?", "Close All", MB_YESNO|MB_ICONQUESTION) !=IDYES) return(1);
double prc;
int prc_mode;
int total = OrdersTotal();
int orders[];
int size;
size = ArrayResize(orders, total);
//Get original positions
for(int i=0;i<total;i++)
{
OrderSelect(i, SELECT_BY_POS);
orders[i] = OrderTicket();
}
if(size <= 0)
{
//No open orders
return(-1);
}
int ticketSent;
for(int x=0;x<size;x++)
{
OrderSelect(orders[x], SELECT_BY_TICKET);
if(OrderType()==OP_BUY)
prc_mode = MODE_BID;
else
prc_mode = MODE_ASK;
prc = MarketInfo(OrderSymbol(), prc_mode);
Print("Closing Order # ", orders[x], " symbol: ", OrderSymbol(), " price: ", prc);
if(OrderClose(orders[x],OrderLots(),prc,3))
{
Print("Order # ", orders[x], " closed");
}
else
{
Print("Failed to close Order # ", orders[x], " Error: ", GetLastError());
return(false);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| 'Close all'/'Open' tools | newdigital | Tools and utilities | 168 | 07-17-2008 08:27 PM |
| applying mt4 scripts | symtec23 | Metatrader 4 | 2 | 01-31-2006 02:44 PM |