Replies

WienAT
21 Mar 2021, 01:44

tnx :) It's working :)


@WienAT

WienAT
18 Mar 2021, 18:34

RE:

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;

 


@WienAT

WienAT
18 Mar 2021, 01:21

I think my problem was that I used above code in PositionClosedEventArgs. This was run very often and probably caused multiple layers of TextBlock.

Anyhow, now I am using textblock in combination with grid.

I created grid and textblock which runs ONLY once OnStart- What i need to do that value of "SymbolWinRatio[2]" is updated in TextBlock in "SymbolWinRatio3" and consequently we will see also updated value in GRID  - value should be updated after values is changed in "PositionsTrack"

             protected override void OnStart()
             {
              Positions.Closed += PositionsTrack;


               var SymbolWinRation3 = new TextBlock
                {
                    BackgroundColor = Color.Green,
                    Text = "Symbol WinRatio " + SymbolWinRatio[2] + " % "
                };


              // Creating GRID (rows, columns)
                var grid = new Grid(40, 40)
                {
                   // BackgroundColor = Color.LightGray,
                    ShowGridLines = false
                };

                grid.Columns[0].SetWidthInStars(6);

                grid.AddChild(SymbolWinRation3, 28, 1);
           
                Chart.AddControl(grid);
              }


         private void PositionsTrack(PositionClosedEventArgs args)
         {
        SymbolWinRatio[i] = Math.Round(WinnerTrades[i] / (WinnerTrades[i] + LosserTrades[i]) * 100, 0);
         }

 

 

 

what i need to do that some values in grid will be automatically changed  - i update values automatically in PositionClosedEventArgs.


@WienAT

WienAT
17 Mar 2021, 17:08

if i put "Chart.RemoveControl(text)" before definition of textblock, then visual studio shows me some errors ... something like text is not known...

Can you pls adice how i can find already created TextBlock and how i should delete it


@WienAT

WienAT
17 Mar 2021, 14:19 ( Updated at: 21 Dec 2023, 09:22 )

RE:

ok i will try that.

I am using textblock  like following:

private void PositionsTrack(PositionClosedEventArgs args)
{

  var position = args.Position;
  AccomulatedGrossProfit += position.GrossProfit;

 if (AccomulatedGrossProfit > 0)
            {
                var text = new TextBlock
                {
                    BackgroundColor = Color.Green,
                    ForegroundColor = Color.White,
                    Text = "....",
                    Padding = "8 4",
                    VerticalAlignment = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Margin = 5
                };
                Chart.RemoveControl(text);
                Chart.AddControl(text);
            }
            else
            {
                var text = new TextBlock
                {
                    BackgroundColor = Color.Red,
                    ForegroundColor = Color.White,
                    Text = "...",
                    Padding = "8 4",
                    VerticalAlignment = VerticalAlignment.Bottom,
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Margin = 5
                };
                Chart.RemoveControl(text);
                Chart.AddControl(text);
            }

}

I am not sure why previous texblock is not removed? You can see red textblock in background - I am doing something wrong? After some time doing like that my cTrader suite is frozen :/ Probably too much TextBlock - how to keep it always as one?

 


@WienAT

WienAT
17 Mar 2021, 11:54 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi WienAT,

It is not possible. You can use a TextBox instead. 

Best Regards,

Panagiotis 

Join us on Telegram

tnx. works fine.

Do you have any idea how can i fix space between text .. if you see picture below I marked it with blue color - in that part you see that | is not on the same level in new line ... on the eyes it doesnt looks good :) 

Is there any option how can i fix this?


@WienAT

WienAT
17 Mar 2021, 04:26 ( Updated at: 21 Dec 2023, 09:22 )

RE:

PanagiotisCharalampous said:

Hi WienAT,

It could be a cBot exception as well. Can you send us some troubleshooting information? Next time this happens, restart cTrader, press Ctrl+Alt+Shift+T, paste the link to this discussion in the text box that will appear and press submit.

Best Regards,

Panagiotis 

Join us on Telegram

Ok. As soon as this happens i will do as you sugggested.

by the way, if i press Ctrl+Alt+Shift+T i get following window - is this what you are searching for? 

Regards


@WienAT

WienAT
17 Mar 2021, 04:24

RE:

PanagiotisCharalampous said:

Hi WienAT,

II believe it would be possible to built a "monitoring" cBot that would gather all this information and display it to you.

Best Regards,

Panagiotis 

Join us on Telegram

Tnx PanagiotisCharalampous!

I found solution :) 

Do you know how can I add some background color on text written with DrawStaticText?


@WienAT

WienAT
08 Apr 2020, 21:43 ( Updated at: 21 Dec 2023, 09:21 )

RE:

WienAT said:

Dear all,

I am having three accounts in my Broker account. 

I am using 2 demo and 1 live. I am testing one bot on Demo account. I would like to get information about FreeMargin.

Here is something very interesting:

In visual studio i see Account.FreeMargin == 6651.55€ and account balance 10.000€, but my current demo account shows 2.468€:

What could be wrong?

i already found out what is my problem. In Backtesting, it always reset balance to 10.000€.


@WienAT

WienAT
08 Apr 2020, 21:35

RE:

PanagiotisCharalampous said:

Hi WienAT,

Are you sure you are looking at the correct position? SL and entry price also seem different.

Best Regards,

Panagiotis 

Join us on Telegram

 

Sorry, I mixed up something. 


@WienAT

WienAT
08 Apr 2020, 20:50 ( Updated at: 21 Dec 2023, 09:21 )

RE:

WienAT said:

I also tried, but doesnt work:

I already found mistake in my code. Following code works:

 


@WienAT

WienAT
08 Apr 2020, 20:44

I also tried, but doesnt work:


@WienAT