Placing orders in the demo.

 
Hello.

I will ask for help. Why this script does not place orders.

//+------------------------------------------------------------------+
//|                                              Poziom i spadek.mq4 |
//|                        Copyright 2019, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

void OnTick()
      {
      string morning="";                              
      if (Hour()>6)
      {  
      morning="buy";
      }
      string evening="";                              
      if (Hour()<9)
      {  
      evening="buy";
      }
      string trade="";                              
      int Orders=OrdersTotal();
      if (Orders==0)
      {  
      trade="buy";
      }
      string spadek="";                              
      if (Close[1]<Open[1])
      {  
      spadek="buy";
      }
      double one=2;
      double two=1;
      double three=0;
      double four=-1;
      double five=-2;
      one=one*Close[2];
      two=two*Close[3];
      three=three*Close[4];
      four=four*Close[5];
      five=five*Close[6];
      double counter_b;
      counter_b=one+two+three+four+five;
      double denominator_b;
      denominator_b= 10;
      double b;
      b=counter_b/denominator_b;
      double counter_a;
      counter_a=Close[6]+Close[5]+Close[4]+Close[3]+Close[2];
      double denomimator_a=5;
      double a=counter_a/denomimator_a;
      double one_prim;
      one_prim=a+b*2;
      double two_prim;
      two_prim=a+b;
      double three_prim;
      three_prim=a;
      double four_prim;
      four_prim=a-b;
      double five_prim;
      five_prim=a-2*b;
      double counter_1;
      counter_1=MathPow(Close[2]-one_prim,2);
      double counter_2;
      counter_2=MathPow(Close[3]-two_prim,2);
      double counter_3;
      counter_3=MathPow(Close[4]-three_prim,2);
      double counter_4;
      counter_4=MathPow(Close[5]-four_prim,2);
      double counter_5;
      counter_5=MathPow(Close[6]-five_prim,2);
      double counter_S;
      counter_S=counter_1+counter_2+counter_3+counter_4+counter_5;
      double denominator_S=3;
      double S;
      S=MathSqrt(counter_S/denominator_S);
      double average;
      average=(Close[6]+Close[5]+Close[4]+Close[3]+Close[2])/5;
      double V;
      V=(S/average)*100;
     Comment(" b=",b," \n a=",a," \n average=",average,"\n Counter S=",counter_S," \n S=",S," \n V=",V,"\n Hour ",Hour());
     if  (morning=="buy" && evening=="buy"&& trade=="buy" && b>0 && b<0.0002  && V<0.03 && spadek=="buy")
            {
            //--- get minimum stop level
            double minstoplevel=MarketInfo(Symbol(),MODE_STOPLEVEL);
            Print("Minimum Stop Level=",minstoplevel," points");
            double price=Ask;
            //--- calculated SL and TP prices must be normalized
            //double stoploss=Ask-75*Point;
            double stoploss=NormalizeDouble(Ask-75*Point,Digits);
            double takeprofit=NormalizeDouble(Ask+75*Point,Digits);
            // double takeprofit=Ask+75*Point;
            //--- place market order to buy 1 lot
            int ticket=OrderSend(Symbol(),OP_BUY,0.4,price,5,stoploss,takeprofit,"My Order",16384,0,clrGreen);
             Print (b,"   ",V);
             }
          }
   


Everything works in the strategy tester. The strategy tester has made 216 transactions over the past year. But as I want to test the strategy live in the bill, nothing happens. 2020-06-05 the strategy should buy. But it didn't happen. Below are logs from that day:

0 07:02:48.726 BOSSAFX build 1260 started (Dom Maklerski Banku Ochrony Srodowiska S.A.)

0 07:02:48.726 Windows 10 Pro x64, IE 11, UAC, 4 x Intel Core i5-7200U  @ 2.50GHz, Memory: 5667 / 7639 Mb, Disk: 198 / 237 Gb, GMT+1

0 07:02:48.726 Data Folder: C:\Users\MAgda\AppData\Roaming\MetaQuotes\Terminal\4D8765565A48572E2B4FDE0D8FFD6A2C

2 07:02:54.789 Expert Inne\Poziom i spadek USDHUF USDHUF.,M5: loaded successfully

2 07:02:54.846 Expert Inne\Poziom i spadek USDPLN USDPLN.,M5: loaded successfully

2 07:02:54.898 Expert Inne\Poziom i spadek USDCZK USDCZK.,M5: loaded successfully

0 07:02:56.494 '10116846': login on BossaFX-Demo through dc-04.bossafx.pl (ping: 24.58 ms)

0 07:02:56.919 '10116846': login datacenter on BossaFX-Demo through dc-04.bossafx.pl (ping: 24.58 ms)

0 07:02:57.159 '10116846': previous successful authorization performed from 89.64.2.38

0 07:02:57.231 '10116846': ping to current access point dc-04.bossafx.pl is 30.48 ms

0 13:59:32.059 System to be shutdown, request for close BOSSAFX

0 13:59:32.450 BOSSAFX build 1260 stopped because system shutdown

 

This is not the full code?

string morning="";                              
      if (Hour()>6)
      {  
      morning="buy";
      }
      string evening="";                              
      if (Hour()<9)
      {  
      evening="buy";
      }
      string trade="";   

what are you trying to do?

 

I wanted the machine to buy only in the morning. So it's morning hours.

So should I turn on the computer myself in the morning and shutdown Windows at 9 o'clock by task scheduling?

Reason: