Hello Everyone!
Is there any history deals based indicator around? Almost all of them are market based, but almost none is account based.
I've seen a product that created an indicator based on profit, but what if I wanted to know my position moving average plotted with market candles?
What is a "position moving average" ?
What is "account based" in opposition to "market based" ?I don't get it.
What is a "position moving average" ?
On a Netting account, a simple PositionGetDouble(POSITION_PRICE_OPEN) will do, as netting account allows one position for a single symbol. The (untested, notepad) snippet below, should give a glimpse that should work on netting and hedging accounts:
sinput string InpSymbol = ""; string ExtSymbol = ""; int OnInit() { if(!SymbolSelect(InpSymbol)) ExtSymbol = _Symbol; if(!ObjectCreate(0,"PositionPriceOpen",OBJ_HLINE,0,0,PositionPriceOpen(ExtSymbol)); return(INIT_SUCCEDED); }; void OnDeInit() { ObjectDestroy("PositionPriceOpen"); }; void OnTick() { ObjectMove(0,"PositionPriceOpen",0,0,PositionPriceOpen(ExtSymbol)); }; double PositionPriceOpen(const string SYMBOL) { double PositionVolume = 0.0; double PositionValue = 0.0; for (int i=0;(i<PositionsTotal())&&PositionSelect(i); i++) { if(PositionGetString(POSITION_SYMBOL)==SYMBOL) { PositionValue =+ PositionGetDouble(POSITION_PRICE_OPEN) * PositionGetDouble(POSITION_VOLUME); PositionVolume =+ PositionGetDouble(POSITION_VOLUME); }; }; return((PositionVolume>0)?(PositionValue/PositionVolume):SymbolInfoDouble(ExtSymbol,SYMBOL_LAST)); };
I believe using HistoryDealGetDouble can populate buffer calculations and create a moving average of my own position, using two buffers,
one for calculations and another for the indicator.
On a Netting account, a simple PositionGetDouble(POSITION_PRICE_OPEN) will do, as netting account allows one position for a single symbol. The (untested, notepad) snippet below, should give a glimpse that should work on netting and hedging accounts:
I believe using HistoryDealGetDouble can populate buffer calculations and create a moving average of my own position, using two
buffers, one for calculations and another for the indicator.
I believe I will borrow Masters @Mladen Rakic and @Alain Verleyen code...
https://www.mql5.com/en/forum/275327/
If I am able to move forward, I will post code here.
- 2018.08.23
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello Everyone!
Is there any history deals based indicator around? Almost all of them are market based, but almost none is account based.
I've seen a product that created an indicator based on profit, but what if I wanted to know my position moving average plotted with market candles?
Many thanks,
Arthur.