Code_condition for last bar changes

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #237249 quote
    AlfredAlfred
    Participant
    Average

    Hi

    I would like to addition a condition code, if last bar increase/decrease 30 point or 0.3%, then buy at market open. And sell it at this bar or next bar close?

    May I know how to write? thanks.

     

    if close[1] >30 then
    buy 1 contract at market
    endif

    IF longonmarket AND (BarIndex – TradeIndex) = 1 THEN
    SELL AT Market
    ENDIF

    #237253 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    There you go:

    if (close - close[1]) > 30*PipSize then
       buy 1 contract at market
    elsif (close[1] - close) > 30*PipSize then
       sellshort 1 contract at market
    endif
    
    IF onmarket AND (BarIndex - TradeIndex) = 1 THEN
       SELL AT Market
       EXITSHORT AT Market
    ENDIF
    Alfred and Iván González thanked this post
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

Code_condition for last bar changes


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Alfred @kin08180213 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzirobertogozzi
2 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/06/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...