BUY or SELL in the actual bar is possible?

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #54910 quote
    SickBoySpain
    Participant
    Junior

    Hi,

     

    I want to know if it’s possible to buy or sell in the same bar that I check the conditions.

     

    At the moment, I can only buy or sell on the next bar, so I have one bar delay in my system.

     

    It’s easy to check, just with a var that I GRAPH in the backtest. Also I can see that in real.

    It’s there a way to avoid this??

     

    Thanks in adavance

    #54916 quote
    Despair
    Blocked
    Master

    There is no way around this delay. During a bar only stop and limit orders are executed (which have to be set before the bar begins). Nothing else would be possible anyway since PRT evaluates your code just once at the close of every bar. During the bar nothing is going on.

    #54922 quote
    SickBoySpain
    Participant
    Junior
    Thank you,   I’ve been trying to avoid this, but as you said, it’s impossible.
    Nothing else would be possible anyway since PRT evaluates your code just once at the close of every bar. During the bar nothing is going on.
    Ok, but after the evaluation, PRT could simply send the order at market, just that, looks so simple….  
    I insert a var in the code and show on screen with GRAPH, and it’s  one bar before the order. I really don’t like this at all
    #54950 quote
    Despair
    Blocked
    Master

    At the close of the bar you can send a market order that will be executed at the open of the following bar.

    #54972 quote
    Leo
    Participant
    Veteran
    There are two possible Solutions:
    • Despair has already said: in the previous candle open orders like  “buy 1 contract at XXX stop”, XXX is the Price where the conditions will be meet in the current candle
    • Create an strategy in shorter time Frame: for example a Moving Average of 20 periods in a 1h time Frame Looks very similar to a Moving Average of 40 periods in a 30min time Frame
    Someone else knows another approach?
    #54987 quote
    SickBoySpain
    Participant
    Junior
    There are two possible Solutions:
    • Despair has already said: in the previous candle open orders like “buy 1 contract at XXX stop”, XXX is the Price where the conditions will be meet in the current candle
    • Create an strategy in shorter time Frame: for example a Moving Average of 20 periods in a 1h time Frame Looks very similar to a Moving Average of 40 periods in a 30min time Frame
    Someone else knows another approach?


    Despair option it’s the same problem, you are sending the order 1 candle after you check the conditions.

     

    The strategy works well in the timeframe I create it for, don’t want to change, because PRT does not have multitimeframe.

    Maybe multitimeframe it’s dificult to program, but sending the order AT THE MOMENT I get the signal should be really easy.

     

    I will leave PRT as soon as possible

    #54988 quote
    Nicolas
    Keymaster
    Master

    If you could explain a bit what is your condition, we could try to find something to better suit your trading style. Is is based on indicators or only price itself? 

    #54989 quote
    SickBoySpain
    Participant
    Junior
    If you could explain a bit what is your condition, we could try to find something to better suit your trading style. Is is based on indicators or only price itself?


    It’s based on indicators.

     

    I just want to buy or sell, open or close positions when I want. I can’t understand why I have to wait one full candle to send the order, or change the stop loss or the take profit. So many good strategy are wrong because of this.

     

    Let’s say you have an average, ando you are checking the change of direction…

    m= average[40](close)
    changeup = m[2]>m[1] and m[1]<m
    
    if changeup THEN
      buy at market
    ENDIF

    That code will buy 2 bars after the change. One it’s ok, as you have to wait for the candle to close and check, but the second candle….

    #55008 quote
    Nicolas
    Keymaster
    Master

    You are right. But if your strategy only rely on moving averages, you can use period multiplier in inferior timeframe to get values from the superior ones. That way you can interact between bars, this is just a simple workaround before we get the multi timeframe support.. 

    #55098 quote
    SickBoySpain
    Participant
    Junior
    You are right. But if your strategy only rely on moving averages, you can use period multiplier in inferior timeframe to get values from the superior ones. That way you can interact between bars, this is just a simple workaround before we get the multi timeframe support..


    It’s not only averages, so it’s dificult to adapt. And as you already know, a period multiplier it’s not exactly the same.

    Multitiframe it’s a must

    Intermarket it’s a must

    AND why CAN’T I send an order at the moment?? Why?? I really can’t understand this

    #55099 quote
    Leo
    Participant
    Veteran
    I feel you upset SickBoySpain, Your code will exclty work if you reduce the time frame by half and increase the period by 2. Another possibility is to think more deep into the mathematics of code, you can know far in advance if the slope of your moving average will Change ist slope. (unless North Korea attacks Usa or something very strange in the bar will happend) In any case, let us know if you get a profitable code in a so symple way.
    #55127 quote
    SickBoySpain
    Participant
    Junior
    I feel you upset SickBoySpain, Your code will exclty work if you reduce the time frame by half and increase the period by 2. Another possibility is to think more deep into the mathematics of code, you can know far in advance if the slope of your moving average will Change ist slope. (unless North Korea attacks Usa or something very strange in the bar will happend) In any case, let us know if you get a profitable code in a so symple way.


    Mi code it’s not about medium average, and this problem it’s not about the code, it’s about that I have to wait one extra bar to enter or exit the market

     

    Why do I have to wait if I already have the signal??

     

    If I want to make a 4H strategy, do I have to wait 4 Hours to enter the market??

    In a daily strategy, wait 1 DAY!!!

     

    I simply don’t understand

    #55128 quote
    SickBoySpain
    Participant
    Junior
    I feel you upset SickBoySpain, Your code will exclty work if you reduce the time frame by half and increase the period by 2. Another possibility is to think more deep into the mathematics of code, you can know far in advance if the slope of your moving average will Change ist slope. (unless North Korea attacks Usa or something very strange in the bar will happend) In any case, let us know if you get a profitable code in a so symple way.


    And no, you can’t reduce the time frame and increase the period and get the same results.

     

    Try it, and you will see that it’s not correct

    #55192 quote
    AVT
    Participant
    Senior

    What about this idea:

    You know for example a 4-hour bar starts at say 14:00 and you want to enter half an hour later, so just hardcode

    if current time==14:30 buy a contract – and sell one hour later if current time==15:00 sell the contract.

    Something like this should be possible.

    #55193 quote
    Despair
    Blocked
    Master

    Won’t work, the condition in your example will never come true. The code is only evaluated att the end of each bar. Both 14:30 and 15:00 are never seen by your code. It will be checked once every 4 hours.

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

BUY or SELL in the actual bar is possible?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 18 replies,
has 6 voices, and was last updated by Marke
8 years, 2 months ago.

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