Anybody have a solution??

 

I have a buy stop.

It is not the current price, but a future price. The lotsize is good. The stop loss is good. And the takeprofit is good.

I know the order is good because there is no error 130 or anything.

It just gives me invalid parameter. What is the invalid parameter???? Can the dealer just give out invalid parameter errror.

The price is a future price above the buy price because it is a buystop. Everything else is good. So where is the invalid parameter??????

It works really good in backtester. So why does it not work live. Is some asshole interrupting my connection or what?????

 
ckingher:

I have a buy stop.

It is not the current price, but a future price. The lotsize is good. The stop loss is good. And the takeprofit is good.

I know the order is good because there is no error 130 or anything.

It just gives me invalid parameter. What is the invalid parameter???? Can the dealer just give out invalid parameter errror.

The price is a future price above the buy price because it is a buystop. Everything else is good. So where is the invalid parameter??????

It works really good in backtester. So why does it not work live. Is some asshole interrupting my connection or what?????

you have some function, where you have too many parameters, check your ordersend function, to make sure that it has an appropriate number of parameters.


Ordersend function:

OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)


The following are the parameters in the ordersend function:

string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE

 

I said, I have tested my program. It works in the backtester real good.

Therefore, the ordersend function and its parameters are not the real problem.

What I wanted to know was: what other factor may trigger an invalid parameter error?

I believe that my system is probably having a concurrency problem. I have several charts opened.

And I believe that pending orders from the several charts are competing to send in the orders.

With all the charts competing, can this cause an invalid parameter error?????

This can be a factor, but then I am speculating and not sure. That is why I ask for opinions in the first place.

 

Are you delaying and or looping on a busy trade context, without a refresh and recalculating values?

Here's my code for the trade context:

//+------------------------------------------------------------------+
//| Trade context semaphore.                                         |
//+------------------------------------------------------------------+
#include <stderror.mqh>

int GetTradeContext(int MaxWaiting_sec = 30)
{   // This function replaces the IsTradeAllowed().
        #define TC_variable "TradeIsBusy"   // If there is no global variable,
    // the function creates it. If TC_variable == 1 when called, the function
    // waits until another thread sets it back to 0, and then replaces.
    // Return codes:
        #define TC_LOCKED        0  //  Success. The global variable TC_variable
    //                                  was set to 1, locking out others.
        #define TC_REFESHED     +1  //  Success. The trade context was initially
    //                                  busy, but became free. The market info
    //                                  has been refreshed. Recompute trade
    //                                  values if necessary.
        #define TC_ERROR        -1  //  Error, interrupted by the user. The
    //                                  expert was removed from the chart, the
    //                                  terminal was closed, the chart period
    //                                  and/or symbol was changed, etc.)
        #define TC_TIMEOUT      -2  //  Error, the wait limit was exceeded.
    ////////////////////////////////////////////////////////////////////////////

    if ( IsTesting() )  return(TC_LOCKED);  // Only one EA runs under the tester
                                            // Context always available.
    int startWaitingTime    = GetTickCount(),
        needRefresh         = TC_LOCKED;        // Assume no problems.

//---- Repeat until we get the semaphore and the context is free.
    #define TCSTEP_LOCK 1
    #define TCSTEP_BUSY 2
    for(int step = TCSTEP_LOCK; step <= TCSTEP_BUSY; ) {
        if ( IsStopped() ) {    // The expert was terminated by the user, abort.
            Print("The expert was terminated by the user!");
            return(TC_ERROR);
        }

        if (TCSTEP_LOCK == step) {  // Set the semaphore
            if (!GlobalVariableSetOnCondition( TC_variable, 1.0, 0.0 )) {
                int _GetLastError   = GetLastError();
                switch(_GetLastError) {
                    case 0:                         // Variable exists but is
                        break;                      // already set. Need to wait

                    case ERR_OBJECT_DOES_NOT_EXIST:         // unlock returned
                    case ERR_GLOBAL_VARIABLE_NOT_FOUND:
                        GlobalVariableSet(TC_variable, 0.0);    // Create it.
                        _GetLastError   = GetLastError();
                        if (_GetLastError != 0) Print(
                            "GetTradeContext: GlobalVariableSet(", TC_variable,
                            ", 0.0) Failed: ",  GetLastError() );   // Error
                        break;                                  // Unexpected

                    default:
                        Print(  "GetTradeContext:GlobalVariableSetOnCondition('",
                                TC_variable, "',1.0,0.0)-Error #", _GetLastError);
                        break;
                }   // switch(_GetLastError)
            } else {
                step++;     // Semaphore now set
            }
        }   // TCSTEP_LOCK == step
        if (TCSTEP_BUSY == step) {  // Wait for idle context (Non-semaphore EAs)
            if ( !IsTradeContextBusy() ) break; // Cleanup and return.
        }                                       // Need to wait.

        int delay   = ( GetTickCount() - startWaitingTime ) / 1000;
        if (delay > MaxWaiting_sec) {   // Wait time exceeds maximum, abort.
            Print("Waiting time (", MaxWaiting_sec, " sec) exceeded!");
            return(TC_TIMEOUT);
        }

        Comment("Wait until another expert finishes trading...", delay);
        needRefresh = TC_REFESHED;      // Will need to refresh.
        Sleep(1000);
    }   // for(step)

    if (needRefresh == TC_REFESHED) {
        Comment("EA ver: ",Version);
        RefreshRates();
    }
    return(needRefresh);
}   // GetTradeContext(MaxWaiting_sec)

void RelTradeContext() {
    // The function sets the value of the global variable GetTradeContext = 0.
    ////////////////////////////////////////////////////////////////////////////
    while( !IsTesting() ) {
        GlobalVariableSet(TC_variable, 0.0);
        int _GetLastError   = GetLastError();
        if (_GetLastError == 0) break;
        Print(  "RelTradeContext: GlobalVariableSet('",
                TC_variable,"',0.0)-Error #", _GetLastError );
        Sleep(100);
    }
}   // void RelTradeContext()

Reason: