Replies

diiptrade
26 Jan 2021, 11:20

Calculation using Dynamic Leverage
double MarginFor(Position Pos)
{
    double vol = Pos.VolumeInUnits;
    double margin = 0;

    foreach (var DynamicLeverage in Symbol.DynamicLeverage)
    {
        if (vol >= DynamicLeverage.Volume)
        {
            double used = Math.Floor(vol / DynamicLeverage.Volume);
            margin += used / DynamicLeverage.Leverage;
            vol -= used;
        }
        else if (vol > 0)
        {
            margin += vol / DynamicLeverage.Leverage;
            vol = 0;
        }
    }

    return margin * Pos.EntryPrice;
}

 


@diiptrade

diiptrade
15 Oct 2019, 15:28

RE:

Panagiotis Charalampous said:

Hi D D,

It seems that your product needs a single threaded appartment to run. Therefore you should run it on a separate thread specifying the STA apartment state on the thread. See here.

Best Regards,

Panagiotis

Tried this solution, but nothing)


@diiptrade

diiptrade
05 Dec 2018, 16:50

It doesn't work. MACD require DataSeries istead of MarketSeries as you in your example.


@diiptrade

diiptrade
03 Oct 2018, 20:58

But, in real time it prefetch about 2k bars, in backtesting - about 120 bars... How to prefetch more?


@diiptrade

diiptrade
03 Oct 2018, 15:56

Thanks!

Works!


@diiptrade

diiptrade
11 Mar 2018, 19:21

Good work!

It will be great if you can fix backtesting to show more than 2k deals and to show more logs) Also sometimes when there are a lot of deals in backtesting, it's not showing after backtesting stop. 


@diiptrade

diiptrade
27 Jul 2017, 08:17

MarketData.GetSeries doesnt work properly!!!

For example, If indicator is on Hour1 Timeframe and I want to get DataSeries from Minute1 Timeframe, it only get truncated Minute1 DataSeries.

DataSeries.Close.Count = 6000

M1DataSeries.Close.Count = 9000, but it should be at least 6 000 x 60 = 360 000!

And when you scroll to the beginning DataSeries.Close is updated, but M1DataSeries.Close is the same = 9000.

Please, fix it!


@diiptrade