concept G22PassiveTradingStrategy extends G22TradingStrategy { // A regular expression that will be used to match // the "strategy" field coming from TradingView to // distinguish this strategy from others on the same coin. settableWithVar S tradingViewRegexp; // If not 0, ths "PS" comment (position size) coming from // TradingView is evaluated. // tradingViewPSFactor == 100 => scale $100 in TradingView to our current equity // tradingViewPSFactor == 50 => scale $100 in TradingView to 50% of our current equity settableWithVar double tradingViewPSFactor; void price(double price) { if (currentPrice == price) ret; currentPrice = price; afterStep(); change(); } bool tradingViewMatch(S text) { ret empty(cleanedTradingViewRegexp()) || safeRegexpFindIC(cleanedTradingViewRegexp(), text); } S cleanedTradingViewRegexp() { ret trim(tradingViewRegexp); } LS addPassiveTradingStatus(LS list) { if (nempty(tradingViewRegexp)) list.add("TradingView regexp: " + cleanedTradingViewRegexp()); ret list; } LS status() { ret addPassiveTradingStatus(super.status()); } LS activationStatus() { ret addPassiveTradingStatus(super.activationStatus()); } bool hasTradingViewPSFactor() { ret isNonZero(radingViewPSFactor); } }