Announcement

Collapse
No announcement yet.

HTTP help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP help

    Someone has written an API to a trade log database so that I can send trade calls via HTTP. I'm not really a web guy but this does seem very basic.

    If I paste the following URL into my browser's address bar everything works perfectly:

    "http://service.livetradingfloor.com/restapi/index.php/api/mwmf/addTradeCall/tid/12/setup/35/epic/GBPUSD/sector/-2-/direction/1/entry/3456/stoploss/3450/target/3464/ordertype/1/status/1"_

    so why doesn't the following script work.


    var reset = 0;

    function main() {

    if (reset == 0) reset=call();

    return;
    }

    function call() {
    HTTP("http://service.livetradingfloor.com/restapi/index.php/api/mwmf/addTradeCall/tid/12/setup/35/epic/GBPUSD/sector/-2-/direction/1/entry/3456/stoploss/3450/target/3464/ordertype/1/status/1");

    Alert.addToList(getSymbol(), "DONE", Color.red, Color.white);
    Alert.playSound("beep.wav");
    return 1;
    }

    Have I done something wrong and if so what? If not, how can I accomplish this.

    Please help - I'm desperate.

    Thank you.

  • #2
    Re: HTTP help

    I tried your script and the Triggered Alert List popped up with a trigger date-time and the symbol IDC and the word DONE. I also get a beep. So the script is executing something...

    If I try to go to your URL in a browser I get a popup asking for a log in. If I decline I get an error.
    Because I can't inspect the web page I don't really know what is supposed to happen. I wonder if the log in is an issue with the script running to your expectations.

    Mike Scott
    Tarzana, CA


    Originally posted by BerkoBob
    Someone has written an API to a trade log database so that I can send trade calls via HTTP. I'm not really a web guy but this does seem very basic.

    If I paste the following URL into my browser's address bar everything works perfectly:

    "http://service.livetradingfloor.com/restapi/index.php/api/mwmf/addTradeCall/tid/12/setup/35/epic/GBPUSD/sector/-2-/direction/1/entry/3456/stoploss/3450/target/3464/ordertype/1/status/1"_

    so why doesn't the following script work.


    var reset = 0;

    function main() {

    if (reset == 0) reset=call();

    return;
    }

    function call() {
    HTTP("http://service.livetradingfloor.com/restapi/index.php/api/mwmf/addTradeCall/tid/12/setup/35/epic/GBPUSD/sector/-2-/direction/1/entry/3456/stoploss/3450/target/3464/ordertype/1/status/1");

    Alert.addToList(getSymbol(), "DONE", Color.red, Color.white);
    Alert.playSound("beep.wav");
    return 1;
    }

    Have I done something wrong and if so what? If not, how can I accomplish this.

    Please help - I'm desperate.

    Thank you.
    ....Mike

    Comment


    • #3
      Thanks for getting back to me. Normally the database requires authentication but this can be removed to test the script.

      When the URL is entered into a web browser it works but when the same URL is posted using the HTTP script it doesn't work.

      Is there a problem with my code? Does the HTTP function work or does it have strange behaviour.

      Any advice you can give would be greatly appreciated.

      Comment


      • #4
        BerkoBob
        As it's described in this KB article http://kb.esignalcentral.com/article...ticle=2229&p=4 the HTTP object can be used for reading the content of txt, html, xml files etc.

        Thus, if you want to read the content of file by URL you can use this example
        PHP Code:
        function preMain()
        {
            
        HTTPcall();
        }
        function 
        main() 
        {
            return;
        }

        function 
        HTTPcall() 
        {
            var 
        HTTPObj = new HTTP("http:// <specify here URL> ");
            
        with HTTPObj )
            {
                    
        ret open();
                    
        0;
                    if (
        ret){
                        
        debugPrintln("Start read file");
                        while( !
        eof() )
                        {
                                
        = (i++) + ": " readln();
                                
        debugPrintln(s);
                        }        
                        
                    }
                    else{
                        
        debugPrintln ('Cannot open resource');    
                    }
            }
            
            
            
        Alert.addToList(getSymbol(), "DONE"Color.redColor.white);
            
        Alert.playSound("beep.wav");
            
        HTTPObj null;
            
            return 
        1;

        This example will output the text-content of file, located by specified URL to Formula Output

        Please, note, that user-defined function has name HTTPcall, not call. Because call is word reserved in EFS. In case of using this name for user-defined function, its behavior can be unpredictable.
        Another point, using HTTP as a procedure is not correct. HTTP is a constructor, which creates an object instance, therefore HTTP should be used like it's shown in example.
        PHP Code:
            var HTTPObj = new HTTP("http:// <specify here URL> "); 
        after that you can use variable HTTPObj for using methods of HTTP object.

        If you want to use HTTP for output the web-page (not text-content), I'm afraid that you try to use an object for other purposes.
        By using HTTP it's impossible. If you want this feature you can submit your request via the form under the Support menu in eSignal called "Request a feature".

        Thank you.

        Comment

        Working...
        X