How to send an HTTP request via MQL4 Expert Adviser? -


li have found code sends http request via mql4 expert adviser , modified personal ea logic.

technically, works, there huge problem, sends requests on every tick. need change - 1 request per each signal.

please me solve it!

code example:

#import    "shell32.dll" // -------------------------------<begofimport>-section  int shellexecutew( int    hwnd,                    string lpoperation,                    string lpfile,                    string lpparameters,                    string lpdirectory,                    int    nshowcmd                    );  #import // "shell32.dll" // -------------------------------<endofimport>-section   if (  > b    && 1 > orderstotal()       ) {    if (  ordersend( symbol(), op_sell, 1, bid, 10, 0, 0, 0, 0, 0, clrgreen )          )          orderselect( 0, select_by_pos, null );    shellexecutew( 0, "open", links, "", "", 1 );    } 

and how trading?

is ea sending trade requests on every tick?

currently tries send trade (which not guaranteed, i.e. requote or slippage or market closed / trading disabled etc.)

if need on each new signal - think maybe need check on each new bar, or keep recent trade direction in memory or recent time of signal in memory.

void ontick(){     if (  > b && orderstotal() < 1 ){          int ticket = ordersend( symbol(),op_sell,1,bid,10,0,0,0,0,0,clrgreen );          if (  ticket > 0 ){ // means ticket opened successfully, orderstotal = 1                if (  orderselect( 0, select_by_pos ) ) { } // what???          shellexecutew( 0, "open", links, "", "", 1 );       }    } }   

in such case, if ticket opened, shellexecute() called, in other cases - not.

not sure why orderselect() ticket, maybe stoplosses.

anyway should find out why rejected in case is

int   ticket  = ordersend( symbol(), op_sell, 1, bid, 10, 0, 0, 0, 0, 0, clrgreen ); if (  ticket >  0 ){  }else{    int error = getlasterror();    print( " failed send. error#", error ); } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -