My language policy pushes real-time position changes to mobile apps and WeChat

Author: , Created: 2021-08-10 17:06:46, Updated: 2023-09-20 11:10:28

img

A summary

With the continuous improvement of quantitative trading strategies, users are also increasingly demanding real-time push of holdings changes, such as: Web online logs, mobile apps, WeChat, etc., all need to transmit the changes that occur in the account holdings in real time, proactively to the browser, mobile phone, etc. Therefore, this article is aimed at inventors of quantitative.FMZ.COMMy language strategy, to push the position in real time to the mobile app and WeChat.

The full source code for this article is available here.https://www.fmz.com/strategy/305785In the meantime, I would like to ask you to start typing the code.

Second, demonstrate trading strategies

For the sake of simplicity, this article will refer to the previous William W%R trading strategy, whose link address is:https://www.fmz.com/strategy/283024The strategy logic consists of a William value and a mean line together, a complete strategy and retrieval configuration, which can be obtained by clicking on this link, below is the code for the policy:

HC := HHV(HIGH, 14) - CLOSE;
HL := HHV(HIGH, 14) - LLV(LOW, 14);
WR := -100 * HC / HL;
MA20 : EMA2(C, 14);
C1 := WR < -60 && C > MA20;
C2 := WR > -15 && C < MA20;
C1, BPK;
C2, SPK;

My language language enhancement

The inventor quantifiedFMZ.COMThe My language is a further encapsulation of the JavaScript language, designed to help quantify beginners for a better introduction. The My language has the characteristic of being syntactically concise, able to handle some simple tactical logic, but is elbow-tight in the face of some complex tactics.

%%
// 这里面可以调用发明者量化的任何API 
scope.TEST = function(obj) {
    return obj.val * 100;
}
%% 
收盘价:C;
收盘价放大100倍:TEST(C);
上一个收盘价放大100倍:TEST(REF(C, 1)); // 鼠标移动到回测的K线上就会提示变量值

As shown in the code above, the language enhancement features allow My language to be programmed in a mixture of JavaScript languages.https://www.fmz.com/doc/2569#语言增强

Some of them are:

1, scope objectThe scope object, which can add attributes and assign anonymous functions to the property. In the Mac language code section, you can call the anonymous function that refers to this property.

2、scope.get_locals(‘name’)The function can obtain My language variables to enable interaction between My language and JavaScript.

Four, change the push position

In the My language policy, the BKVOL function can get the number of buy signals, i.e. the current multi-headed holdings. The SKVOL function can get the number of sell signals, i.e. the current empty headed holdings. Then we can calculate the current position change state by using BKVOL minus SKVOL.

HC := HHV(HIGH, 14) - CLOSE;
HL := HHV(HIGH, 14) - LLV(LOW, 14);
WR := -100 * HC / HL;
MA20 : EMA2(C, 14);
C1 := WR < -60 && C > MA20;
C2 := WR > -15 && C < MA20;
C1, BPK;
C2, SPK;

%%
// 下面代码附加到任何My语言策略最后都可以实现仓位变化推送到手机App与微信
if (typeof(scope._tmp) !== 'number') {
    scope._tmp = 0;
}
var pos = scope.get_locals('BKVOL') - scope.get_locals('SKVOL');
if (pos != scope._tmp) {
   scope._tmp = pos;
   Log('通知仓位变化:', scope.symbol, pos, '@');
}
%%

In the code above, we have combined the William W%R trading strategy and push position change functionality to enable real-time synchronization of trading orders with position changes and push to the mobile app and WeChat.

Five, test on the real disk

Next we run a real-time verification of this function, creating a real-time select OKEX spot, the currency pair set to LTC_USDT (commodity futures and digital currency futures can also use this function, operating in a similar manner)

1, the signal is triggered, the web log img 2 Signal is triggered, mobile app message is pushed img 3rd, the signal is triggered, the message is pushed img

6 and Summary

The above is a simple My Language William W%R trading strategy, which is implemented with the message push module developed by the language enhancement module in My Language, which enables real-time push of position changes to mobile apps and WeChat. The module code can be attached to any My Language strategy, which enables push of position changes to mobile apps and WeChat, and launch multiple push types for different scenarios to meet your personalized push needs.


Related

More