Signal confirmation before Algo starts

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #183514 quote
    idunnomuch
    Participant
    New

    I have a trading algo I have created. Seems to be working well for what I want.

    The issue is when you start it it immediately read as signal and goes into a trade – which is problematic.

    Obviously once it is in a trade and up and running it can do its own thing and is fine. The issue is always with its first step.

    Is there a way to programme it so that it waits for a signal before starting the algo and then never refers back to that again?

    i.e.

    indicator1 = DIplus[14]
    indicator2 = DIminus[14](close)
    c1 = (indicator1 CROSSES OVER indicator2)

    Once this happens then the algo will start?

     

    Thanks

    #183521 quote
    JS
    Participant
    Senior

    When you have started your algo, the first trade will depend on the conditions you have set in your algo.

    The condition, in your example, will indeed ensure that, when the condition is met, the first trade will be executed.

    There is nothing wrong with the condition in your example.

    #183522 quote
    robertogozzi
    Moderator
    Master

    Try adding this line at the very beginning:

    Defparam PreLoadBars = 0
    #183576 quote
    idunnomuch
    Participant
    New

    Thanks, but not quite what I was trying to explain. Sorry for my poor explanation.

    I shall try and explain it better.

    Basically I would like to get the algo to find a setup first, once it does this then execute a follow on strategy and once it is done, do nothing until the setup presents itself again.

    For instance.

    Once MACD line crosses signal – it will then wait for SMA 5 to be 3 points higher than SMA 8 before executing a buy signal.

    But after trade is executed and ended it should wait until the MACD line crosses the signal line before relooking for the setup.

    Does this make sense?

    IT is almost like when this is triggered wait for this condition and end. Wait for trigger again and then wait for condition.

    As the conditions never happen simultaneously and I want a cross over condition rather than a > condition.

    Thanks

    #183577 quote
    JS
    Participant
    Senior

    If I understand what you mean, then you must work with “conditions”:

    For example:

    MyCondition = 0

    If MACD Crosses Over …. Then

    MyCondition = 1

    EndIf

    If Average[5](close) > Average[8](close) + 3 AND MyCondition = 1 then

    Buy x contract at market

    EndIf

    #183578 quote
    JS
    Participant
    Senior

    For example, you can reset your condition when a position is closed.

    If OnMarket = 0 and OnMarket[1] = 1 then

    MyCondition = 0

    EndIf

    #183601 quote
    idunnomuch
    Participant
    New

    Thank you MYCondition is very useful.

    So as I understand it then – once MYCONDITION is fulfilled it will allow the other conditions “Average[5](close) > Average[8](close)” to trigger an action.

    Thanks for your help.

    #183605 quote
    JS
    Participant
    Senior

    That’s right, when MyCondition (or the name you want to give it) is triggered, it can, together with the next condition, generate a buy or sell signal.

    Please note that you put MyCondition back to zero after closing a trade by, for example,

    If OnMarket = 0 and OnMarket[1] = 1 then

    MyCondition = 0

    EndIf

    You can of course use more conditions for Long and Short, but that works in an equal way.

    #183651 quote
    idunnomuch
    Participant
    New

    Thanks – but I don’t think it does what I need.

    All it is doing to setting a trigger point with a condition.

    If Average[5](close) > Average[8](close) + 3 AND MyCondition = 1 then

    i.e. in this scenario all it needs to happen is the SMA 5 needs to be greater then the SMA8 and at the same time the MACD needs to have crossed over?

    What I want is a scenario where once the MACD crosses over it enables the trade to happen once the following parameters are satisfied.

    I don’t want them to need for them to happen all at the same time before it triggers the action.

    Does that makes sense?

    #183655 quote
    GraHal
    Participant
    Master

    If JS had called MyCondition a Flag then it may have been easier to grasp the concept?

    Flag = 0 at start of code, if MACD crosses over then Flag =1; Flag  stays at 1 forever until code resets to Flag = 0 (e.g. at trade exit).

    So Flag = 1 could be for 50 bars until Average[5](close) > Average[8](close) + 3.

    Hope that helps?

    #183691 quote
    idunnomuch
    Participant
    New

    Yes sorry my stupidity .. I get it now .. and i understand the principles and I believe have got it working.

    Many many thanks.

    JS and GraHal thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Signal confirmation before Algo starts


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
idunnomuch @idunnomuch Participant
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by idunnomuch
4 years, 2 months ago.

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