Trade opens opposite direction

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #192431 quote
    15482847
    Member
    New

    Hi,

    I use a very simple rule to enter trades. If previous candle closes green -> then long. If previous candle closes red -> then short.

    As an example, for long I use (close[0] > open[0])

    Sometimes a candle will close green then enter a short and visa versa.

    Is there a better code I can use to implement this instruction correctly?

    Thank you in advance!

    Kind regards,

    Anton

     

     

    IF NOT ONMARKET THEN
    LONGRULE = (close[0] > open[0])
    SHORTRULE = (open[0] > close[0])
    IF LONGRULE and TradeAllowed=1 THEN
    BUY PositionSize CONTRACT AT MARKET
    
    SET TARGET PROFIT TPT //TPT2
    SET STOP LOSS SSS //SSS2
    
    ENDIF
    
    IF SHORTRULE and TradeAllowed=1 THEN
    SELLSHORT PositionSize CONTRACT AT MARKET
    
    SET STOP LOSS SSS//SSS2
    SET TARGET PROFIT TPT//TPT2
    
    ENDIF
    ENDIF
    #192443 quote
    robertogozzi
    Moderator
    Master

    I tested it on DAX, 5-min TF,  and all entries are correct according to the two rules, GREEN or RED.

    What TF and instrument are you using?

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

Trade opens opposite direction


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
3 years, 9 months ago.

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