Trading with RSIA sample script presented below makes its trades according to the signals of the RSI indicator. The script opens a long position if the value of RSI falls below a
lower threshold and opens a short one if the RSI value soars above an
upper threshold. The threshold values are specified as launching parameters of the script (see in the code the
lowerThreshold and
upperThreshold variables respectively). The period of the RSI as well as the period of candle bars are specified as lauhcing parameters too (the
periodOfRSI and
timeFrame varialbes respectively).
When opening a long position the script closes a previously opened short one (if exists) and vice versa. To implement this logic the script stores ids of opened positions in the global variables:
longPositionId and
shortPositionId. The use of these variables also prevents positions from duplicating: a LONG position isn’t opened if longPositionId is not nil and the same is true for a SHORT one.
The RSI indicator signals overbought (when it soars above 70–80) and oversold (when it falls below 20–30) market.https://c.radikal.ru/c01/1804/86/cfe26a9335cf.jpgWhen launching the script you may specify the following set of parameters (see the
PARAMETERS text field at the right half of the page):
https://c.radikal.ru/c20/1804/26/6704d7d573e1.jpgAfter you click the
Add button you will be able to set the time window for the simulated trading (plase note that it should not exceed 90 days):
https://d.radikal.ru/d35/1804/72/ae85f8ab4f24.pngNow you may click the Start button, wait until the simulated trading is done and have a look at the results. Depending on a chosen time window the simulated trading may end up either with a positive or with a negative profit.
#tradingene #tradingeneration