
Winson

Info
Username: | winsonet |
Name: | Winson |
Member since: | 03 Jan 2021 |
About
Signature
Last Algorithm Comments
@OrglobalFx ATR Risk Calculator V1.0: 04 May 2022, 06:13
this is very good and that's what I need, thank you so much!
@PinBar Detector: 15 Mar 2021, 16:00
Hi Symposium, Thanks for your suggestion, I have updated the indicator to show the left room candles! :)
@Information Pad: 20 Jan 2021, 02:31
Thank you!, ClickAlgo :)
@Sync Objects: 04 Jan 2021, 14:48
That's great!!! Thanks!!
Last Forum Posts
@TextBox: 19 Mar 2021, 14:21
WienAT said:
winsonet said:
I don't know what's the problems of your case, if you want to change the background color, just set it's color should be ok:
Overall1.BackgroundColor = Color.Red;
but I don't know when and where will you want to check the variable for do this?
I will try like you suggested.
I have one textbox where some text is presented (let say that also value of currenct profit is shown).
if profit is more then 0, then i would like to have green background ... if profit is less then 0, then i would like to have red background ...
If i understood you correctly, i should od like this:
if (profit > 0) Overall1.BackgroundColor = Color.Green; else Overall1.BackgroundColor = Color.Red;
Yes, and if you want to base on current profit to dynamic to change it, you can put the codes in
public override void Calculate(int index)
{
//your logic for calculate the profit
//update the background color
}
@TextBox: 18 Mar 2021, 15:21
I don't know what's the problems of your case, if you want to change the background color, just set it's color should be ok:
Overall1.BackgroundColor = Color.Red;
but I don't know when and where will you want to check the variable for do this?
@Range Bars indicator for showing where bar will close: 18 Mar 2021, 08:47
Oh, actually, I didn't use that, I think you can try to search the indicator with google site search, you will find many similar indicators :)
site:https://ctrader.com/algos/indicators range bars
@Range Bars indicator for showing where bar will close: 17 Mar 2021, 16:13
quantictrader said:
Hello,
I hope i am writing on the right section. I´d like to ask if anyone have an indicator that displays the High and Low thresholds for the current bar plus bar size information.
Thanks in advance.
Regards
I think you can try this:
@Position Size CBot: 17 Mar 2021, 15:54
jasonwm372 said:
Hey guys,
Can anyone suggest a good auto position size bot for me? Im a scaler on the 1M so I need a bot that shows the TP and SL and will calculate the lot size based on 1% of the account. Im having trouble finding some as I am new to Ctrader and getting used to it all, so if anyone uses any or knows a good one, it would be much appreciated!
Thanks!
you can also take a look another version of mine :)
@How to get values from "Sample Trading Panel" cBot: 29 Jan 2021, 10:54
dinhvuongfx said:
protected override void OnTick() { var tradingPanel = new TradingPanel(this, Symbol, defaultRR, DefaultStopLossPips); double stopLossPips = tradingPanel.GetValueFromInput("SLKey", 0); Chart.DrawStaticText("SL", stopLossPips.ToString(), VerticalAlignment.Top, HorizontalAlignment.Right, Color.White); }
Thank you. But I got only the default SL, I cannot get the SL value whenever I change the SL in Textbox
You don't create the new tradingPanel every time on tick, you need to put the trading Panel in a global and use it on tick:
TradingPanel tradingPanel; //define as global variable
protected override void OnStart()
{
//just need to create once time on start
tradingPanel = new TradingPanel(this, Symbol, DefaultLots, DefaultStopLossPips, DefaultTakeProfitPips);
}
protected override void OnTick()
{
//call the get value on tick
var sl = tradingPanel.GetValueFromInput("SLKey", 0);
Print("SL: " +sl);
}
@How to get values from "Sample Trading Panel" cBot: 29 Jan 2021, 09:05
dinhvuongfx said:
winsonet said:
oh, if you really want to get the value in the sample, there is a method GetValueFromInput for do that:
var lots = GetValueFromInput(LotsInputKey, 0);
this code from the sample, the LotsInputKey is the TextBox object name
"GetValueFromInput" is in TradingPanel class, not in main Class so I cannot get the value from panel
easy, you just make it public and shoiuld be ok :)
for example , change below
private double GetValueFromInput(string inputKey, double defaultValue)
to
public double GetValueFromInput(string inputKey, double defaultValue)
and you will can use it as below:
tradingPanel.GetValueFromInput("name");
@How to get values from "Sample Trading Panel" cBot: 29 Jan 2021, 09:02
oh, if you really want to get the value in the sample, there is a method GetValueFromInput for do that:
var lots = GetValueFromInput(LotsInputKey, 0);
this code from the sample, the LotsInputKey is the TextBox object name
@How to get values from "Sample Trading Panel" cBot: 29 Jan 2021, 08:57
But I did't say how to add the TextBox control, but if you know how to add the label into the panel, you should know how to do with the TextBox, it's same :)
@How to get values from "Sample Trading Panel" cBot: 29 Jan 2021, 08:54
dinhvuongfx said:
winsonet said:
dinhvuongfx said:
winsonet said:
the value will save in a TextBox control, you can get the value with the TextBox Text attribute, for example:
the textbox control name is : tbSL, then you can get the value as below:
tbSL.Text
I added 2 functions in class "SampleTradingPanel"
private readonly IDictionary<string, TextBox> _inputMap = new Dictionary<string, TextBox>(); protected override void OnTick() { var stopLossPips = GetValueFromInput("SLKey", 0); Chart.DrawStaticText("SL", stopLossPips.ToString(), VerticalAlignment.Top, HorizontalAlignment.Right, Color.White); } private double GetValueFromInput(string inputKey, double defaultValue) { double value; return double.TryParse(_inputMap[inputKey].Text, out value) ? value : defaultValue; }
I got an error: "Crashed in OnTick with KeyNotFoundException: The given key was not present in the dictionary."
why you need to use _inputMap for save the textbox? also, if you want to do that, you need to add the textbox object in your dict at first
I don't have much C# textbox experience. Could you please check "Sample Trading Panel" cBot and print Stop Loss (pips) from Panel to the cTrader screen whenever tick changes and give me all the code?
Thank you so much!
this sample there is a little complicated for beginner, it created a custom control object and encapsulated the textbox control in it, if you just want to create a simple panel and get the value, you can take a look my Information Pad indicator and the description in here:
my indicator: