For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Beginner questions



  • Hello everyone,

    I am new to trading and I am trying to create a simple strategy that uses a simple machine learning algorithm to trade forex currency pairs. Simply put, the model predicts whether the closing price in the next interval will be higher or lower and use self.buy or self.sell accordingly. This, however, leads to ridiculous ROIs such as -1000% or +600% on some currency pairs.

    I don't think I understand self.buy, self.sell and sell.close correctly. From the documentation, when self.buying, you will attain a long position. When self.selling, you attain a short position. My code is therefore as follows:

    if prediction == 1:
        self.log('BUY CREATE, %.5f' % self.dataclose[0])
        self.order = self.buy()
    elif prediction == 0:
        self.log('SELL CREATE, %.5f' % self.dataclose[0])
        self.order = self.sell()
    

    Is this the wrong way of looking at it? When a currency has been bought, does self.sell sell the currency first and if there is none left, it will buy a short position? Should I check for self.position when ordering a self.buy or self.sell command? Should I close the position before executing self.sell?

    My knowledge or forex trading is also very basic so I might have some wrong assumptions somewhere.

    Thanks!



  • Just a friendly advice, read couple articles on the trading itself. After go thru the Docs - Quickstart. This two actions will remove bunch of the questions like you ask now. Then write a script of the simple strategy like enter position on monday, get out of the position on friday (or thursday). Or based on the any indicator.

    @ForexBeginner said in Beginner questions:

    Is this the wrong way of looking at it?

    Depends on what you are trying to achieve.

    When a currency has been bought, does self.sell sell the currency first and if there is none left, it will buy a short position?

    Broker first sells what you have in your account, and than goes short i.e. give you the loan.

    Should I check for self.position when ordering a self.buy or self.sell command?

    Depends on what you are trying to achieve.

    Should I close the position before executing self.sell?

    Depends on what you are trying to achieve.


Log in to reply
 

});