Topics
Replies
neverman
29 Sep 2014, 15:07
RE:
Spotware said:
Do you use cAlgo OnTimer method or system timer?
Here you are the code:
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Globalization; using System.IO; using System.Windows.Forms; using System.Threading; namespace cAlgo { [Robot(TimeZone = TimeZones.EEuropeStandardTime, AccessRights = AccessRights.FullAccess)] public class testClipboard : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { Timer.Start(TimeSpan.FromMilliseconds(1)); //start timer with minimal interval //Timer.Start(1); //start timer with 1 second interval } protected override void OnTimer() { copy_to_clipboard(); } public void somethingToRunInThread() { //############# clipboard work ################ string ClipboardData = ""; double AskEUR_CT = 0; double BidEUR_CT = 0; Symbol EUR = MarketData.GetSymbol("EURGBP"); Symbol USD = MarketData.GetSymbol("GBPUSD"); Symbol CHF = MarketData.GetSymbol("GBPCHF"); Symbol JPY = MarketData.GetSymbol("GBPJPY"); AskEUR_CT = EUR.Ask; BidEUR_CT = EUR.Bid; ClipboardData = AskEUR_CT.ToString("0.00000") + "," + BidEUR_CT.ToString("0.00000") ; Clipboard.Clear(); Clipboard.SetText(ClipboardData); } protected void copy_to_clipboard() { Thread clipboardThread = new Thread(somethingToRunInThread); clipboardThread.SetApartmentState(ApartmentState.STA); clipboardThread.Start(); } protected override void OnStop() { // Timer.Stop(); } } }
its a little changed from the first version (do not write to csv file), but the error is the same. Obviously its related to clipboard work. And I'm using OnTimer method.
@neverman
neverman
27 Sep 2014, 20:39
I decided to decrease the amount of calculations on the script, and this allowed me to decrease the milliseconds to 25. Now another error appear.
Problem signature:
Problem Event Name: CLR20r3
Problem Signature 01: ctrader.exe
Problem Signature 02: 1.24.102.34377
Problem Signature 03: 53ff6fe2
Problem Signature 04: mscorlib
Problem Signature 05: 4.0.0.0
Problem Signature 06: 4ba1da6f
Problem Signature 07: 3dab
Problem Signature 08: 1f4
Problem Signature 09: System.IO.IOException
OS Version: 6.1.7601.2.1.0.256.1
Locale ID: 1026
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789
I hope this info will help to give me idea for a solution.
@neverman
neverman
15 Aug 2014, 11:00
RE: RE:
Spotware said:
neverman said:
Hello,
I worked on the following code and its not working very well:
var dailyEurGbpSeries = MarketData.GetSeries("EURGBP", TimeFrame.Minute); var dailyClose = dailyEurGbpSeries.Close.Last(1);
I'm starting this code on tick graph with the idea to get the last M1 close (not current). I added Print(dailyClose) to the code and the result was strange.
07/08/2014 22:15:59.909 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:00.143 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:00.564 | GBP, EURGBP, t1 | Previous Close is0.79377
...
07/08/2014 22:16:06.211 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:06.243 | GBP, EURGBP, t1 | Previous Close is0.79381
As you see it took 6 seconds to show me the true Close M1. Where is the mistake ?
First of all, please rename dailyEurGbpSeries variable, because it is minute, not daily series. It is not clear why do you think that GetSeries took 6 seconds. Please try to clarify your question.
The code is ran on 1 tick graph. It is made every tick to show me Previous 1 Minute Close using above example.
From the above raport, there are 5 given only tick raport from a minute 22:16 ... until 22:16:06.211 the script shows Close Quote from minute 22:14 ... from 22:16:06.243, the script shows close quote from minute 22:15.
Normally, the Last Minute close have to be given after 22:15:59.909 ... am I right ?
or Is it possible the fiven time to be client time, not server time ?
@neverman
neverman
14 Aug 2014, 22:07
When my broker agent told me about cTrader, he assured me that there is a great tutorial and very useful forum when I can receive information about the coding ? Any idea why he lied me ? One WEEK I can't receive an answer of simple question ?! I suppose its better to rethink the idea of using non supporting software for trading.
@neverman
neverman
07 Aug 2014, 22:32
Hello,
I worked on the following code and its not working very well:
var dailyEurGbpSeries = MarketData.GetSeries("EURGBP", TimeFrame.Minute); var dailyClose = dailyEurGbpSeries.Close.Last(1);
I'm starting this code on tick graph with the idea to get the last M1 close (not current). I added Print(dailyClose) to the code and the result was strange.
07/08/2014 22:15:59.909 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:00.143 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:00.564 | GBP, EURGBP, t1 | Previous Close is0.79377
...
07/08/2014 22:16:06.211 | GBP, EURGBP, t1 | Previous Close is0.79377
07/08/2014 22:16:06.243 | GBP, EURGBP, t1 | Previous Close is0.79381
As you see it took 6 seconds to show me the true Close M1. Where is the mistake ?
@neverman
neverman
04 Aug 2014, 11:12
RE:
neverman said:
Hello,
I need a little more help. I need to know how to get in same script data (Open High Low Close timeframe last m1, not current) for EURUSD and USDJPY when the script is ran on other timeframe than m1. Let's assign the data to variable EUROpenM1, EURHighM1 and JPYOpenM1, JPYHighM1.
Thank you, this will help a lot.
no need to answer ... answers are here /forum/calgo-support/3115 ... thanks anyway
@neverman
neverman
31 Jul 2014, 20:52
RE:
neverman said:
Hello,
I got a problem using the clipboard. I got data in the clipboard that I want to assign it on a variable. I found a post in the forum
/forum/cbot-support/799
but i have trouble with it, I suppose because I have no reference to System.Windows.Forms.dll ... I have no this DLL and have no idea how to make this reference to cAlgo.
Please provide me with step by step tutorial how to deal with the DLL and assign the clipboard data to a variable.
Thank you in advance.
I found the button Manage References and made the reference to .net framework. So how to get data from clipboard ?
@neverman
neverman
29 Jul 2014, 19:48
RE:
Spotware said:
5. Of cource for observation needs, I need a code that places datas every tick in CSV file like ask(bid) quotes, server time (hour,minute, second, millisecond), connection speed to the server, current order (type (buy,sell),SL, TP, volume, magicnumber)
You can find an example of writing to a CSV file there: /algos/cbots/show/495. You will need to put your to code to the OnTick handler. You can retrieve prices from Symbol.Ask and Symbol.Bid properties. Server.Time property has DateTime value which stores hour, minute, second and millisecond. Connection speed is not available in the API. There is no current order entity in our API. You can enumerate all Positions with foreach instruction. All position properties are presented there: /api/reference/position.
I can't handle this :(
I'm trying to save data every tick Ask and Bid together with Data and HH:MM:SS.mmm in CSV file. The problem is that the code saves me only last data. Please tell me where I'm wrong.
using System; using System.Globalization; using System.IO; using System.Linq; using System.Threading; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class DumpToCSV: Robot { protected override void OnTick() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); var folderPath = Path.Combine(desktopFolder, "cTraderData"); Directory.CreateDirectory(folderPath); var filePath = Path.Combine(folderPath, Symbol.Code + "-" + Server.Time.Day + "-" + Server.Time.Month + "-" + Server.Time.Year + ".csv"); using (var writer = File.CreateText(filePath)) { writer.WriteLine(ConcatWithComma(Server.Time.Date, Server.Time.TimeOfDay, " ", Symbol.Ask, Symbol.Bid)); }//using }//onTick }//DumpCSV }//cAlgo
Aslo, I can't put on the first row label of colomns and can't add properly mileseconds to the HH:MM:SS.mmm ...
Also any ideas how to put working directory different than Desktop (maybe without granting full access rights ?). Thanks in advance
Help me please
@neverman
neverman
08 Jul 2014, 15:40
RE:
Spotware said:
3. When I make an order, then its possible to change StopLoss and TakeProfit of this order. On MT4 there was a possible Stoploss and TakeProfit (pips away from current price). Is there something in cTrader and how to get this possible Stoploss and TakeProfit
There is no restriction for minimal pips away from spot prices.
6. How much money i have to possess in mu account to buy the minimum 10k eurusd, or 10k gold ... etc ... newbee question.
In order to calculate required margin you can use the following formula:
private double GetRequiredMarginForLongPosition(long volume, Symbol symbol) { return volume / Account.Leverage * symbol.Ask * symbol.TickValue / symbol.TickSize; }
thank you for the useful information ... it will help a lot for reprogramming my script. I suppose that I'll have more questions about the given information, but I'll ask later.
Great work !
@neverman
neverman
07 Jul 2014, 20:47
RE:
3. I need come code to shows me the possible SL and TP for some placed order.
Sorry, but we do not understand the question.
6. A code to shows me what quantity of some pair I can order for the money i got.
Sorry, but we do not understand the question.
Excuse my english:
3. When I make an order, then its possible to change StopLoss and TakeProfit of this order. On MT4 there was a possible Stoploss and TakeProfit (pips away from current price). Is there something in cTrader and how to get this possible Stoploss and TakeProfit
6. How much money i have to possess in mu account to buy the minimum 10k eurusd, or 10k gold ... etc ... newbee question.
@neverman
neverman
06 Jul 2014, 10:28
RE:
algoЕVIПІм>юtсЕ9{‹‘ЏыxymrОiГђ79ОCКзC‘€j§”ТВrц†CЃ!Ы $e=n‡sHКu30yЇ v+ьuцQ‘qФђжижзH$уя|Lo¤Ґ›wGбх Ё….K1еEщДц&§ѓФцwYТ ч@ЋCКЏђXѕгцБIмBЬ*#пШН{ЌN\ wЏe5|як5U†{^«тg›NpО¦?„" ‘ф0лУ{•ЯюyЫbґ"ЈL\фT‡F†зN_ESTc&"±гHЮ€ф‡]6У¤„Xjжr;Хp·ь,‚УЖk»Ї‹EXq3Йѕn»+%©”(ЖI9:Бы1 8a ьcЄdЮюdнHбыхm•‹ЊўTГ]Rtсчѕ"кЈј‚гЧХ<ЧЖИЗLоьB$\@s4ДИЫе)№OнЬАу !@uП —QMї‰sъ#Џ2”I@Єйњ$ѓwjpoЖvM3yЫFьAо…eк0&Ј~[ЪnФцTсфc9Lј•Z\2эУуMѕхAҐ"дТ“Њ”ЭЩ¬Дч(]џђэ•АCmП°›®:d!э6ЙnЇЦUеpVц)к„7нtЋЬ^^ф¦LВР0ъШgґѕцБd‡“Ї1tpВC¶…шБfЮї`<‚f‹µІ њвП)%Хш0gNЄ«№ъь›$Єу}"ЁИУЩ‹pФg!U”Йгё†NYeгП5™сТ©/7мe+НAќікЃ;¬Ћ¦y0¤ѓt ШўЮ›[КвЦ–#шХњЯz’%X¦ПёЈП[ОдЙ/цc€Kc°IлЦГpc¶EйГCг,"гh9шѕ>€€ic#›±Јд6ш/ЎјH„€нќ>,kX†ЇЋЗq&'МЮлИЛ|Ш°Ьк\ЇЬ»вЪ&°2/µb>4еј?И!['m¤[ђ&Оя"Ч wсўг¶/j¬ “aГЊ2ЄµКЙ+йHђ’€ЌУu02‹“_CРІp ‹ЅIїУуЊM*_p1жПЃD*ЏKК'd•P-х&”Uре3·ОБчrДgm”/‰я!haЃh€У‰K,6… Е†0»mҐЇкКSvf8ыГDвм]TVуlM)с‘yлЅ5і7Ч-‡›jGё‚2brј2›†}oле®ЦЎчХЉYo–л@Ют¤€®*#ѓ#Ы:Њ%c]tw¤V’EUЋФ#а !U_–,J±гЉѓаY&<'SiщЏвo:ЫmІVЃtҐЫПўOBf:§0чсUBЎtхY4й<°ЇR«SЛ%Ч|vџb$/е3Щ±uSй‹Ѕ5У‹Пl0эЎ/%цXћР±»Ъяjн¦дТЗє™R3Ш——†Ќµ>Џ[°’9ВL†…µzЭ nыйЉWEЃbлв·:¬?‚N_fҐSрЁЙьт!Jч»ЙB°Э ЉёЉBp2н’T ¶ BГЌац-A3›gшЫ>–`ФY·6Њ »ћЯ!\њ3ёmr`В,}дЌ~е:IЪ® егGѕЧ“{ yЅ%љТђўЋн]}в0ЅivЬ‘ЦBБ eФ»Q љюЈйL/ЖшД”A)¦ыe4Qq—CNЃ?лЧ)нХЏџU{"яmЮЛpu·G•ц«ѕ G(0„ЏЋ„ЗµJі”;:6ЪGҐЮЮ8Ц8ЮQш0?зїћЖsн—лO€6·…!В|Mј)†аји=TћЛ±тв%†/elѓ3цзb,SьT°йн^ЄяOЦaГЯЛ>Пр+`‡й·Љ Є6љ‘%Ф |AH‹\,-$мїЉ*ыі—Eњµїlм„жЇТЂrџ СXІeЇK©R~CX^ћ2Їгл‚щ=ЩIТґBЎWчкр2•о@cгнбЏЧТ1J“J]xіЪѓ Ђ!-Eсбzw 98PЌ/]hLS|ј6PzЋ=т‹<Р6ѓ=ќu`3бЫж»IFЏиxљТ=Ґ,ўљ<Џ&„°wБ%¦И,5VRвпnї3.|wлСй~,ІaЄ“2#ыМih]ЯЭyБТ‡ч;aёЈЙЮ€бм}›Џ?•џ‡_є»О€UЎќlSC04‘LщВЂvЃ(tБУ—А5FїП;БЏdЯ±ФуГxNЁt†оютЌV«"Ёч р"чN—щE и[ ]ќrн~—LґЌЩйЁШ,Оs8бi{D‚cW¤P“b—Шхtв ц·wПҐТм•w!Сл™иШр~40Ю„n‚Ф4кјPyЪa;ВPИ UіягJВ°›ОЭUOЩЇИ–~гe13h$qUЎ®нУѓ±<CnOцЌОчСYORФ,ЦCП-uѓ}%[’O¦rјЙPnЃшейrў^uc®К#ыHП €њ'c4Oж®№Oџv™w*Ъ0tа$ХрЈTпCnРxC9ўоg\жCю;‹VЕЧ±Uо[rqВ0џDl+Ђ0вЄњcy^iuJ№M®†ќ(ы ·DH/”ЁZ6vбФі)[TЖ=Њж]ѓ4gдaтЎ•€<uР9Х^~ЃtЈГпЉGў:Ґ’VрxЌTџќЄEЫБ=7IH&к?wНє~G'ZкЈ"/бЙZй5М&ц °Tю*ZuUOЙ&Д*ь‹1аi?”У¦?EщN`CFЃO§9Ўh%Жsъќ$]Щsуаq}ўж^vњШM`эВgШ§ёoCЊјEю ѓzЄLы]Љв)б‚—К]rЭ!їѕНїjnЁ,ыtBVЌ°pO'©2ИГЭМA4fLѕџ™о0ПoБЭ ¶g`UPИўфnЙY5dЖfЇ©ЙІјІ © [ISДu tKгМРІ™‘~R$џіиg¶›u4 “ї–ЅЦУъ Ф'К§ГА8¶UґИ0ьњ¦ЭМ7В_ИљFOJЈў}я Ґ‡k1Ѕ•Б Х:pµ‡>*нжAP|a›%ЌBP’DмJ[бGф|nл…Х@ЁЂQѕ+‘ґQЫЋ’шяm‡ИЉKМјB¦u® eХњбјi]н!cЮчяЈєlvЉо]}#.:W0і@6јLIBЪ{GхН[щ ы^@гYI†uЏў® Д*1:ыМЊ%АЯжzцъЏФf&<:¬‚жakXс·g]«I4B|ЬЅ>PЇfZБZ‚KэOM7ЃaЖк5гЬ&b¦^QЈО$kI%ё¤aРІщRбaёчЋєyЌ™€ЯRЙ}mТИзuэ§Мг8rCШ5&ъ|y€ц )§¦¦„G(J'jеGДЅZГЬЙV s,њЪ}i 1$9AЁ€Vq¬[L‘з®s¶ьWЊц•П][4`ћЧ·ЁЪY’Z;;”ЦWІ5hI6}Pmb±П‡н7Ўcм°ў56є[џjВбЗЌ1\е‰џЅ@У-:сђ9·§ъFwd “БNд'нn¬¶дЗKqЛZc.х€Y_|gп,O0еиД7џђA%eЂwS2Ѓ„тµKB°eс И›ҐЬdh5^±ІСЪz|г§р&Y'Г…Ѓйъ€¤{гЧ0СЪMXЬG Г-џшИ_¶ДTEЎVvнНS6ГйДХM"FеYФж•РБ°ґИЖ8ЋїPЫь‹fѕЙQ•#‘U<#-椈Оv fшЎ<gШQt#\џЊНW92І‡#Jч9РцЄрj“яM]OдGлтpЭЁу™љtЩЂ)ДЄ6Ґ”wqЇтПd№kBР/~ЏыFЄ•і)^ў·±8РЄЏB,йНnЅѓ9zXяўxр‡Ќ<NЉwЋвіД3ОWїw"$Хu>"БАЯ·МQ•±n)uкE2 `Ф©ЉґвєбЭ}ЈzHj:ЌЙ—ЦЗўДі-JЊЬсФ+Nз6+Хp·“ уТї:]|›*JKTw–Е µpU ЊПdRu“lWЗСаn/`VЄЛащpЃp* Ў·>Ћµўзии.(F•JЛџм7ю|сњ|¤}M~ЊР‡†’щдЌ1eГ„7tЇ*¤¦0внyЛнУВbц†CЃ!L$e=n‡szE}мQ Ц›ћЙЉј™ѕ6‚t:W°t±0.Wў}°тWrЋDuЗц7цtзzчeіEнвЙ3/Г”MѕIЁ4о0—d&/т¬C№ Й¶6ў¤]љжeВ“mъч¶~MжVшI` ЊыХп К—‡¦Чт‚ЛФС№4ыV-цТ©РlЦЎF"ЕЙuІ€g/_/ШH,фУр}‹/Тб пщу7[ъ*°нђПЅ>V!HR›&UрЮЦапKrEe!EЪ{ѕQ55~Ф[њ$±'iжЂЬeXљKY…;e‘§*xdЪcчFОeЁЂQT№А.ЗбЊЕ‰јм@/єч…ъBґqwњMMп9 ЇъЇџЕлsѓвЎсЊ#ЄЁяБІjђ=ќвB#бyЫњ‹{»<'5XА0†”=СР…)Ј]пxZ•Ы\Н]Ў щЁhV%5Oьtќ§ Ѓгы Мј·Ц}!%KЩ>ъ&ЊмФz«OБ,.АHwШІ$Ъђ»ЎЏR#*»C2°›^в[V+RflPЉЁЅe›HsшqIѓYЏФiВ6§?Џ{“a›•}[®>T4>З{mV§»њ9?RЫSR†мLѕ-Б[ККгВ.%QоTГЏлЈV<A…GBчnИњ"•|№f‹ с„U}G.zючN‹Т‰kТУХ‚ГУЁ%иФS‡C7оъ їъШ@|pРN—В}ж“< ЭЫ:W^-'vґќШkjЩьjѓV8JЧPХЎВlф.ЬBЕh›ГTъ7щк¦У№?џZЗЈр ?oj»Ѓи‹ы(ҐЄ=9ao>- WлЏ:ИЏ·ћФйЌ„Ё™xoNnои (|=кЕeГЮ¶SЯM"FеYФж‰РБ°ґИЖhЕѕRиь¦oѕБQМP9 Ц0№[w1‰х™^0gМQt#\џЊНW92І‡#–Pѕ·Щѓkс“4\OфGлтpЭЁу™ ~ЩЂ)ДЄfо‘qqЇтОdёkР/~bсFЄ•і)^ў·±8РЄЏB,йНnЅѓ9zXяўxр‡Ќ<NЉwЋвіД3ОWїw"$Хu>"БАЯ·МQ•±n)uкE2 `Ф©ЉґвєбЭ}ЈzHj:ЌЙ—ЦЗўДі-JЊЬсФ+Nз6+Хp·“ уТї:]|›*JKTw–Е µpU ЊПdRu“lWЗСаn/`VЄЛащpЃp* Ў·>Ћµўзии.(F•JЛџм7ю|сњ|¤}M~ЊР‡†’щдЌ1eГ„7tЇ*¤¦0внyЛнУВbц†CЃ!L$e=n‡szE}мQ Ц›ћЙЉј™ѕ6‚t:W°t±0.Wў}°тWrЋDuЗц7цtзzчeіEнвЙ3/Г”MѕIЁ4о0—d&/т¬C№ Й¶6ў¤]љжeВ“mъч¶~MжVшI` ЊыХп К—‡¦Чт‚ЛФС№4ыV-цТ©РlЦЎF"ЕЙuІ€g/_/ШH,фУр}‹/Тб пщу7[ъ*°нђПЅ>V!HR›&UрЮЦапKrEe!EЪ{ѕQ55~Ф[њ$±'iжЂЬeXљKY…;e‘§*xdЪcчFОeЁЂQT№А.ЗбЊЕ‰јм@/єч…ъBґqwњMMп9 ЇъЇџЕлsѓвЎсЊ#ЄЁяБІjђ=ќвB#бyЫњ‹{»<'5XА0†”=СР…)Ј]пxZ•Ы\Н]Ў щЁhV%5Oьtќ§ Ѓгы Мј·Ц}!%KЩ>ъ&ЊмФz«OБ,.АHwШІ$Ъђ»ЎЏR#*»C2°›^в[V+RflPЉЁЅe›HsшqIѓYЏФiВ6§?Џ{“a›•}[®>T4>З{mV§»њ9?RЫSR†мLѕ-Б[ККгВ.%QоTГЏлЈV<A…GBчnИњ"•|№f‹ с„U}G.zючN‹Т‰kТУХ‚ГУЁ%и //:Robot
not working, when open with notepad, you see what happens. I added the strings you are told, nothing happen. Where is the mistake ? BTW, the code i wrote already and can see it also is shows like that in notepad.
@neverman
neverman
29 Sep 2014, 15:42
RE:
Spotware said:
Not a big help for the moment ... like "Doctor, when I touch here I feel pain ... so don't touch here!"
@neverman