MQL5 Script example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//+------------------------------------------------------------------+ | |
//| CyClosePositionAll.mq5 | | |
//| igotit | | |
//| http://igotit.tistory.com | | |
//+------------------------------------------------------------------+ | |
#property copyright "igotit" | |
#property link "http://igotit.tistory.com" | |
#property version "1.00" | |
#include <Trade\Trade.mqh> | |
CTrade trade; | |
//+------------------------------------------------------------------+ | |
//| Script program start function | | |
//+------------------------------------------------------------------+ | |
///// close only one position which lowest ticket number. | |
void OnStart() // | |
{ | |
trade.PositionClose(Symbol()); | |
} | |
//+------------------------------------------------------------------+ | |
//// close all postion | |
void OnStart() | |
{ | |
int maxnum_position = PositionsTotal(); | |
for(int i=0; i<maxnum_position; i++ ) | |
{ | |
trade.PositionClose(Symbol()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://igotit.tistory.com/1832