1. Debug 1

test3_random project debug:

#include "main.hpp"

int main()

{

    init_mt4(MT4);

    string fn="Random";

    int i=4;

    int maxrand1=2;

    srand((unsigned int)time((time_t *)NULL));

    int period1=PERIOD_M1;

    double SL = 0.50;

    double TP = 0.50;

    bool IsPercent = false;

    int MagicNum=0;

    int LastDT=0;

    vector <string> symb;

    symb.push_back("GBPUSD");

    symb.push_back("EURUSD");

    symb.push_back("EURGBP");

    time_t begin_t = time_t_common_begin(symb, PERIOD_M1);

    time_t end_t = time_t_common_end(symb, PERIOD_M1);

    int date_start=begin_t;

    //int date_end=end_t;

    int _per=period1*60;

    int dt=date_start-_per;

    int date_end1=date_start+_per*100;

    cout << "begin_t=" << date_start << endl;

    //cout << "end_t=" << date_end << endl;

    cout << "date_end1=" << date_end1 << endl;

    int maxrand2=symb.size();

    string str1="";

    while (date_end1>dt)

    {

        dt+=_per;

        RecalcTradeArray(dt);

        if (OrdersTotal()>0) continue;

        int op=(rand()%maxrand1);

        int op1=1-op;

        int isymb = (rand()%maxrand2);;

        string sy = symb[isymb];

        double pp,sl,tp;

        int sh=iBarShift0(sy,period1,dt,true);

        if (sh<0)

            continue;

        int spread=MarketInfo(sy,MODE_SPREAD);

        double _point=MarketInfo(sy,MODE_POINT);

        int dg = MarketInfo(sy, MODE_DIGITS);

        pp=iOpen(sy,period1,sh)+spread*op1*_point;

        cout    << "sy="<< sy

                << ": " << op

                << " sh= " << sh

                << " iOpen: " << pp

                //<< " iOpen: " << NormalizePrice(sy,(pp/2.0),true)

                //<< " iOpen: " << NormalizePrice(sy,(pp/2.0),false)

                //<< " iOpen: " << NormalizeDouble((pp/2.0),dg)

                << " dt: " << dt

                //<< " dt: " << UnixTime2TDateTime(dt)

                //<< " dt: " << time_t_to_string2((time_t)dt)

                //<< " dt: " << string_to_time_t("1192034967000")

                << endl;

        if (IsPercent)

        {

            sl=pp * (1 - IIF(op==OP_BUY,1,-1) * SL/100);

            tp=pp * (1 + IIF(op==OP_BUY,1,-1) * TP/100) ;

        }

        else

        {

            sl=pp-IIF(op==OP_BUY,1,-1)* SL *_point;

            tp=pp+IIF(op==OP_BUY,1,-1)* TP *_point;

        }

        SetCurrentDateTime(dt);

        //str1=StringConcatenate("Params",csv.dem,SL,csv.dem,TP);

        //SetOrder(sy, op, 0.1,pp,sl ,tp, MagicNum, dt+86400, str1);

        SetOrder(sy, op, 0.1,pp,sl ,tp, MagicNum, dt+86400, str1);

    }

    CloseAllOrders();

    DebugPrintArrays(fn);

    return 0;

}