Tâche terminée
Spécifications
Context: Watch the following video for an example usecase - https://www.youtube.com/watch?v=3FV8PTikKc0
What I have at the moment is an Expert Advisor that calculates the Total Value at Risk for Currently Open Symbols.
Outcome, a bool (true / false) variable that checks the symbol , lot size and assesses whether adding that trade would reduce the value at risk.
e.g. if Proposed Value at Risk < Current Value at risk then the variable is true.
Here is my attempt at this:
bool LowerVAR(string Symbol1, double Lotsize1) { //string CurrPortAssets[] = {symb1, symb2, symb3, symb4, symb5, symb6, symb7, symb8, symb9, symb10}; //double CurrPortLotSizes[] = { SumLots(symb1), SumLots(symb2), SumLots(symb3), SumLots(symb4), SumLots(symb5), SumLots(symb6), SumLots(symb7), SumLots(symb8), SumLots(symb9), SumLots(symb10)}; string CurrPortAssets[]; double CurrPortLotSizes[]; CPortfolioRiskMan PortfolioRisk(InpVaRTimeframe, InpStdDevPeriods, InpCorrelPeriods); PortfolioRisk.CalculateIncrementalVaR(CurrPortAssets, CurrPortLotSizes); // CREATE PROPOSED POSITION ARRAY AND ADD PROPOSED POSITION string ProposedPortAssets[]; double ProposedPorLotSizes[]; ArrayResize(ProposedPortAssets, ArraySize(CurrPortAssets) + 1); ArrayResize(ProposedPorLotSizes, ArraySize(CurrPortLotSizes) + 1); ArrayCopy(ProposedPortAssets, CurrPortAssets); ArrayCopy(ProposedPorLotSizes, CurrPortLotSizes); ProposedPortAssets[ArraySize(ProposedPortAssets) - 1] = Symbol1; ProposedPorLotSizes[ArraySize(ProposedPorLotSizes) - 1] = Lotsize1; // POSITION DIAGNOSTICS string posDiagnostics = ""; for (int i = 0; i < ArraySize(ProposedPortAssets); i++) { string posType = (i == ArraySize(ProposedPortAssets) - 1) ? "PROPOSED" : "EXISTING"; posDiagnostics += "Pos " + IntegerToString(i) + " " + ProposedPortAssets[i] + " " + DoubleToString(ProposedPorLotSizes[i], 2) + " (" + posType + ")\n"; } // CALCULATE THE PROPOSED VaR IF NEW POSITION WERE ALLOWED TO OPEN PortfolioRisk.CalculateIncrementalVaR(ProposedPortAssets, ProposedPorLotSizes); double proposedValueAtRisk = PortfolioRisk.IncrementalVaR; return TotalValueAtRisk > proposedValueAtRisk; }
What I need next is some assistance in editing / making a change to this so that I can achieve the above goal above.
Please check all the content and I will send you the code (which I have already created), I just need to make sure you understand he task.
Looking forward to working with you :)