How can I make the code so that I won't buy when I don't have enough available money to buy?
I've found "GetRTDayTradingBuyingPower" but this one does not seem to be working. The powerlanguage editor doesn't even recognizes it and I get "is not recognized" error when I complile.
I also found Getnumpositions (getaccountID), and powerlanguage editor compiled it but it won't work either. I have a maximum buying power of 50k and each position is worth 10k ,so I though if my number of positions is less than 5, than it should buy and if it becomes more than 5 than it shouldn't buy or short since I have no available cap.
I backtested after I added the condition below, backtester kept exceeding the limit.
Does this work only in the real time autotrading situation, and not on the backtest?
Code: Select all
Value1 = GetNumPositions (GetAccountID);
if value1 < 5 then
buy this bar on close;