Replies

imrealfighter
13 Apr 2021, 11:21

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

Check While Loops.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hello PanagiotisCharalampous Nice to meet you again and thank for your kind as always.

Thank you. I'll try it.


@imrealfighter

imrealfighter
12 Apr 2021, 20:05

Bring it in a nutshell 

I want my for loop to run when a new tick occurs until it reaches a condition that has been set in the for loop.


@imrealfighter

imrealfighter
09 Apr 2021, 16:07

RE:

amusleh said:

Hi,

This sample might help you:

using cAlgo.API;

namespace cAlgo
{
    /// <summary>
    /// This sample shows how to use Thickness for defining a chart control margin
    /// </summary>
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class ThicknessSample : Indicator
    {
        protected override void Initialize()
        {
            var stackPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                BackgroundColor = Color.Gold,
                Opacity = 0.6
            };

            var rectangle = new Rectangle
            {
                StrokeColor = Color.Blue,
                FillColor = Color.Red,
                StrokeThickness = 2,
                Margin = new Thickness(10, 5, 10, 5),
                Width = 300,
                Height = 100,
            };

            stackPanel.AddChild(rectangle);

            Chart.AddControl(stackPanel);
        }

        public override void Calculate(int index)
        {
        }
    }
}

MArgin property type is Thickness.

Hi There ! amusleh
First of all Nice to meet you and thank you for your kind and help.

I know that margin property type is thickness but I don't know how to initialize it.
all I know is from an example that come up with ctrader program.

I try it and it works !.

Thank you Amusleh .

P.s. also I try this and it works too.

Margin = string.Format("{0} {1} 20 10", marginLeft, marginTop),

 


@imrealfighter

imrealfighter
07 Apr 2021, 07:31

RE:

imrealfighter said:

Hello There Everyone ! 

I found on API reference that The Creator has built ChartObjectRemovedEventArgs class for us. 
but unfortunately, it doesn't have an example. 

so Could someone explain or give us some example on how to use it. how to call a method that we created when the object is deleted. 

thank you.

(Problem Solved) !!


Hi There Again Everyone 

I just found out that we could use Chart.ObjectRemoved and add the Method that we want to execute when an object is deleted. !! 


Thank you.


@imrealfighter

imrealfighter
02 Apr 2021, 04:26

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

Unfortunately there is no option to change the active chart from the code at the moment.

Best Regards,

Panagiotis 

Join us on Telegram

Hi There PanagiotisCharalampous :)
Ok then, Thank you. anyway.


@imrealfighter

imrealfighter
09 Jan 2021, 03:02 ( Updated at: 09 Jan 2021, 03:10 )

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

cTrader Desktop 4.0 will introduce a feature that will allow you to keep your lines straight when drawing.

Best Regards,

Panagiotis 

Join us on Telegram

PanagiotisCharalampous  we can't wait to see it.  looking forward for. :) 

Thank you. 

 


@imrealfighter

imrealfighter
07 Jan 2021, 13:29

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

Is this a programming question or a usability question? I am confused. If this is a programming question, then you can set whatever value you like in the DrawTrendLine.

Best Regards,

Panagiotis 

Join us on Telegram

First of all, Thank you again PanagiotisCharalampous you've helped me going through a challenge many and every time. 

I create a trendline by your suggestion method using Chart.DrawTrendLine();  

but I also set it to 

trendLine.IsInteractive = true;

the purpose of this trendline is using like a horizontal line but have a finite length. (the horizontal line doesn't have any angle and it's always 0 and the value of Y-axis at the right and left edge always equal) 

so when I extend or shrink the line the angle of it changes from 0 to 1-5 or something that's it.


Thank you.

 


 


@imrealfighter

imrealfighter
07 Jan 2021, 05:45

RE: RE:

imrealfighter said:

strongResistance said:

the actual bar gives you your x-axis (bar.OpenTime [datetime]). The price gives you your y-axis (the bar, Open, high, Low or close)

this.Chart.DrawRectangle("RectBU", pos.EntryTime, pos.EntryPrice, curBar.OpenTime, curBar.Open, this.Bullish_Box_Color);

the line above draws a rectangle from an entry-time & price to a bar open time & price

I hope this helps.

KF

Edited. (Problem Solved) !! 
Thank KF i've treid to look at Chart interface and I find FirstVisibleBarIndex property it return first bar that appears on the chart  and then as your suggestion I use bar.OpenTimes Boom ! we get datetime1 that start at the beginning of the chart. 



Hi There strongResistance(KF) first of all thank you for your kind and help.

just to clarify more my point on finding datetime1, datetime2 is when I draw Trendline I want it to be drawn on the current chart (can see it immediately by our eyes on the chart).

so maybe we need a datetime1 and datetime2 that correspond to the chart. Have you ever tried to use  Chart.TopY; and Chart.BottomY; it gives us the highest and the lowest price on the scale chart at that time. 

 

Edited. (Problem Solved) !! 
Thank KF i've treid to look at Chart interface and I find FirstVisibleBarIndex property it return first bar that appears on the chart  and then as your suggestion I use bar.OpenTimes Boom ! we get datetime1 that start at the beginning of the chart. 
 

 

 


@imrealfighter

imrealfighter
07 Jan 2021, 03:05 ( Updated at: 07 Jan 2021, 03:09 )

RE: RE:

^^^^ duplicated above comment ^^^^

 


@imrealfighter

imrealfighter
07 Jan 2021, 03:04

RE: RE:

gmkenneyy said:

imrealfighter said:

HI there hope you guys doing well in this 2021 want some help here. 

Edit : Problem Solved !!! but welcome to another suggestion and method. Thx.

( From Philippe Leybaert I just edit some ) 
----------------------


public double RoundDown(this double value, int digits)
{
     double factor = Math.Pow(10,digits);

     return Math.Truncate(value * factor) / factor;
}

​---------------------


I want to compare double type with double type (which is a product price with product price or product price with some price level) and I found that we could use double.CompareTo() method.

but have some problem with that 

assume 

double a = 1.2345

double b = 1.23456789  if we compare these two on 4 digit precision it will get the equal result right.

so to use double.CompareTo() we need to get b price with an exact digit as a 

I try to use Math.Round() but it doesn't give what I want Round() medthod it add the value of b up 1.2346 instead of 1.2345 

is there a way then? 

Thank you. 

Rounding double b = 1.23456789 to 4 decimal places will give you 1.2346 - so its correct!

Thank you.again gmkenneyy at first I thought that price on the chart is precisely calculated without round numbers but as result comeout yeap it uses Math.Round(); 

 


@imrealfighter

imrealfighter
07 Jan 2021, 03:01 ( Updated at: 07 Jan 2021, 03:09 )

RE:

strongResistance said:

the actual bar gives you your x-axis (bar.OpenTime [datetime]). The price gives you your y-axis (the bar, Open, high, Low or close)

this.Chart.DrawRectangle("RectBU", pos.EntryTime, pos.EntryPrice, curBar.OpenTime, curBar.Open, this.Bullish_Box_Color);

the line above draws a rectangle from an entry-time & price to a bar open time & price

I hope this helps.

KF

Hi There strongResistance(KF) first of all thank you for your kind and help.

just to clarify more my point on finding datetime1, datetime2 is when I draw Trendline I want it to be drawn on the current chart (can see it immediately by our eyes on the chart).

so maybe we need a datetime1 and datetime2 that correspond to the chart. Have you ever tried to use  Chart.TopY; and Chart.BottomY; it gives us the highest and the lowest price on the scale chart at that time. 

 

 


@imrealfighter

imrealfighter
04 Jan 2021, 16:29 ( Updated at: 04 Jan 2021, 16:32 )

 

Same Content as Above


@imrealfighter

imrealfighter
04 Jan 2021, 15:59 ( Updated at: 04 Jan 2021, 16:31 )

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

There is no built-in method for this, you will need to write your own.

Best Regards,

Panagiotis 

Join us on Telegram

Hello There again PanagiotisCharalampous need a little bit of helping here if you don't mind. (Solved) !

.........Edit now I've problem solved 
I declare Variable outside the method and then on Onstart() I set it's value and Call to to take action when it load more historical tick data.  

as begins ctrader provide us around thousand ticks but I try to test more than that so I find method and class on API that support to load more tick I found this class  TicksHistoryLoadedEventArgs and it provides new Count and a new set of Ticks data how can I get this Count and set of Ticks data to use? 

this is my method for now 
TIcks ticksOfMarket = MarketData.GetTicks();

and I call ticksOfMarket.LoadMoreHistory();
so when we call LoadMoreHistory() method 

TicksHistoryLoadedEventArgs will occur right and 

on Ticks we have Ticks.HistoryLoaded to take action 
I write Ticks.HistoryLoaded on OnStart() and when come to build CBot it says 

An object reference is required for the non-static field, method, or property 'cAlgo.API.TIcks.HistoryLoaded' that's it 



I try my best but there is no example with this so hope you could give me some suggestion on this. 

.........Edit now I've problem solved 
I declare Variable outside the method and then on Onstart() I set it's value and Call to to take action when it load more historical tick data.  

 

Thank you.


@imrealfighter

imrealfighter
04 Jan 2021, 14:36

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

There is no built-in method for this, you will need to write your own.

Best Regards,

Panagiotis 

Join us on Telegram

Thank you PanagiotisCharalampous I will try to. 


@imrealfighter

imrealfighter
04 Jan 2021, 06:52

Hello There again.

Just tried more and figure it out that Datetime is a built-in function from C# so now I could Create Trendline. 

Thx

 


@imrealfighter

imrealfighter
03 Jan 2021, 07:09

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

Check Notifications.PlaySound() method.

Best Regards,

Panagiotis 

Join us on Telegram

Thank you again PanagiotisCharalampous I will definitely try it.


@imrealfighter

imrealfighter
30 Dec 2020, 15:51

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

How could we set the price alert ring till we close it by manual ?

and is it possible for us to change the sound of price alert ?

There are no such built in features. You might want to consider building something custom.

Best Regards,

Panagiotis 

Join us on Telegram

Thank you for your responses, any suggestion would be great.

I've tried to see some code on cbots there is nothing about price alert. (except ChartDisplaySettings)

so how could I fix this problem. 

Thank you.

 


@imrealfighter

imrealfighter
28 Nov 2020, 03:23

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

It would be easier for us to understand what you need if you shared some code with us. For example, why do you replicate the code on both event handlers if you need it to be executed once?

Best Regards,

Panagiotis 

Join us on Telegram

PanagiotisCharalampous  like you've said I replicate the code so just delete PositionOpenedEventArgs  so it works ! 

Thank you. 


@imrealfighter

imrealfighter
25 Nov 2020, 03:09

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

The most appropriate way to use the method in another class is to pass the Robot object as an argument. Inheriting it will not work because the new class will not have a char object initialized if it is not added on a chart.

Best Regards,

Panagiotis 

Join us on Telegram

Hello There PanagiotisCharalampous I've tried to put robot object as a parameter to the class that I want to use and it works. 

Thank you.


@imrealfighter

imrealfighter
24 Nov 2020, 14:58

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

To add a horizontal line to the chart, you need to use Chart.DrawHorizontalLine() method.

Best Regards,

Panagiotis 

Join us on Telegram

Hello There ! (Again) LOOL 

Hope you could help me on this 

Of course that when I create new class that inherited from robot class I could use Chart.DrawHorizontalLine() and no error on this 

my code can build successfully but when I use my method In my class to draw a HorizontalLine my cbot Crashed and it said that 

" Crashed in Onstart with NullReferenceException: Object reference not set to an instance of an object.

What should I do then ? 

Thank you.


@imrealfighter