Hello I try to log the Cashvalue from the TWS in an ADC to track the real value
of the trading system. It should only add new values to the ADC.
So far I succeded in writing the cashvalue to the ADC but on every explore run
it sums up more to the adc. As you can see in the following code snippet I try
nearyl all to prevent a double add to the ADC array, but now I run out of ideas.
What I did so far:
1) Tried to check if time has changed
2) I have a system with 4 Forex running at the same time. Each time it added
the summ. That's why the sTicker == "EUR.USD-IDEALPRO-CASH is there
3) Checked if the ADC field has already a value and if not write to the ADC. I
guess the ADC field is up to date when it is read?
Trying to solve this for many hours, but did not succed. This should not be
difficult to solve ( if someone knows the solution).
Thanks for any help on this.
Oliver
//**************** Write TWS Cash to ADC ********************//
CashBalanceStr = ibc.GetAccountValue("TotalCashBalance");
CashBalanceStr2 = ibc.GetAccountValue("NetLiquidationByCurrency");
if (CashBalanceStr == "")
CashBalance = 0;
else
CashBalance = StrToNum(CashBalanceStr);
// ad 1) time check
Olddatetime=StaticVarGetText("Olddatetime");
myminute= NumToStr(DateTimeConvert(4,DateTime()) );
// ad 3)
anzahl=Foreign("~TWSCashBalance","V",0);
if (IsNull(anzahl[BarCount-1]) )
testempty=1;
else
testempty=0;
if ( myminute != Olddatetime AND sTicker == "EUR.USD-IDEALPRO-CASH" AND
testempty ) {
StaticVarSetText("Olddatetime", myminute );
AddToComposite(CashBalance,"~TWSCashBalance","X", 4+atcFlagEnableInExplore);
AddToComposite(1,"~TWSCashBalance","V",4+atcFlagEnableInExplore);
}
What is written to the ADC:
..................~
~TWSCashBalance 30.01.2009 18:00:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 17:45:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 17:30:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 17:15:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 17:00:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 16:45:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 16:30:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 16:15:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 16:00:00 207542 207542 207542 207542 5 0
~TWSCashBalance 30.01.2009 15:45:00 165964 165964 165964 165964 4 0
~TWSCashBalance 30.01.2009 15:30:00 124344 124344 124344 124344 3 0
~TWSCashBalance 30.01.2009 15:15:00 82874.3 82874.3 82874.3 82874.3 2 0
~TWSCashBalance 30.01.2009 07:15:00 41754.1 41754.1 41754.1 41754.1 1 0
~TWSCashBalance 30.01.2009 06:15:00 41810.7 41810.7 41810.7 41810.7 1 0
~TWSCashBalance 30.01.2009 18:45:00 207542 207542 207542 207542 5 0
~TWSCashBalance 29.01.2009 18:15:00 43464.5 43464.5 43464.5 43464.5 1 0
~TWSCashBalance (new)