Topics
Replies
gunning.ernie
17 Aug 2018, 22:47
RE:
Spotware said:
Dear Trader,
The DrawText method can be used in a cBot. Please have a look at the following code snippet.
protected override void OnStart() { var name = "myObject"; var index = MarketSeries.Low.Count - 1; var low = MarketSeries.Low.Last(1); var text = low.ToString(); var xPos = index; var yPos = low; var vAlign = VerticalAlignment.Bottom; var hAlign = HorizontalAlignment.Right; ChartObjects.DrawText(name, text, xPos, yPos, vAlign, hAlign, Colors.Red); }
Hi Spotware,
How would i go about to draw text vertically? like from down to up or up to down?
@gunning.ernie
gunning.ernie
24 Dec 2017, 07:30
RE:
Spotware said:
cAlgo.API is not thread safe.....
Is this still the case today? I'm asking cause I use the Parralel libraries like parallel.For...?
@gunning.ernie
gunning.ernie
23 Dec 2017, 11:43
Thanks Panagoitis again for your effort and time to assist,
To conclude and get back to the question I asked around "what i need to specify in the volumne parameter and how to calculate it?"
cAlgo uses volume(long) to open trades and MT uses lot (decimal)
For clarity sake I will use above parameters from the first post as example
Metatrader used Lot size and was calculated as follows:
Full Lot : 100 000
Leaverage: 100
Currency pip size: 0.0001 (in MetaTrader it was 5 decimals, but to keep thinks same i wil use 4)
micro lot (0.01lot) value: (100 000/100) * 0.0001 = 0.10 c
NB: I cant tie the 0.01 lot to something. if I multiply it with a full lot (100 000) the formulate is broken with leaverage. So i dont know how or where 0.01 lot came from?
micro lot (0.01) = $0.10c
so you would use 0.01 lot as parameter to opren trade.
CAlgo uses Volume and gets calculated as follows:
Lot : 100 000
Leaverage: 100
Currency pip size: 0.0001
Volume Step = (100 000/100) = 1000
a Volume step has a pip value of : 1000 * 0.0001 = $0.10c
so when opening a trade you need to specify 1000 as the volume for 0.10c pip value. YOU should increase the Volume by units of the volume step to increase your pip value. For example, you cannot specify 1500 of 4300. it should be devidable by the step (1000). So correct values are 1000, 2000,3000...100 0000.
@Panagoitis, please can you verify my section above?
If everything is correct above then I assumes that Quantity (double) in the PendingOrder class is the amount of units of volume you want to trade thus you can use the QuantityToVolume function that will multiply Quantity with Volume.
Some aditional notes:
Formula :
((Full Lot) / (Leaverage) ) x (pip size) = pip value in bank account currency
100 000 / 100 x 0.0001 = 0.10
This formula scales nicely down in pipvalue when you increase the leaverage...as it should.
I tried bringing the micro lot (0.01) into the equation and it screwed things up and didnt scale...so im confused as to why i traded in lot in MT4 and 5...?
@gunning.ernie
gunning.ernie
23 Dec 2017, 08:42
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
The percentage of your risk depends on where you will put your stop loss, not only on the volume. In leveraged accounts you can risk your entire account balance if you do not use a stop loss. The higher the volume, the less pips needed to reach your risk threshold. For example, if you open a position of $100.000 and you want to risk only $100, you need to place your stop loss at 10 pips since each pip is $10.
The leverage does not change the amount of risk. It is the size of the position itself that determines your risk. Leverage just defines the minimum margin required by the broker to open a position i.e. with a leverage of 1:100 the maximum position you can open with $1000 is $100.000.
I hope this helps.
Best Regards,
Panagiotis
"The percentage of your risk depends on where you will put your stop loss, not only on the volume."
I agree, I feel there is 2 types of risk in a trading bot strategy. Your trading risk (stoploss position - risk is with time in the market here) and your finacial risk (money management strategy - how much you risk finacially based on volume). They are seperate risk elements as they independantly can yield very diffrent results.
"In leveraged accounts you can risk your entire account balance if you do not use a stop loss. The higher the volume, the less pips needed to reach your risk threshold."
Agreed, I finaly can understand when you talk volume here. In my MetaTrader days i talked lot sizes. This is were I was confused as I know lots which van be fractional (0.01) to place an trade. In cTrade Volume cant be fractional...
"The leverage does not change the amount of risk. It is the size of the position itself that determines your risk"
Agreed.
Hope i clearly explain myself?
@gunning.ernie
gunning.ernie
23 Dec 2017, 08:21
( Updated at: 21 Dec 2023, 09:20 )
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000. Regarding your calculation, leverage in not related to pip size. Leverage is related to your account's margin. Pip size is only related to position size. The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.
Let me know if my explanation makes things clearer to you.
Best Regards,
Panagiotis
Hi Panagiotis, Thanks for you posts and I do appreciate you responses. I must admit that I just couldnt grasp out of all your post what I should populate Volume with. I have spent some time and I beliwve I know now AND I would like you to confim this in my LAST post. I'm stepping one step back and responding to you post inn a quote by quote mater that confused me. This might cause out conversation to spawn in multple conversations BUT if there something to learn here I would like us t try and keep track as I see my self as still a learner although I have been a while in this. Here we go:
"Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000"
I do understand from this sentance where we I missed your conversation. 100 0000 (1 lot) was my volume. It is not the volume for cAlgo. I will explain in my last post for clarity on guys comming from mt4 and 5 (please inspect my answer)
leverage in not related to pip size
Agreed, I was talking about pip value in my first post
Leverage is related to your account's margin. Pip size is only related to position size.
Agree
The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.
I Think we might missing each other here. Your statement on "In reality" are you saying reality without leaverage? then I can agree, but my formula is correct except for the 5 decimal places used as you mentioned it should use 4 decimal places (lol i only read this now...i figured this out after some trail and error ouch). So the result is $0.10c in above formula in my first post and this alligns with what cTrades is saying, see image below:
(100 000(lot)/100(leaverage) = 1000.
1000 x 0.0001 (pipsize 4 decimal) = $0.10c
Please let me know if I clearly explained myself?
@gunning.ernie
gunning.ernie
22 Dec 2017, 10:52
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
Volume is just the amount of base currency you would like to invest in your position e.g. 100000 in EURUSD means a position of €100.000. Regarding your calculation, leverage in not related to pip size. Leverage is related to your account's margin. Pip size is only related to position size. The result of your calculation should be $1. In reality, the pip value of EURUSD is $10 since the the pip position is on the fourth decimal place.
Let me know if my explanation makes things clearer to you.
Best Regards,
Panagiotis
Thanks Panagoitis,
Let me try a example, if I have a 1:100 leaveraged account with a balance of $1000 and I want to risk $100 (10%) in my next trade. Do I just put 100 in the volume?
@gunning.ernie
gunning.ernie
21 Dec 2017, 06:46
RE:
Panagiotis Charalampous said:
Hi gunning.ernie,
The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example
using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { var EURUSD = MarketData.GetSymbol("EURUSD"); var GBPUSD = MarketData.GetSymbol("GBPUSD"); var EURJPY = MarketData.GetSymbol("EURJPY"); var USDJPY = MarketData.GetSymbol("USDJPY"); } protected override void OnTick() { Print("tick"); } protected override void OnStop() { // Put your deinitialization logic here } } }In this case, OnTick() will be invoked for all four symbols.
Let me know if this helps you.
Best Regards,
Panagiotis
Thanks Panagiotis, This helps allot. This is my first stab at cALGO and i have noted on other post the same...they are old. You think certain functionality is not there then it is...
Thanks again for the effort.
Ernie
@gunning.ernie
gunning.ernie
18 Dec 2017, 20:17
RE:
Spotware said:
Dear Trader,
OnTick() method is triggered on each incoming tick of the Symbol your cBot is set to run.
Hi Guys,
This is a big one for me. You cant have a trading strategy tied to 1 chart (one symbol and time frame). a trading strategy can be applied to many symbols and many timeframes. So you have a 1 to many relationship here apose to 1 to 1.
If my cbot trades 5 pairs and I register the bot to 1 chart of the 4 AND with what you telling me is that I will only receive ontick events for the 1 symbol on the chart, right?
AND what you suggesting is to get the other symbols data on the Chats OnTick event... then the 4 symbols would only be processed when symbol 1 has a OnTick event. THIS IS A HUGE RISK TO ME
I would like to trade the calendar fundamentals and a micro split second is very important. Thus a timer based approach is also not feasable..
Is there no pub & sub (publish and subscribe pattern) were I can subscribe to for Ontick feeds for multiple symbols?
@gunning.ernie
gunning.ernie
18 Dec 2017, 20:06
RE:
Spotware said:
Dear Trader,
OnTick() method is triggered on each incoming tick of the Symbol your cBot is set to run.
Hi Guys,
This is a problem, a trading strategy should not be limited to one symbol ontick feed. We have a 1 to many relationship here as I have 1strategy being applied accrosss many symbols AND timeframes. I would siggests a Pubish subscribe pattern were so my bot can register to all the symbol ontick data feeds it wants to receive. Otherwise my other symbols which is not related to the bot's chart is only getting their updated data bassed on the chart's symbol so i will definitaly be delayed on my other symbols for data.
Hope im making sense,
This is a HUGEt issue for me...
A timer is not an option as I'm trading fundamentals (calendar news) and with a huge news events every micro second count.
Any suggestions?
@gunning.ernie
gunning.ernie
04 Apr 2024, 19:16
cbot using custom indicator with rectangles
So My custom indicator draw rectangles and detects when the market moves in and outside of these chart objects. Now I wrote a cbot to utilise this indicator and it is not working because this indicator is not drawing chart objects through the cbot. Are you telling me I cannot let the bot add the indicator and let the indicator do the heavy calculations and let the cbot just read the indicator series? the indicator also raises events for break outs which my cbot is subscribing to.
Am I screwed now?
@gunning.ernie