No Consecutive orders in the same direction

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #32411 quote
    gm74
    Participant
    Average

    Hi Everyone

    I am having a problem with a problem. I just want some fresh eyes to perhaps give me a different perspective.

    Its simple:

    If my previous trade was long. Then the next trade cannot be long.

    How would I code this simple bit of logic?

    Thanks!

    George

    #32415 quote
    GraHal
    Participant
    Master

    Hi George

    I take it you don’t want to put your code on here? It be so much easier for a skilled coder to look at what your code is doing and propose a solution to your problem in seconds?

    Take a look here … sounds a similar issue?

    https://www.prorealcode.com/topic/never-two-or-more-time-trading-in-same-direction/

    Cheers
    GraHal

    #32442 quote
    gm74
    Participant
    Average

    Thank you, yes this does help. I was on the right track but never got it exactly. My solution is as follows. Purely in terms of the condition as mentioned. I use the variable “POS”. This seems to have done the trick.

     

    IF c1 and pos<1 THEN
    BUY positionsize CONTRACT AT MARKET
    ENDIF

    if longonmarket then
    pos=2
    endif

     

    And for short trades the following:

    IF c3 and pos>-1 THEN
    SELLSHORT positionsize CONTRACT AT MARKET
    ENDIF

    if shortonmarket then
    pos=-2
    endif

    GraHal thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

No Consecutive orders in the same direction


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
gm74 @gm74 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by gm74
8 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/18/2017
Status: Active
Attachments: No files
Logo Logo
Loading...