In reviewing the documentation, it looks like there is some functionality in the MC NET code to support aspects I like to use in my strategies. Is there example code I could look at either on the forum here or in the default indicators + studies?
- Getting account balance, margin, and account equity: I would like to use these for position sizing, and for "emergency trade closures / cease trading" if equity goes too low.
- Forex spreads, bid-ask functions: I like to use these to avoid the least liquid times of the market... and avoid extra costs / big slippage.
- Any examples of position sizing code to look at? It would be great to get an idea of how it can work in MC NET
- Reading off of multiple timeframes (ie: 1 hr and 1 day): This still might be in the tutorials that I haven't finished, but would like to look at example code
- Time zones/GMT/Server time/Exchange time: I imported data from Dukascopy in GMT time, it is my preferred timeframe for FOREX. But, how to read and convert from the "server time" to GMT, or reverse?
Thanks
General question - Account Management / Position sizing / Timeframes & time zones
-
- Posts: 45
- Joined: 07 Mar 2024
- Has thanked: 13 times
- Been thanked: 1 time
- Polly MultiCharts
- Posts: 210
- Joined: 20 Jul 2022
- Has thanked: 1 time
- Been thanked: 57 times
Re: General question - Account Management / Position sizing / Timeframes & time zones
Hello Talky_Zebra,
You can refer to the following sources:
1. Getting account balance, margin, and account equity.
Initial Capital
MaxLotsHeld
2. Forex spreads, bid-ask functions.
You can create two separate charts with Ask and Bid data and refer to these data series prices.
You might also use the Status line for that. Here is how to do that.
3. Any examples of position sizing code to look at.
You can use the CurrentPosition.OpenLots to get the size of the strategy's current open position.
4. Reading off of multiple timeframes (ie: 1 hr and 1 day)
Here is the code sample you can refer to:
More info is here.
5. Time zones/GMT/Server time/Exchange time.
Please refer to this sample:
You can refer to the following sources:
1. Getting account balance, margin, and account equity.
Initial Capital
MaxLotsHeld
2. Forex spreads, bid-ask functions.
You can create two separate charts with Ask and Bid data and refer to these data series prices.
You might also use the Status line for that. Here is how to do that.
3. Any examples of position sizing code to look at.
You can use the CurrentPosition.OpenLots to get the size of the strategy's current open position.
4. Reading off of multiple timeframes (ie: 1 hr and 1 day)
Here is the code sample you can refer to:
Code: Select all
BarsOfData(1).Close[0]
BarsOfData(2).Close[0]
5. Time zones/GMT/Server time/Exchange time.
Please refer to this sample:
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;
namespace PowerLanguage.Strategy
{
public class DateTimeConvert : SignalObject
{
public DateTimeConvert(object _ctx):base(_ctx){}
DateTime timeNow;
DateTime timeEsternNow;
TimeZoneInfo easternZone;
protected override void Create()
{
// create variable objects, function objects, order objects etc.
}
protected override void StartCalc()
{
timeNow = DateTime.Now;
#region TimeZone ID
/*
Arabic Standard Time
Arabic Standard Time\Dynamic DST
Argentina Standard Time
Argentina Standard Time\Dynamic DST
Atlantic Standard Time
Atlantic Standard Time\Dynamic DST
AUS Central Standard Time
AUS Eastern Standard Time
AUS Eastern Standard Time\Dynamic DST
Azerbaijan Standard Time
Azores Standard Time
Azores Standard Time\Dynamic DST
Bahia Standard Time
Bahia Standard Time\Dynamic DST
Bangladesh Standard Time
Bangladesh Standard Time\Dynamic DST
Canada Central Standard Time
Cape Verde Standard Time
Caucasus Standard Time
Caucasus Standard Time\Dynamic DST
Cen. Australia Standard Time
Cen. Australia Standard Time\Dynamic DST
Central America Standard Time
Central Asia Standard Time
Central Brazilian Standard Time
Central Brazilian Standard Time\Dynamic DST
Central Europe Standard Time
Central European Standard Time
Central Pacific Standard Time
Central Standard Time
Central Standard Time\Dynamic DST
Central Standard Time (Mexico)
China Standard Time
Dateline Standard Time
E. Africa Standard Time
E. Australia Standard Time
E. Europe Standard Time
E. South America Standard Time
E. South America Standard Time\Dynamic DST
Eastern Standard Time
Eastern Standard Time\Dynamic DST
Egypt Standard Time
Egypt Standard Time\Dynamic DST
Ekaterinburg Standard Time
Ekaterinburg Standard Time\Dynamic DST
Fiji Standard Time
Fiji Standard Time\Dynamic DST
*/
#endregion
easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
timeEsternNow = TimeZoneInfo.ConvertTime(timeNow, TimeZoneInfo.Local, easternZone);
Output.WriteLine
(" {0} {1} corresponds {2} {3}. ",
timeNow,
TimeZoneInfo.Local.IsDaylightSavingTime(timeNow) ? TimeZoneInfo.Local.DaylightName : TimeZoneInfo.Local.StandardName,
timeEsternNow,
easternZone.IsDaylightSavingTime(timeEsternNow) ? easternZone.DaylightName : easternZone.StandardName
);
}
protected override void CalcBar()
{
}
}
}
-
- Posts: 45
- Joined: 07 Mar 2024
- Has thanked: 13 times
- Been thanked: 1 time
Re: General question - Account Management / Position sizing / Timeframes & time zones
Thanks Polly, I will try these out and learn how to use them.