Topics

Forum Topics not found

Replies

bellong
19 Oct 2014, 16:30

RE:

bellong said:

Great news to make it available; this is a huge step forward really.

But i'm wondering about the actual possibilities of cAlgo/cTrader to use the modern hardware: cpu/gpu which have each one a huge amount of threads

Does they understand opencl/cuda  (builtin API)?  That should open the door of 'fuzzy' logic coding (aka using a set of parameters (range) vs unique parameter as usual), so an inline optimization where the user have set the limits.

 

Thanks again for the new features and future targets.

 


@bellong

bellong
19 Oct 2014, 16:29

Great news to make it available; this is a huge step forward really.

But i'm wondering about the actual possibilities of cAlgo/cTrader to use the modern hardware: cpu/gpu which have each one a huge amount of threads

Does they understand opencl/cuda ?  That should open the door of 'fuzzy' logic coding (aka using a set of parameters (range) vs unique parameter as usual), so an inline optimization where the user have set the limits.

 

Thanks again for the new features and future targets.


@bellong

bellong
19 Oct 2014, 15:48

http://www.dailyfx.com/calendar

news are there, not the url hardcoded

 


@bellong

bellong
19 Oct 2014, 15:44

RE: dailyfx url not found

aisaac said:

good afternoon, is possible add this indicator in ctarder ?  the converter online not work, thanks.


//+--------------------------------------------------------------------------------+
//|ForexNews Market Clock indicator                    forex_news_market_clock.mq4 |
//|                                                                                |
//| Made by Tjipke de Vries   (deVries) at mql4.com                                |
//|       Indicator displays a News Calendar with a market clock.                  |
//|       news events "http://www.dailyfx.com/files/"                              |
//|                                                                                |
//| Some sources I have used                                                       |
//| This article Displaying a News Calendar written by Slobodov Gleb and to read at|
//| http://articles.mql4.com/523 shows a way how to get data displayed on the chart|
//| The file contains the description of writing a simple and convenient indicator |
//| displaying  in a working  area the main economic events from external Internet |
//| resources.                                                                     |
//|                                                                                |
//| Another source I have used for this indicator is the indicator SimpleMarketInfo|
//| here to find   http://codebase.mql4.com/7157  made by  born2trade  (2010.11.25)|
//| It shows upcoming news events 1 hour before and 30 minutes after event. It also|
//| shows active sessions etc. It gives a look to all news events.                 |
//| changes on this.  I did wanna have the possibillity to choose the kind of news |
//| I like to see, and when local time isn't brokertime there was not the correct  |
//| displaying vertical lines on the chart. And some other changes...                                        |
//|                                                                                |
//| Found the indicator Clockzv1_2 auto.mq4  (http://forum.mql4.com/14052#91898)   |
//| from "Jerome" This version made it possible for me to write down the coming DST|
//| times for the local markets also. ST/DST changes are unique to each timezone.  |
//| To know when a market is open we have to know the right localtime...           |
//| timezones   http://www.timeanddate.com/worldclock/                             |
//| markethours: http://www.2011.worldmarkethours.com/Forex/index1024.htm          | 
//| Auckland/Sydney/Tokyo/Hong Kong/Europe/London/New York                         |
//|                                                                                |
//| The clock will display the different times, the open markets and market holiday|
//| More info:  http://www.donnaforex.com/forum/index.php?topic=4339.0             |
//+--------------------------------------------------------------------------------+
#property  copyright "deVries"
#property  link      ""
#property indicator_chart_window 
#property indicator_buffers 0

#include 


//----
#import "wininet.dll"
int InternetAttemptConnect(int x);
int InternetOpenW(string sAgent,int lAccessType,
                  string sProxyName="",string sProxyBypass="",
                  int lFlags=0);
int InternetOpenUrlW(int hInternetSession,string sUrl,
                     string sHeaders="",int lHeadersLength=0,
                     int lFlags=0,int lContext=0);
int InternetReadFile(int hFile,int &sBuffer[],int lNumBytesToRead,
                     int &lNumberOfBytesRead[]);
int InternetCloseHandle(int hInet);
#import

#define COLUMN_DATE        0
#define COLUMN_TIME        1
#define COLUMN_TIMEZONE    2
#define COLUMN_CURRENCY    3
#define COLUMN_DESCRIPTION 4
#define COLUMN_IMPORTANCE  5
#define COLUMN_ACTUAL      6
#define COLUMN_FORECAST    7
#define COLUMN_PREVIOUS    8

#define COLUMN_DATE_DAY_STR    0
#define COLUMN_DATE_MONTH_STR  1
#define COLUMN_DATE_DAY_INT    2

int        time_zone_gmt     =0;//LOCAL TIMEZONE WILL BE CHANGED TO 
                                //YOUR PC-TIMEZONE AUTOMATICLY

//---- input parameters news
extern string news_parameters="Make your selection";
extern color  session_upcoming_title_color=Purple;
extern color  session_closing_color=Red;
extern color  bar_closing_color=Green;
extern string if_show_currency_news_only="Choose auto true";
extern bool   auto=true;
extern bool   show_low_news     = true;
extern bool   show_medium_news  = true;
extern bool   show_high_news    = true;
extern color  news_past_color   = Gray;
extern color  news_high_color   = Red;
extern color  news_medium_color = Orange;
extern color  news_low_color    = Blue;
extern string if_auto_false="select news currencie(s)";
extern bool   show_eur = true;
extern bool   show_usd = true;
extern bool   show_jpy = true;
extern bool   show_gbp = true;
extern bool   show_chf = true;
extern bool   show_cad = true;
extern bool   show_aud = true;
extern bool   show_nzd = true;
extern bool   show_cny = true;
//verticale lines
extern bool   show_news_lines  = true; //verticale lines show moments of news
extern bool   show_line_text   = true; //news text by verticale lines
//---------------------------------------------------
//---- input parameters clock
int           Clockcorner=0;
extern string input_parameters="for the clock";
extern int       godown=0;
extern int       goright=0;
//Colors clock
extern color     labelColor=DarkSlateGray;
extern color     clockColor=DarkSlateGray;
extern color     ClockMktOpenColor=Red;
extern color     ClockMktHolidayClr=PaleTurquoise;// Blue;
bool             show12HourTime=false; //YOU CAN CHANGE IT BUT I LIKE THIS MORE
extern bool      ShowSpreadChart=true;
extern bool      ShowBarTime=true;
extern bool      ShowLocal=true;
extern bool      ShowBroker=true;
extern bool      ShowGMT=true;
//FOUND THE TIMES WHEN THE MARKETS WERE OPEN AT
//World Financial Markets   http://www.2011.worldmarkethours.com/Forex/index1024.htm
extern bool      Show_NEW_ZEALAND=true;//Auckland GMT+12
extern bool      Show_AUSTRALIA=true;//Sydney GMT+12
extern bool      Show_JAPAN=true;//Tokyo GMT+9
extern bool      Show_HONG_KONG=true;//    GMT+8
extern bool      Show_EUROPE=true;//Frankfurt GMT+1
extern bool      Show_LONDON=true;//GMT+0
extern bool      Show_NEW_YORK=true;//GMT-5

string     news_url="http://www.dailyfx.com/files/";
int        update_interval=15;
int        show_min_before_news=60;

double spread;

datetime NZDHoliday =0;
datetime AUDHoliday =0;
datetime JPYHoliday =0;
datetime CNYHoliday =0;
datetime EURHoliday =0;
datetime GBPHoliday =0;
datetime USDHoliday =0;
datetime localTime;

#import "kernel32.dll"

void GetLocalTime(int &LocalTimeArray[]);
void GetSystemTime(int &systemTimeArray[]);
int  GetTimeZoneInformation(int &LocalTZInfoArray[]);
bool SystemTimeToTzSpecificLocalTime(int &targetTZinfoArray[],int &systemTimeArray[],int &targetTimeArray[]);

#import

//---- buffers
double ExtMapBuffer1[];
int LondonTZ= 0;
int TokyoTZ = 9;
int NewYorkTZ= -5;
int SydneyTZ = 11;
int BerlinTZ = 1;
int AucklandTZ = 13;
int HongKongTZ = 8;
datetime newyork,london,frankfurt,tokyo,sydney,auckland,hongkong,GMT;
string newyorks,londons,frankfurts,tokyos,sydneys,aucklands,hongkongs,GMTs;
// -----------------------------------------------------------------------------------------------------------------------------
int TotalNews=0;
string News[1000][10];
datetime lastUpdate=0;
int NextNewsLine=0;
int LastAlert=0;
double Points;
// -----------------------------------------------------------------------------------------------------------------------------
int init()
  {
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   int top=godown+20;
   int left2= 70+goright;
   int left =left2;
   if(show12HourTime) left=left2-20;
   if(ShowSpreadChart)
     {
      ObjectMakeLabel("Spread Monitor1",left-45,top);
      ObjectMakeLabel("Spread Monitor2",left2+25,top);
      top+=15;
     }
   if(ShowBarTime)
     {
      ObjectMakeLabel("barl",left2,top);
      ObjectMakeLabel("bart",left-45,top);
      top+=15;
     }
   top+=5;
   if(ShowLocal)
     {
      ObjectMakeLabel("locl",left2,top);
      ObjectMakeLabel("loct",left-45,top);
      top+=15;
     }
   if(ShowBroker)
     {
      ObjectMakeLabel("brol",left2,top);
      ObjectMakeLabel("brot",left-45,top);
      top+=15;
     }
   if(ShowGMT)
     {
      ObjectMakeLabel("gmtl",left2,top);
      ObjectMakeLabel("gmtt",left-45,top);
      top+=15;
     }
   top+=5;
   if(Show_NEW_ZEALAND)
     {
      ObjectMakeLabel("NZDl",left2,top);
      ObjectMakeLabel("NZDt",left-45,top);
      top+=15;
     }
   if(Show_AUSTRALIA)
     {
      ObjectMakeLabel("sydl",left2,top);
      ObjectMakeLabel("sydt",left-45,top);
      top+=15;
     }
   if(Show_JAPAN)
     {
      ObjectMakeLabel("tokl",left2,top);
      ObjectMakeLabel("tokt",left-45,top);
      top+=15;
     }
   if(Show_HONG_KONG)
     {
      ObjectMakeLabel("HKl",left2,top);
      ObjectMakeLabel("HKt",left-45,top);
      top+=15;
     }
   if(Show_EUROPE)
     {
      ObjectMakeLabel("berl",left2,top);
      ObjectMakeLabel("bert",left-45,top);
      top+=15;
     }
   if(Show_LONDON)
     {
      ObjectMakeLabel("lonl",left2,top);
      ObjectMakeLabel("lont",left-45,top);
      top+=15;
     }
   if(Show_NEW_YORK)
     {
      ObjectMakeLabel("nyl",left2,top);
      ObjectMakeLabel("nyt",left-45,top);
      top+=15;
     }

   CreateInfoObjects();
   return(0);
  }
// -----------------------------------------------------------------------------------------------------------------------------
int deinit()
  {
//----
   ObjectDelete("locl");
   ObjectDelete("loct");
   ObjectDelete("nyl");
   ObjectDelete("nyt");
   ObjectDelete("gmtl");
   ObjectDelete("gmtt");
   ObjectDelete("berl");
   ObjectDelete("bert");
   ObjectDelete("NZDl");
   ObjectDelete("NZDt");
   ObjectDelete("lonl");
   ObjectDelete("lont");
   ObjectDelete("tokl");
   ObjectDelete("tokt");
   ObjectDelete("HKl");
   ObjectDelete("HKt");
   ObjectDelete("sydl");
   ObjectDelete("sydt");
   ObjectDelete("brol");
   ObjectDelete("brot");
   ObjectDelete("barl");
   ObjectDelete("bart");
   ObjectDelete("Spread Monitor1");
   ObjectDelete("Spread Monitor2");

   DeleteNewsObjects();
   DeleteSessionInfoObjects();
//----
   DisplaySessionInfo();

   return(0);
  }
// -----------------------------------------------------------------------------------------------------------------------------
int start()

  {
   static datetime last_timecurrent;

   if(!IsDllsAllowed())
     {
      Alert("Clock V1_2: DLLs are disabled.  To enable tick the checkbox in the Common Tab of indicator");
      return;
     }
   int    counted_bars=IndicatorCounted();
//----

   int    systemTimeArray[4];
   int    LocalTimeArray[4];
   int    TZInfoArray[43];
   int    nYear,nMonth,nDay,nHour,nMin,nSec,nMilliSec;
   string sMilliSec;

   HandleDigits();

   GetLocalTime(LocalTimeArray);
//---- parse date and time from array
/*
   nYear=TimeArray[0]&0x0000FFFF;
   nMonth=TimeArray[0]>>16;
   nDay=TimeArray[1]>>16;
   nHour=TimeArray[2]&0x0000FFFF;
   nMin=TimeArray[2]>>16;
   nSec=TimeArray[3]&0x0000FFFF;
   nMilliSec=TimeArray[3]>>16;
*/
   string LocalTimeS=FormatDateTime(nYear,nMonth,nDay,nHour,nMin,nSec);
   datetime localTime=TimeArrayToTime(LocalTimeArray);//StrToTime( LocalTimeS );
//-----------------------------------------------------  
   GMTs=TimeToString1(GMT);
   string locals=TimeToString1(localTime);
   londons=TimeToString1(london);
   frankfurts=TimeToString1(frankfurt);
   tokyos=TimeToString1(tokyo);
   newyorks= TimeToString1(newyork);
   sydneys = TimeToString1(sydney);
   aucklands = TimeToString1( auckland );
   hongkongs = TimeToString1( hongkong );
   string brokers=TimeToString1(CurTime());
   string bars=TimeToStr(CurTime()-Time[0],TIME_MINUTES);

//   DisplayTodaysNews();
//-----------------------------------------------------
   LondonTZ = GMT_Offset("LONDON",localTime);   //GBP
   TokyoTZ = GMT_Offset("TOKYO",localTime);     //JPY
   NewYorkTZ = GMT_Offset("US",localTime);      //USD
   SydneyTZ = GMT_Offset("SYDNEY",localTime);   //AUD
   BerlinTZ = GMT_Offset("FRANKFURT",localTime);//EUR
   AucklandTZ = GMT_Offset("AUCKLAND",localTime);//NZD
   HongKongTZ = GMT_Offset("HONGKONG",localTime);//CNY
//-----------------------------------------------------
/*
   int gmt_shift=0;
   int dst=GetTimeZoneInformation(TZInfoArray);
   if(dst!=0) gmt_shift=TZInfoArray[0];
   if(dst==2) gmt_shift+=TZInfoArray[42];
*/
   GetSystemTime(systemTimeArray);
   GMT=TimeArrayToTime(systemTimeArray);//localTime + gmt_shift * 60;

   london= GMT+3600 * LondonTZ;
   tokyo = GMT+3600 * TokyoTZ;
   newyork= GMT+3600 * NewYorkTZ;
   sydney = GMT+3600 * SydneyTZ;
   frankfurt= GMT+3600 * BerlinTZ;
   auckland = GMT +3600 * AucklandTZ;
   hongkong = GMT + 3600 * HongKongTZ;
//   time_zone_gmt = -(gmt_shift/60);
   time_zone_gmt=(localTime-GMT)/3600;

   DisplaySessionInfo();
   DisplayTodaysNews();

   if(ShowLocal)
     {
      ObjectSetText("locl","Local time",10,"Arial Black",labelColor);
      ObjectSetText("loct",locals,10,"Arial Black",ClockMktOpenColor);
     }
   if(ShowBroker)
     {
      ObjectSetText("brol","Broker time",10,"Arial Black",labelColor);
      ObjectSetText("brot",brokers,10,"Arial Black",ClockMktOpenColor);
     }
   if(ShowGMT)
     {
      ObjectSetText("gmtl","GMT",10,"Arial Black",labelColor);
      ObjectSetText("gmtt",GMTs,10,"Arial Black",ClockMktOpenColor);
     }
//--------------------------
   if(Show_NEW_ZEALAND)
     {
      if(NZDHolidayStrToTime("10:00") && StrToTime(aucklands)TimeCurrent())
        {
         ObjectSetText("sydl","Australia market Holiday ",10,"Arial Black",ClockMktHolidayClr);
         ObjectSetText("sydt",sydneys,10,"Arial Black",ClockMktHolidayClr);
        }
     }
//---------------------------      
   if(Show_JAPAN)
     {
      if(JPYHolidayStrToTime("9:00") && StrToTime(tokyos)TimeCurrent())
        {
         ObjectSetText("tokl","Japan market Holiday ",10,"Arial Black",ClockMktHolidayClr);
         ObjectSetText("tokt",tokyos,10,"Arial Black",ClockMktHolidayClr);
        }
     }
//---------------------------         
   if(Show_HONG_KONG)
     {
      if(CNYHolidayStrToTime("10:00") && StrToTime(hongkongs)TimeCurrent())
        {
         ObjectSetText("berl","European market Holiday ",10,"Arial Black",ClockMktHolidayClr);
         ObjectSetText("bert",frankfurts,10,"Arial Black",ClockMktHolidayClr);
        }
     }
//---------------------------      
   if(Show_LONDON)
     {
      if(GBPHolidayStrToTime("8:00") && StrToTime(londons)TimeCurrent())
        {
         ObjectSetText("nyl","New York market Holiday ",10,"Arial Black",ClockMktHolidayClr);
         ObjectSetText("nyt",newyorks,10,"Arial Black",ClockMktHolidayClr);
        }
     }
//---------------------------                  

   ObjectSetText("barl","Bar time",10,"Arial Black",labelColor);
   ObjectSetText("bart",bars,10,"Arial Black",clockColor);
   spread=NormalizeDouble((Ask-Bid)/Points,1);
   ObjectSetText("Spread Monitor1","Spread ",10,"Arial Black",labelColor);
   ObjectSetText("Spread Monitor2",DoubleToStr(spread,1),10,"Arial Black",clockColor);
//----  

   return(0);
  }
// -----------------------------------------------------------------------------------------------------------------------------
int DisplayTodaysNews()
  {
   string news[1000][10];
   datetime time=TimeCurrent();
   if(time>=lastUpdate+update_interval*60)
     {
      DeleteNewsObjects();
      string str="";

      InitNews(news,time_zone_gmt,news_url);
      if(show_news_lines)
        {
         DrawNewsLines(news,show_line_text,news_high_color,news_medium_color,news_low_color);
        }
     }
   ShowNewsCountDown(news,show_min_before_news,1,news_high_color,news_medium_color,news_low_color,news_past_color,session_upcoming_title_color);
   return(0);
  }
// -----------------------------------------------------------------------------------------------------------------------------
string FormatDateTime(int nYear,int nMonth,int nDay,int nHour,int nMin,int nSec)
  {
   string sMonth,sDay,sHour,sMin,sSec;
//----
   sMonth=100+nMonth;
   sMonth=StringSubstr(sMonth,1);
   sDay=100+nDay;
   sDay=StringSubstr(sDay,1);
   sHour=100+nHour;
   sHour=StringSubstr(sHour,1);
   sMin=100+nMin;
   sMin=StringSubstr(sMin,1);
   sSec=100+nSec;
   sSec=StringSubstr(sSec,1);
//----
   return(StringConcatenate(nYear,".",sMonth,".",sDay," ",sHour,":",sMin,":",sSec));
  }
// -----------------------------------------------------------------------------------------------------------------------------
int Explode(string str,string delimiter,string &arr[])
  {
   int i=0;
   int pos=StringFind(str,delimiter);
   while(pos!=-1)
     {
      if(pos==0) arr[i]=""; else arr[i]=StringSubstr(str,0,pos);
      i++;
      str = StringSubstr(str, pos+StringLen(delimiter));
      pos = StringFind(str, delimiter);
      if(pos==-1 || str=="") break;
     }
   arr[i]=str;

   return(i+1);
  }
// -----------------------------------------------------------------------------------------------------------------------------
datetime TimeArrayToTime(int &LocalTimeArray[])
  {
//---- parse date and time from array

   int    nYear,nMonth,nDOW,nDay,nHour,nMin,nSec,nMilliSec;
//string sMilliSec;

   nYear=LocalTimeArray[0]&0x0000FFFF;
   nMonth=LocalTimeArray[0]>>16;
//nDOW=LocalTimeArray[1]&0x0000FFFF;
   nDay=LocalTimeArray[1]>>16;
   nHour=LocalTimeArray[2]&0x0000FFFF;
   nMin=LocalTimeArray[2]>>16;
   nSec=LocalTimeArray[3]&0x0000FFFF;
   nMilliSec=LocalTimeArray[3]>>16;
   string LocalTimeS=FormatDateTime(nYear,nMonth,nDay,nHour,nMin,nSec);
   datetime Local_Time=StrToTime(LocalTimeS);
   return(Local_Time);
  } // end of TimeArrayToTime
//+------------------------------------------------------------------+

// -----------------------------------------------------------------------------------------------------------------------------

// Used to find out if news curreny is of interest to current symbol/chart. 
// Will have to be changed if symbol format does not look like for example eurusd or usdjpy

bool IsNewsCurrency(string cSymbol,string fSymbol)
  {
   if(fSymbol == "usd") fSymbol = "USD";else
   if(fSymbol == "gbp") fSymbol = "GBP";else
   if(fSymbol == "eur") fSymbol = "EUR";else
   if(fSymbol == "cad") fSymbol = "CAD";else
   if(fSymbol == "aud") fSymbol = "AUD";else
   if(fSymbol == "chf") fSymbol = "CHF";else
   if(fSymbol == "jpy") fSymbol = "JPY";else
   if(fSymbol == "cny") fSymbol = "CNY";else
   if(fSymbol == "nzd") fSymbol = "NZD";

   if((auto) && (StringFind(cSymbol,fSymbol,0)>=0)){return(true);}
   if(!auto && show_usd && fSymbol == "USD"){return(true);}
   if(!auto && show_gbp && fSymbol == "GBP"){return(true);}
   if(!auto && show_eur && fSymbol == "EUR"){return(true);}
   if(!auto && show_cad && fSymbol == "CAD"){return(true);}
   if(!auto && show_aud && fSymbol == "AUD"){return(true);}
   if(!auto && show_chf && fSymbol == "CHF"){return(true);}
   if(!auto && show_jpy && fSymbol == "JPY"){return(true);}
   if(!auto && show_nzd && fSymbol == "NZD"){return(true);}
   if(!auto && show_cny && fSymbol == "CNY"){return(true);}
   return(false);
  }
// ----------------------------------------------------------------------------------------------------------------------------- 
void InitNews(string &news[][],int timeZone,string newsUrl)
  {
   if(DoFileDownLoad()) //Added to check if the CSV file already exists
     {
      DownLoadWebPageToFile(newsUrl); //downloading the CSV file
      lastUpdate=TimeCurrent();
     }
   if(CsvNewsFileToArray(news)==0)
      return(0);

   NormalizeNewsData(news,timeZone);
  }
// -----------------------------------------------------------------------------------------------------------------------------
bool DoFileDownLoad() // If we have recent file don't download again
  {
   int handle;
   datetime time=TimeCurrent();
   handle=FileOpen(NewsFileName(),FILE_READ);  //commando to open the file
   if(handle>0)//when the file exists we read data
     {
      FileClose(handle);//close it again check is done
      if(time >= lastUpdate+update_interval*60)return(true);
      return(false);//file exists no need to download again
     }
// File does not exist if FileOpen return -1 or if GetLastError = ERR_CANNOT_OPEN_FILE (4103)
   return(true); //commando true to download CSV file
  }
// -----------------------------------------------------------------------------------------------------------------------------
void NormalizeNewsData(string &news[][],int timeDiffGmt,int startRow=1)
  {
   int totalNewsItems=ArrayRange(news,0)-startRow;
   for(int i=0; i>8  &0x000000FF);
         if(StringLen(text)==dwBytesRead[0]) break;
         text=text+CharToStr(cBuffer[i]>>16  &0x000000FF);
         if(StringLen(text)==dwBytesRead[0]) break;
         text=text+CharToStr(cBuffer[i]>>24  &0x000000FF);
        }
      fileContents=fileContents+text;
      Sleep(1);
     }
   InternetCloseHandle(hInternetSession);
// Save to text file  
   int handle;
   handle=FileOpen(NewsFileName(),FILE_CSV|FILE_WRITE,';');
   if(handle>0)
     {
      FileWrite(handle,fileContents);
      FileClose(handle);
     }
  }
// -----------------------------------------------------------------------------------------------------------------------------
// We will get news every sunday, so name file with sundays date
string NewsFileName(bool forDailyFXUrl=false)
  {
   int adjustDays=0;
   switch(TimeDayOfWeek(TimeLocal()))
     {
      case 0:
         adjustDays=0;
         break;
      case 1:
         adjustDays=1;
         break;
      case 2:
         adjustDays=2;
         break;
      case 3:
         adjustDays=3;
         break;
      case 4:
         adjustDays=4;
         break;
      case 5:
         adjustDays=5;
         break;
      case 6:
         adjustDays=6;
         break;
     }
   datetime date=TimeLocal() -(adjustDays *86400);
   string fileName="";
   if(TimeDayOfWeek(date)==0)// sunday
     {
      if(forDailyFXUrl) // if we are building URL to get file from daily fx site.
        {
         fileName=(StringConcatenate("Calendar-",PadString(DoubleToStr(TimeMonth(date),0),"0",2),"-",PadString(DoubleToStr(TimeDay(date),0),"0",2),"-",TimeYear(date),".csv"));
        }
      else
        {
         fileName=(StringConcatenate(TimeYear(date),"-",PadString(DoubleToStr(TimeMonth(date),0),"0",2),"-",PadString(DoubleToStr(TimeDay(date),0),"0",2),"-News",".csv"));
        }
     }
   return (fileName);
  }
// -----------------------------------------------------------------------------------------------------------------------------
string PadString(string toBePadded,string paddingChar,int paddingLength)
  {
   while(StringLen(toBePadded)0)
     {
      int lineCount=0;
      int lineNumber=0;
      bool processedFirstLine=false;
      while(!FileIsEnding(handle))
        {
         string lineData="";
         if(ArrayRange(lines,0)>lineCount)
           {
            for(int itemCount=0;itemCount<=numDelimItems; itemCount++)
              {

               lineData=FileReadString(handle);

               if(ignoreFirstLine && lineCount>0)
                 {

                  lineNumber=lineCount-1;
                  lines[lineNumber][itemCount]=lineData;

                  if(itemCount==freeTextCol)
                    {

                     for(int i=0; i<10; i++)
                       {
                        lineData=FileReadString(handle);
                        if(lineData=="Low" || lineData=="Medium" || lineData=="LOW" || lineData=="High" || lineData=="HIGH")
                          {
                           lines[lineNumber][freeTextCol+1]=lineData;
                           itemCount=freeTextCol+1;
                           break;
                          }
                        else
                          {
                           if(lineData!="")
                             {
                              lines[lineNumber][itemCount]=lines[lineNumber][itemCount]+", "+lineData;
                             }
                          }
                       }
                    }
                 }
              }
           }
         lineCount++;
        }

      ArrayResize(lines,lineCount);
      FileClose(handle);
     }
   else if(handle<1)
     {
      Print("File ",NewsFileName()," not found, the last error is ",GetLastError());
     }

   return(lineCount);
  }
// -----------------------------------------------------------------------------------------------------------------------------
int DeleteNewsObjects()
  {
   for(int i=0; i<1000; i++)
     {
      ObjectDelete("NewsLine"+i);
      ObjectDelete("NewsText"+i);
      ObjectDelete("NewsCountDown"+i);
     }
   return(0);
  }
// -----------------------------------------------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------------
void DrawNewsLines(string news[][],bool showLineText,color high_color=Red,color medium_color=DarkOrange,color low_color=Blue,int startRow=1)
  {
   datetime local=TimeLocal();
   datetime broker=TimeCurrent();
   datetime current=0;
   double impact;
   bool skip;
   int totalNewsItems=ArrayRange(news,0)-startRow;
   if(Period()>PERIOD_H1)
      Print("Line text will only be shown for chart periods less than 4 hours");
   for(int i=0; i0)
        {
         if(news[i][COLUMN_TIME]!=news[i-1][COLUMN_TIME])impact=0;
        }
      else
         impact=0;
      string newsCurrency=news[i][COLUMN_CURRENCY];
      if(!IsNewsCurrency(Symbol(),newsCurrency)){skip=true;}
      if(!show_high_news && (news[i][COLUMN_IMPORTANCE]=="High" || news[i][COLUMN_IMPORTANCE]=="HIGH"))
        {skip=true;}
      if(!show_medium_news && news[i][COLUMN_IMPORTANCE]=="Medium")
        {skip=true;}
      if(!show_low_news && (news[i][COLUMN_IMPORTANCE]=="Low" || news[i][COLUMN_IMPORTANCE]=="LOW"))
        {skip=true;}
      if(news[i][COLUMN_TIME]=="All Day" ||
         news[i][COLUMN_TIME]== "Tentative" ||
         news[i][COLUMN_TIME]==""){skip=true;}
      if(!skip)
        {
         if(ImpactToNumber(news[i][COLUMN_IMPORTANCE])>impact)impact=ImpactToNumber(news[i][COLUMN_IMPORTANCE]);
         if(StrToTime(news[i][COLUMN_DATE]+" "+news[i][COLUMN_TIME])== current) continue;
         current=(broker-local)+StrToTime(news[i][COLUMN_DATE]+" "+news[i][COLUMN_TIME]);
         color clr = low_color;
         if(impact == 2) clr = medium_color;  else
         if(impact == 3)clr = high_color;

         string text="";
         if(news[i][COLUMN_PREVIOUS]!="" || news[i][COLUMN_FORECAST]!="") text="["+news[i][COLUMN_PREVIOUS]+", "+news[i][COLUMN_FORECAST]+"]";
         if(news[i][COLUMN_IMPORTANCE]!="") text=text+" "+news[i][COLUMN_IMPORTANCE];

         ObjectCreate("NewsLine"+i,OBJ_VLINE,0,current,0);
         ObjectSet("NewsLine"+i,OBJPROP_COLOR,clr);
         ObjectSet("NewsLine"+i,OBJPROP_STYLE,STYLE_DASHDOTDOT);
         ObjectSet("NewsLine"+i,OBJPROP_BACK,true);
         ObjectSetText("NewsLine"+i,news[i][COLUMN_DATE]+" "+news[i][COLUMN_DESCRIPTION]+" "+text,8);

         if(showLineText)
           {
            if(Period()StrToTime("9:45")) && (StrToTime(aucklands)StrToTime("10:00")) && (StrToTime(aucklands)29)
           {
            closingSession="Australia closing in "+(60-TimeMinute(TimeLocal()))+" mins";
           }
        }
     }
//Japan ....:  9.00 - 12.30    Re-opens  14.00 - 17.00
   if(JPYHoliday=StrToTime("8:45") && StrToTime(tokyos)0 && TimeDayOfWeek(tokyo)<6)
        {closingSession="Tokyo first session opens in "+(60-TimeMinute(TimeLocal()))+" mins";}
      if(TimeHour(tokyo)>=9 && TimeHour(tokyo)<17 && TimeDayOfWeek(tokyo)>0 && TimeDayOfWeek(tokyo)<6)
        {
         if((StrToTime(tokyos)>StrToTime("9:00")) && (StrToTime(tokyos)29)
           {
            closingSession="Tokyo final closing in "+(60-TimeMinute(TimeLocal()))+" mins";
           }
        }
     }
//Hong Kong..: 10.00 - 17.00
   if(CNYHoliday=StrToTime("9:45") && StrToTime(hongkongs)0 && TimeDayOfWeek(london)<6)
        {closingSession="Hong Kong opens in "+(60-TimeMinute(TimeLocal()))+" mins";}
      if((StrToTime(hongkongs)>StrToTime("10:00")) && (StrToTime(hongkongs)=StrToTime("7:45") && StrToTime(londons)0 && TimeDayOfWeek(london)<6)
        {closingSession="London opens in "+(60-TimeMinute(TimeLocal()))+" mins";}
      if(TimeHour(london)>=8 && TimeHour(london)<17 && TimeDayOfWeek(london)>0 && TimeDayOfWeek(london)<6)
        {
         openSessions=openSessions+" London";
         if(TimeHour(london)==16 && TimeMinute(london)>29)
           {
            closingSession="London closing in "+(60-TimeMinute(TimeLocal()))+" mins";
           }
        }
     }
// New York....: 08.00 - 17.00
   if(USDHoliday=StrToTime("7:45") && StrToTime(newyorks)0 && TimeDayOfWeek(newyork)<6)
        {closingSession="New York opens in "+(60-TimeMinute(TimeLocal()))+" mins";}
      if(TimeHour(newyork)>=8 && TimeHour(newyork)<17 && TimeDayOfWeek(newyork)>0 && TimeDayOfWeek(newyork)<6)
        {
         openSessions=openSessions+" New York";
         if(TimeHour(newyork)==16)
           {
            closingSession="New York closing in "+(60-TimeMinute(TimeLocal()))+" mins";
           }
        }
     }

   string TimeLeft=TimeToStr((iTime(NULL,Period(),0)+Period()*60-TimeCurrent()),TIME_MINUTES|TIME_SECONDS);
//----
   if(openSessions=="Active sessions: ") openSessions="Markets Closed";
   ObjectSetText("OpenSessions",openSessions,12,"Arial Black",session_upcoming_title_color);
   ObjectSetText("BarClosing","Time to bar close "+TimeLeft,10,"Arial Black",bar_closing_color);
   ObjectSetText("SessionClosing",closingSession,10,"Arial Black",session_closing_color);

  }
//+------------------------------------------------------------------+ 

void CreateInfoObjects()
  {
   ObjectCreate("OpenSessions",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("OpenSessions",OBJPROP_CORNER,1);
   ObjectSet("OpenSessions",OBJPROP_XDISTANCE,4);
   ObjectSet("OpenSessions",OBJPROP_YDISTANCE,0);
   ObjectSetText("OpenSessions","",12,"Arial Black",session_upcoming_title_color);

   ObjectCreate("SessionClosing",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("SessionClosing",OBJPROP_CORNER,1);
   ObjectSet("SessionClosing",OBJPROP_XDISTANCE,4);
   ObjectSet("SessionClosing",OBJPROP_YDISTANCE,15);

   ObjectCreate("BarClosing",OBJ_LABEL,0,0,0,0,0);
   ObjectSet("BarClosing",OBJPROP_CORNER,1);
   ObjectSet("BarClosing",OBJPROP_XDISTANCE,4);
   ObjectSet("BarClosing",OBJPROP_YDISTANCE,30);
   ObjectSetText("BarClosing","",10,"Arial Black",bar_closing_color);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void DeleteSessionInfoObjects()
  {
   ObjectDelete("OpenSessions");
   ObjectDelete("BarClosing");
   ObjectDelete("SessionClosing");
  }
//+------------------------------------------------------------------+
string TimeToString1(datetime when)
  {
   if(!show12HourTime)
      return (TimeToStr( when, TIME_MINUTES ));
   int hour=TimeHour(when);
   int minute=TimeMinute(when);

   string ampm=" AM";

   string timeStr;
   if(hour>=12)
     {
      hour = hour - 12;
      ampm = " PM";
     }

   if(hour == 0 )
      hour = 12;
   timeStr = DoubleToStr( hour, 0 ) + ":";
   if(minute<10)
      timeStr=timeStr+"0";
   timeStr = timeStr + DoubleToStr( minute, 0 );
   timeStr = timeStr + ampm;

   return (timeStr);
  }
// -----------------------------------------------------------------------------------------------------------------------------

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int ObjectMakeLabel(string n,int xoff,int yoff)
  {
   ObjectCreate(n,OBJ_LABEL,0,0,0);
   ObjectSet(n,OBJPROP_CORNER,Clockcorner);
   ObjectSet(n,OBJPROP_XDISTANCE,xoff);
   ObjectSet(n,OBJPROP_YDISTANCE,yoff);
   ObjectSet(n,OBJPROP_BACK,true);
  }
//deal with five digit broker
void HandleDigits()
  {
// Automatically handles full-pip and sub-pip accounts
   if(Digits==4 || Digits==2)
     {
      Points=Point;
     }
   if(Digits==5 || Digits==3)
     {
      Points=Point*10;
     }
  }
//+------------------------------------------------------------------+

 

 


@bellong

bellong
22 Jun 2014, 18:40

Test feedback

Installing cAlgo/cTrader  with wine 1.7.20 & winetricks r1196

- create a clean fresh new .wine prefix

- with winetricks, install one by one in that order: dotnet40, corefonts, vcrun6, msxml6 (with wine set as 'xp')

-download from Microsoft Windows Installer 4.5 (msi 4.5): copy the 2 files for your system (32 or 64 bits) inside the system32 folder (test done with the 32 bits here)

- download ctrader & calgo from your broker (MBTrading here) or from Spotware

- then set wine as 'windows 2000' with winecfg (have tested xp, windows 7 & windows 8 but they all fails)

- then select ctrader/calgo to be opened by wine : the process of installation start as expected and the program is loaded. Voila you are ready to use it.

 

What still does not work: even if the installer seem to do its job, in fact there is only a symlink dropped on the desktop for each prog, but not an exe ready to launch. Each time the 'installtion process have to be repeated. Not a big deal as its faster to use it that way compared to using virtualbox. Maybe a next tweak will be found or a next wine release will help.

 


@bellong

bellong
22 Jun 2014, 18:25

RE: RE:

forexner12 said:

bellong said:

Also note that : 

"WPF applications are mostly now working thanks to recent client side window rendering code." with recent wine (winehq) release.

http://appdb.winehq.org/objectManager.php?sClass=version&iId=10166

So i will  soon test both cTrader & cAlgo on Ubuntu with wine (and report back the results) 

 

hi have u done testing? was it sucessfull 

thanks 

 


@bellong

bellong
07 Apr 2014, 15:50

RE: how to change default font text size ?

Spotware said:

// ---------------------------------------------------------------------------------------
//
//    This code demonstrates use of ChartObjects
//    It shows the maximum of a DataSeries for a period.
//
// ---------------------------------------------------------------------------------------

using System;
using cAlgo.API;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true)]
    public class ChartObjectsSample : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("Period", DefaultValue = 30, MinValue = 3)]
        public int Period { get; set; }

        [Parameter("Text Color", DefaultValue = "Yellow")]
        public string TextColor { get; set; }

        [Parameter("Line Color", DefaultValue = "White")]
        public string LineColor { get; set; }


        private Colors _colorText;
        private Colors _colorLine;

        protected override void Initialize()
        {
            // Parse color from string

            if (!Enum.TryParse(TextColor, out _colorText))
            {
                ChartObjects.DrawText("errorMsg1", "Invalid Color for Text", StaticPosition.TopLeft, Colors.Red); 
                _colorText = Colors.Yellow;
            }

            if (!Enum.TryParse(LineColor, out _colorLine))
            {                
                ChartObjects.DrawText("errorMsg2", "\nInvalid Color for Line", StaticPosition.TopLeft, Colors.Red);
                _colorLine = Colors.White;
            }
        }

        public override void Calculate(int index)
        {
            if (!IsLastBar) return;

            ChartObjects.DrawVerticalLine("vLine", index - Period, _colorLine);

            int maxIndex=index;
            double max = Source[index];

            for (int i = index - Period; i <= index; i++)
            {
                if (max >= Source[i])
                    continue;
                                       
                max = Source[i];
                maxIndex = i;

            }

            var text = "max " + max.ToString("0.0000");
            var top = VerticalAlignment.Top;
            var center = HorizontalAlignment.Center;

            ChartObjects.DrawText("max", text, maxIndex, max, top, center, _colorText);       
            ChartObjects.DrawLine("line", maxIndex, max, index, 
                                       Source[index], _colorLine);
        }
    }
}

 

I have uploaded the indicator "draw spread" from your repo; and try to set a bigger font text size for displaying the "spread".  But im not lucky with my tweaks: how to insert the font size parameter ?


@bellong

bellong
16 Jun 2013, 11:29

RE:
hichem said:

Can't one just use Virtualisation to run cAlgo and cTrader on Linux ?

yes indeed, but its slower


@bellong

bellong
14 Jun 2013, 18:00

Also note that : 

"WPF applications are mostly now working thanks to recent client side window rendering code." with recent wine (winehq) release.

http://appdb.winehq.org/objectManager.php?sClass=version&iId=10166

So i will  soon test both cTrader & cAlgo on Ubuntu with wine (and report back the results) 

 


@bellong

bellong
14 Jun 2013, 17:49

maybe a wpf alternative ?  https://github.com/mono/xwt


@bellong