Skip to content

Instantly share code, notes, and snippets.

@igotit-anything
Last active July 2, 2022 14:13
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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