Script won't run on demo

 

I'm trying to run a script on my demo account to open an order.

The script runs but on sending the order the Journal just says script unloaded.

None of my error logging prints out and the order doesn't appear.

ANy ideas?



 
Set after MessageBox function RefreshRates() and recalculate StopLoss.
 
Roger:
Set after MessageBox function RefreshRates() and recalculate StopLoss.

no, still nothing.


//+------------------------------------------------------------------+
//|                                       Lot amount based on SL.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//#property show_inputs
#include <WinUser32.mqh>
#include <stderror.mqh>
#include <stdlib.mqh>

double InputtedStopLoss=50;
double InputtedRisk=1.5;
double InputtedAccountCapital= 0;
double StopLoss = 0.00000;
double Lot = 0.00;

void logError(string functionName, string msg, int errorCode = -1)
  {
    Print("ERROR: in " + functionName + "()");
    Print("ERROR: " + msg );
    
    int err = GetLastError();
    if(errorCode != -1) 
        err = errorCode;
        
    if(err != ERR_NO_ERROR) 
      {
        Print("ERROR: code=" + err + " - " + ErrorDescription( err ));
      }    
  }

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   
   double Answer = 0;
   string text = "";
   int nDigits;
   int nMultiply;
   
   InputtedAccountCapital = AccountBalance()+2000; //hardcoded £2000 extra
   if(Symbol()=="GBPJPY" || Symbol()=="EURJPY" || Symbol()=="USDJPY" || Symbol()=="GOLD")  {nDigits = 3;nMultiply=100;}
   else {nDigits = 5;nMultiply=10000;}
   InputtedStopLoss = iATR(NULL,0,14,0) * nMultiply; //ATR
   StopLoss = NormalizeDouble((Ask-iATR(NULL,0,14,0)),5);
   Lot = NormalizeDouble(((InputtedAccountCapital * (InputtedRisk/100)) / InputtedStopLoss) / 10,2);
   
   if(MessageBox("Do you really want to BUY "+Lot+" "+Symbol()+" at "+Ask+" ask price with stop loss "+StopLoss+ "?",
                 "Script",MB_YESNO|MB_ICONQUESTION)!=IDYES) return(1);
//----
   Print ("Sending");
   RefreshRates();
   StopLoss = NormalizeDouble((Ask-iATR(NULL,0,14,0)),5);
   int ticket=OrderSend(Symbol(),OP_BUY,Lot,Ask,3,StopLoss,0.00000,"My order",0,0,Green);
     if(ticket<0)
       {
        logError("OrderSend BUY failed with error #", "Error");
       }
//----
   OrderPrint();
   return(0);
  }
//+------------------------------------------------------------------+
 
Your Dealer is probably closed for the weekend.
 
phy:
Your Dealer is probably closed for the weekend.

Maybe, I'll try later but it doesn't put this in the journal either:

Print ("Sending");

 
SanMiguel:

Maybe, I'll try later but it doesn't put this in the journal either:

No, the broker is running now on demo but nothing works.

 

Oh, apparently it's an invalid amount on my demo system.

I need to get a demo account from my current live trader with 5 decimals and micro accounts and try that.
Reason: