Topics
28 Feb 2017, 19:31
 1627
 2
25 Apr 2016, 04:51
 13
 941
 1
16 Feb 2016, 02:21
 5650
 6
Replies

cyfer
29 Feb 2016, 12:52

Hello Mikro 

Adding a Trade to a historical Trade List is not hard 

 

       


        private List<HistoricalTrade> LongTrades = new List<HistoricalTrade>();
        private History hist;

         protected override void Initialize()
        {
            // Initialize and create nested indicators


            hist = History;
            for (int i = 0; i < hist.Count; i++)
            {
                LongTrades.Add(hist[i]);
                Print(hist[i].PositionId);
            }


        }

But , in your case it is 

AFAIK the Built-in Historical trade is for the Past only 

so if you are trying to make the List with new Trades that didn't even Finish .. i.e after you execute the trade , it should be added to the List 

then I think you should make you're own Type or Try to use Positions .

for instance ,  A historical trade includes the data about the Finished Date & closing Price .. which is obviously not suitable in your case 

in your example , you should make your own type which includes State of the Trade (Still Open/Closed) and only if it is closed you can add it to the Historical Trade List.

I think you should be really looking into Positions , it is already a Collection 


@cyfer

cyfer
24 Feb 2016, 15:14

Basically  Generic Lists

Reference 

Using System.Collections.Generics ;

Initiation 

Private List<HistroicalTrade> LongTrades = new List<HistoricaTrade>() ;

Addition

LongTrades.ADD(a long Trade) ;

Looping

for(int i = 0 ; i< LongTrades.count ; i++)
{



}

its something like that mainly , you can put any type or Custom Type in a generic list 


@cyfer

cyfer
17 Feb 2016, 01:51

I think this is the best possible hack 

Thanks again mate 

 


@cyfer

cyfer
16 Feb 2016, 04:12

Very clever from you , thank you 

it does catch some values outside the range (30-70 or whatever the range) , but it's much more convenient than what i did  .

thanks mate 

 


@cyfer

cyfer
16 Feb 2016, 02:10

LTSigOpen or LTSigClose is a Series of data (in this case Moving Average).. not a single value 

you should be comparing the X Value in the moving average with the Y Value in price  or Y Value in another moving average

so you should be going like that : 

LTSigOpen.Close.Last(0) < LTSigClose.Close.Last(0) //pseudo code 

this way you're comparing 2 values and it will work 

 

 


@cyfer

cyfer
30 Jan 2016, 02:32

Best solution is to choose candle fill colors with some transparency 

and the dots with solid colors 

AFAIK there is no Z-Depth in cAlgo which is the real solution to this 

 


@cyfer

cyfer
30 Jan 2016, 02:22

I'm responding blindly now because you didn't post any code 

Chartobjects.DrawText("theDot"+index.toString() , the Text , the position , the color)

 


@cyfer

cyfer
30 Jan 2016, 02:16

if (dms.ADX.IsRising())
            {
                ChartObjects.DrawText("IsRising", xySpace(0, 5) + "Is the ADX Rising? " + dms.ADX.IsRising(), StaticPosition.TopLeft, Colors.Black);
                Print("it is Rising !");
            }
            else
            {
                ChartObjects.RemoveObject("IsRising");
            }

            if (dms.ADX.IsFalling())
            {
                ChartObjects.DrawText("IsFalling", xySpace(0, 6) + "Is the ADX Falling? " + dms.ADX.IsFalling(), StaticPosition.TopLeft, Colors.Black);
                Print("it is Falling !");
            }
            else
            {
                ChartObjects.RemoveObject("IsFalling");
            }

I can't look into this in depth because the market is closed , but i did have problems before from this "Drawn text " multiple times with the same name 

or not removing the drawn object  on the chart 

if this is not the solution , I suggest you keep the Print() command .. it's actually proving IsFalling & IsRising are working 

 


@cyfer

cyfer
04 Oct 2015, 04:43

well , eh .. I got some progress  .. always a delay around 3 sec !!

maybe its how long the text takes to display ? 

protected override void Initialize()
        {

            Timer.Start(1);


        }

        protected override void OnTimer()
        {
            ChartObjects.DrawText("time", Time.ToString("HH:mm:ss"), StaticPosition.TopLeft);
            if (DateTime.Now.Minute == 37 && DateTime.Now.Second == 0)
            {
                Notifications.PlaySound("C:\\windows\\media\\tada.wav");
                ChartObjects.DrawText("MESSAGETEXT_1", "Alarm triggered at: " + DateTime.Now.ToLongTimeString(), StaticPosition.Center, Colors.Yellow);
            }
        }

This lag between the exact time specified and when it shows is the problem ? 

BTW , I couldn't get the sound to play .. it must be something on my PC 

 


@cyfer

cyfer
02 Oct 2015, 23:43

it's very hard to know the problem or the fix without code , you could try to split part of the code showing the issue and post it here 

however , because this is C# and you say it works some times and some times it lags .. it could be GC related 

but again it's hard to tell without sample code 

 


@cyfer

cyfer
29 Sep 2015, 13:06

Thank you again Paul 

I have no problem with the design , I wrote many Runtime designs before 

BTW , seems if you don't do the threading part .. you'll always get that exception

but that's exactly the point i needed to reach Paul

I really appreciate your help

 


@cyfer

cyfer
29 Sep 2015, 10:02

@Paul_Hayes

Thank you so much

I wish you winning trades :) 

 

 


@cyfer

cyfer
29 Sep 2015, 07:12

That's what i did before posting the question but I always get this exception 

 

29/09/2015 06:09:19.482 | Crashed in Initialize with SecurityException: Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

 


@cyfer