Trade opens opposite direction

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #192431 quote
    1548284715482847
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 robertogozzirobertogozzi
4 years, 4 months ago.

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