Forum

Trailing Stop Function Ineffective

void Trailing_Stop() { for ( int i = OrdersTotal () - 1 ; i >= 0 ; i--) { if (m_position.SelectByIndex(i)) { if (m_position.PositionType() == POSITION_TYPE_BUY ) { if (TrailingStop > 0 )

Array out of range

Hi All, I have written the code below as an attempt to create a function that limits the number of open positions by closing either the oldest or least profitable depending on input settings, the code compiles however when I run it on backtest I get an error message saying array out of range on line

Closing position in an array

Hi All, I am attempting to write a function that limits the number of open positions held by closing the least profitable trades, I have written the code as below but am having trouble with the PositionClose() function, is there something I am missing here? CSymbolInfo m_symbol;

closing profitable trades

Hi all, I am attempting to write a function that cycles through open positions and closes all those that are in profit by x amount and then returns true, and would return false in the case where no positions have been closed, I have the following code which seems to be ineffective, could someone

placing hedged position at key levels

#include <Expert\Expert.mqh> MqlTick last_tick; MqlTick tickarray[ 2 ]; double last_bid = last_tick.bid; double last_ask = last_tick.ask; int openpositions = PositionsTotal (); bool levelcheck(); double bsl = last_ask - 150 * _Point ; double btp = last_bid + 300 * _Point ; double ssl = last_bid +