Forum

how to have an EA use a manual entry as input

//Open Buy Order, instant signal is tested first RefreshRates(); if (Cross( 0 , iStochastic ( NULL , PERIOD_CURRENT , 34 , 3 , 3 , MODE_SMA , 0 ,MODE_MAIN, 0 )> iStochastic ( NULL , PERIOD_CURRENT , 34 , 3 , 3 , MODE_SMA , 0 ,MODE_SIGNAL, 0 )) ) { RefreshRates(); price=Ask;

need help formating date-time string

currently, using this date1 = StringSubstr (date1, 0 , 4 ) + "-" + StringSubstr (date1, 5 , 2 ) + "-" + StringSubstr (date1, 8 , 2 ); string time1 = TimeToStr( iTime (ccy,tf,i), TIME_MINUTES ); FileWrite (handle, date1 + " " + time1); which gives me, for example, this 2018 - 07 - 20 21

How to get volume for single currency, not pair?

For example is it possible to use iVolume on just the EUR and not the EURUSD or just the USD and not the EURUSD? Thanks

I always get 1?

int return_price( int ttype) { //function that returns price int price= 0 ; for ( int cnt= 0 ;cnt< OrdersTotal ();cnt++) { bool result= OrderSelect (cnt,SELECT_BY_POS,MODE_TRADES); if (OrderType()==ttype && OrderMagicNumber()!= 666 && OrderMagicNumber()!= 667 )

OrderClose error 4051 invalid ticket for OrderClose function

Im facing this error when I try to retrieve the oldest ticket in my current pool of trades using the functions below, int EarliestOpenSellTicket() { datetime EarliestSellTime = TimeCurrent (); //initialize it to the current server time. You will have no orders newer than that. int

scanning historical trades to prevent opening multiple trades of the same type

void hedger() { int buy_trades_number = _get_number_of_trades( OP_BUY ); int sell_trades_number = _get_number_of_trades( OP_SELL ); int numberofhedgedbuys = _get_number_of_trades_hedge_buy( OP_BUY ); int numberofhedgedsells = _get_number_of_trades_hedge_sell( OP_SELL ); for ( int n=

why doesnt this simple loop work?

for ( int n= 0 ; n<total; n++ ){ if ( ! OrderSelect (n, SELECT_BY_POS , MODE_TRADES ) ) if ( OrderMagicNumber ()!= 333 && number_of_buys == 7 ) OrderSend ( Symbol (), OP_SELL , 50 , Bid , 3 , 0 , 0 , "hedged" , 333 , 0 , clrRed ); if ( OrderMagicNumber ()!= 334 && number_of_sells

What is wrong in my code? Getting error 138

int Close1B() { int Close1B=- 1 ; // None open. for ( int cnt= OrdersTotal ()- 1 ;cnt>= 0 ;cnt--) { OrderSelect (cnt, SELECT_BY_POS , MODE_TRADES ); //if( ! OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES) ) continue; if ( OrderSymbol ()== Symbol ()

How to close the last trade EXACTLY at the open of the next trade?

So I have a system where I open a new trade every 10 pips and close out the last trade. The last trade is also modified to set the stop loss to 10 pips. Currently, I have a function that does this: void TradeCloser(){ //start int total = OrdersTotal (); if (total > 0 )