How do you define the "current price" in pro order

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #111953 quote
    jam
    Participant
    New

    I have made some code that returns no results in back testing. I use the 1Hr time frame and I want to buy in the next hour at a retracement level half way of the previous candle (high to low).

    To get the mid point of the previous candle I believe I use the MedianPrice[1] entry… please correct me if I am wrong.

    What I can’t figure out is how do I define the current price in the code… the best I can find (searching) is someone said use Close to define the current live price. So if I said open a position when Close = MedianPrice[1] does that mean it will open the position at the mid point of the previous candle? When I back test this and get no results, is that because the back test takes Close as being the close of the candle (which statistically would practically never equal the prior candle mid-point), but when running live will this actually buy in at the point I want, not the candle close at the end of the hour? … or have I got this completely messed up!

     

    // Define variables
    EntryPrice = MedianPrice[1]
    LongCandle = Close[1] > Open[1]
    ShortCandle = Close[1] < Open[1]
    Capital = 1000
    Equity = Capital + StrategyProfit
    PositionSize = round(Equity/1000)
    // Conditions to enter long positions
    IF CurrentDayOfWeek <> 0  AND IntradayBarIndex = 1 AND LongCandle AND Close = EntryPrice AND NOT LongOnMarket THEN
    BUY PositionSize CONTRACTS AT MARKET
    ELSE
    // Conditions to enter short positions
    IF CurrentDayOfWeek <> 0  AND IntradayBarIndex = 1 AND ShortCandle AND Close = EntryPrice AND NOT ShortOnMarket THEN
    SELLSHORT PositionSize CONTRACTS AT MARKET
    ENDIF
    ENDIF
    // Stops and targets : Enter your protection stops and profit targets here
    SET STOP LOSS AverageTrueRange[120]
    SET TARGET PROFIT 1.5*AverageTrueRange[120]
    
    #111977 quote
    robertogozzi
    Moderator
    Master

    The current price is reported by CLOSE and it’s done at the end of every candlestick.

    Place a pending LIMIT or STOP order to achieve that using either SELLSHORT or BUY:

    BUY/SELLSHORT PositionSize CONTRACTS AT EntryPrice LIMIT //or STOP
    jam thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

How do you define the "current price" in pro order


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
jam @jam Participant
Summary

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

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