Skip to content

Instantly share code, notes, and snippets.

@igotit-anything
Last active July 2, 2022 14:13
Show Gist options
  • Save igotit-anything/2536b455074b602b75b3b00f2adad0ad to your computer and use it in GitHub Desktop.
Save igotit-anything/2536b455074b602b75b3b00f2adad0ad to your computer and use it in GitHub Desktop.
MQL5 Script example
//+------------------------------------------------------------------+
//| 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());
}
}
@igotit-anything
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment