제품을 구매하거나 렌트한 사용자만 코멘트를 남길 수 있습니다
MARCOS Dos santos Moreira  
O meu meta trade 5 não está vendendo mais os meus ativos me ajudem atenciosament
Ian Worthington  
Could you show source since you made this free anyway?
Ivan Zaidenberg  
WorthyVII #:
Could you show source since you made this free anyway?
#property script_show_inputs
#property version "1.0"
#property strict
//--- Parameters
input string   SymName = "RandomWalk";
input int HistoryDepth = 1440;
input int    StartFrom = 100000;
input bool   VolaCycle = true;
double open,high,low,close;
string date,time;
datetime TimeLoc;
int Spread=1,random;
ushort f=0;
//+------------------------------------------------------------------+
//| Custom iteration function                                        |
//+------------------------------------------------------------------+
int OnStart(void)
  {
   int h=FileOpen(SymName+"."+IntegerToString(HistoryDepth)+".csv",FILE_WRITE|FILE_ANSI|FILE_CSV,";");
//---
   if(h==INVALID_HANDLE)
     {
      Alert("Open File Fail");
      return(-1);
     }
//---
   TimeLoc=TimeLocal();
   MathSrand(TimeLoc);
   date=TimeToString(TimeLoc-HistoryDepth*60,TIME_DATE);
   time=TimeToString(TimeLoc-HistoryDepth*60,TIME_MINUTES)+":00";
   open=StartFrom+RandomCoin();
   close=open+RandomCoin();
   high=MathMax(open,close);
   low=MathMin(open,close);
   FileWrite(h,date,time,open,high,low,close,1+(high-low),0,Spread);
//---
   for(int i=HistoryDepth-1; i>0; i--)
     {
      date=TimeToString(TimeLoc-i*60,TIME_DATE);
      time=TimeToString(TimeLoc-i*60,TIME_MINUTES)+":00";
      if(VolaCycle)
        {
         open=close+Vola(time)*RandomCoin();
         close=open+Vola(time)*RandomCoin();
        }
      else
        {
         open=close+RandomCoin();
         close=open+RandomCoin();
        }
      high=MathMax(open,close);
      low=MathMin(open,close);
      FileWrite(h,date,time,open,high,low,close,1+(high-low),0,Spread);
     }
//---
   FileClose(h);
   Alert(TerminalInfoString(TERMINAL_DATA_PATH)+"\\MQL5\\Files\\"+SymName+"."+IntegerToString(HistoryDepth)+".csv");
//---
   return(0);
  }
//+------------------------------------------------------------------+
int RandomCoin()
  {
   int limit=32767;
   int sequence=0;
   for(int i=0; i<=limit; i++)
     {
      random=MathRand()-MathRand();
      if(random>=0)random=1;
      if(random<0)random=-1;
      if(sequence==0)
        {
         sequence=random;
         continue;
        }
      if(random>0)
        {
         if(sequence>0)
           {
            sequence=sequence+random;
            continue;
           }
         if(sequence<0)break;
        }
      if(random<0)
        {
         if(sequence<0)
           {
            sequence=sequence+random;
            continue;
           }
         if(sequence>0)break;
        }
     }
   return (sequence);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int Vola(string t)
  {
   int res=1;
   int hh=StringToInteger(StringSubstr(t,0,2));
   if(hh>=0&&hh<4)res=1;
   if(hh>=4&&hh<8)res=2;
   if(hh>=8&&hh<16)res=3;
   if(hh>=16&&hh<20)res=2;
   if(hh>=20)hh=1;
   return res;
  }
//+------------------------------------------------------------------+