There where no errors in the programming and no errors in the logs. BUT... when I use Strategy Analyzer or run it on the Sim101 account in real-time Errors occure. There are NO trades occuring due to this code. Currently this code outputs a false false when the values say it should be a true output.
when 85% OverallCash value is Greater than the RiskMargin and InitialMarginHeldInAccount combined the output should read as true.
I Created a Risk profile for my Forex.com trading called "GTB ForexDotCom"
I used CashValue - InitialMargin > (Long/Short)MinimumCheckLotsToTradeLogicGTB * Risk.Get("GTB ForexDotCom")
exsample Account has $1000, where there is $400 currently in use. the Next Trade will cost $60 [<Risk.Get("GTB ForexDotCom") = $20>*<Multiplier = 3>]
these all pull correctly
Account.Get(AccountItem.CashValue, Currency.UsDollar);
Account.Get(AccountItem.InitialMargin, Currency.UsDollar);
Risk.Get("GTB ForexDotCom").ByMasterInstrument[Instrument.MasterInstrument].InitialMargin;
namespace NinjaTrader.NinjaScript.Strategies { public class GTBsAutomatedTradingStrategyAccount : Strategy { private Account account; //Account check Long and Short private Series<double> OverallCashValueOfAccountCurrentlyTrading; private Series<double> InitialMarginHeldInAccountAsTrades; private Series<double> RiskMarginRequirementsOnTradedInstrument; private Series<bool> LongMoneyInAccountToTrade; private Series<bool> ShortMoneyInAccountToTrade; } else if (State == State.DataLoaded) { //My Account OverallCashValueOfAccountCurrentlyTrading = new Series<double>(this, MaximumBarsLookBack.Infinite); InitialMarginHeldInAccountAsTrades = new Series<double>(this, MaximumBarsLookBack.Infinite); RiskMarginRequirementsOnTradedInstrument = new Series<double>(this, MaximumBarsLookBack.Infinite); LongMoneyInAccountToTrade = new Series<bool>(this, MaximumBarsLookBack.Infinite); ShortMoneyInAccountToTrade = new Series<bool>(this, MaximumBarsLookBack.Infinite); } protected override void OnAccountItemUpdate(Account account, AccountItem accountItem, double value) { /// Real-Time Trade Logic //My Account // Check Money in Account to Trade OverallCashValueOfAccountCurrentlyTrading[0] = Account.Get(AccountItem.CashValue, Currency.UsDollar); InitialMarginHeldInAccountAsTrades[0] = Account.Get(AccountItem.InitialMargin, Currency.UsDollar); RiskMarginRequirementsOnTradedInstrument[0] = Risk.Get("GTB ForexDotCom").ByMasterInstrument[Instrument.MasterInstrument].InitialMargin; if (Account.Name != "Sim101") { if ((LongMoneyInAccountToTrade[0] == false) && (((OverallCashValueOfAccountCurrentlyTrading[0] * 0.85) - InitialMarginHeldInAccountAsTrades[0]) > ((12 / LongMinimumCheckLotsToTradeLogicGTB) * (RiskMarginRequirementsOnTradedInstrument[0])))) LongMoneyInAccountToTrade[0] = true; else if ((LongMoneyInAccountToTrade[0] == true) && (((OverallCashValueOfAccountCurrentlyTrading[0] * 0.85) - InitialMarginHeldInAccountAsTrades[0]) <= ((12 / LongMinimumCheckLotsToTradeLogicGTB) * (RiskMarginRequirementsOnTradedInstrument[0])))) LongMoneyInAccountToTrade[0] = false; if ((ShortMoneyInAccountToTrade[0] == false) && (((OverallCashValueOfAccountCurrentlyTrading[0] * 0.85) - InitialMarginHeldInAccountAsTrades[0]) > ((12 / ShortMinimumCheckLotsToTradeLogicGTB) * (RiskMarginRequirementsOnTradedInstrument[0])))) ShortMoneyInAccountToTrade[0] = true; else if ((ShortMoneyInAccountToTrade[0] == true) && (((OverallCashValueOfAccountCurrentlyTrading[0] * 0.85) - InitialMarginHeldInAccountAsTrades[0]) <= ((12 / ShortMinimumCheckLotsToTradeLogicGTB) * (RiskMarginRequirementsOnTradedInstrument[0])))) ShortMoneyInAccountToTrade[0] = false; } else if (Account.Name == "Sim101") { LongMoneyInAccountToTrade[0] = true; ShortMoneyInAccountToTrade[0] = true; } } }
Comment