Take what the market gives

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #180816 quote
    phoentzs
    Participant
    Master
    When I write this code in my bot, the code checks for every close whether the current position is 10 points plus and then closes the trade. Quasi an exit without a TP. If the position is 100 points plus, it closes as well as if the position is 11 points plus. The same with the second code, only then time-dependent. Is that correct or do I have a mistake in my thinking?

    If longonmarket and Close>Positionperf+10*pipsize then

    sell at market

    endif

     

    If longonmarket and Time=120000 and Close>Positionperf+10*pipsize then

    sell at market

    endif

    #180825 quote
    JS
    Participant
    Senior
    Calculation PositionPerf example: Open position at 100 Close position at 110 Then PositionPerf = (110 – 100) / 100 = 0,1
    #180826 quote
    JS
    Participant
    Senior
    Or: Open position at 100 Current price 108 (Current)PositionPerf = (108 -100) / 100 = 0,08
    #180830 quote
    robertogozzi
    Moderator
    Master
    To calculate the number of pips gained (or lost, if negative) so far, for a single position:
    PipsGain = PositionPerf * PositionPrice / PipSize
    for all positions (the output is the same as above if you only have one position open):
    PositionPerf * PositionPrice / PipSize * abs(CountOfPosition)
    So the correct code to check if profit is 10+ pips:
    If longonmarket and (PositionPerf * PositionPrice / PipSize) >= 10 then
       sell at market
    endif
    phoentzs thanked this post
    #180838 quote
    phoentzs
    Participant
    Master
    Thanks, this function could be quite useful with different TP distances. Or as an exit from the market in profit in the evening or Friday evening.
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Take what the market gives


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by phoentzs
4 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/02/2021
Status: Active
Attachments: No files
Logo Logo
Loading...